Compare commits

..
6 Commits
Author SHA1 Message Date
Peter Beluzsar c43d0e75c7 things 2026-05-27 17:46:30 +02:00
Belupeti 917b8c8add add discord webhool 2026-02-12 16:47:38 +01:00
Belupeti d698471fb8 css mobile 2026-02-05 23:52:47 +01:00
Belupeti b4f66aa635 css mobile 2026-02-05 23:29:18 +01:00
Peter Beluzsar 72be3434fc Merge branch 'master' of ssh://gitea.sc0tt.org:222/Belupeti/scottgpt 2026-02-05 22:24:04 +01:00
Peter Beluzsar f424bfa9a0 css 2026-02-05 22:23:36 +01:00
6 changed files with 106 additions and 41 deletions
+2
View File
@@ -14,6 +14,7 @@ version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
application {
@@ -26,6 +27,7 @@ dependencies {
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("io.ktor:ktor-server-sessions:${ktor_version}")
implementation("io.ktor:ktor-server-auth:${ktor_version}")
implementation("com.github.BinaryWriter:discord-webhooks:1.0")
}
tasks.test {
+2 -2
View File
@@ -3,6 +3,7 @@ services:
build: .
container_name: "scottgpt"
env_file: .env
restart: unless-stopped
volumes:
- ./src/main/resources:/srv/src
networks:
@@ -11,8 +12,7 @@ services:
- "traefik.enable=true"
- "traefik.http.routers.scottgpt.rule=Host(`ai.sc0tt.org`)"
- "traefik.http.services.scottgpt.loadbalancer.server.port=8080"
- "traefik.http.routers.scottgpt.tls.certresolver=myresolver"
# - "traefik.http.routers.scottgpt.tls.certresolver=letsencrypt"
networks:
traefik:
external: true
+45 -5
View File
@@ -14,6 +14,9 @@ import kotlin.random.nextInt
import io.ktor.server.auth.*
import io.ktor.server.application.*
import me.binarywriter.discordwebhooks.data.* //discord webhook
import java.awt.Color
//átlagos JAVA alapú fejlesztő
val httpPort: Int = System.getenv("HTTP_PORT")?.toInt() ?: 8080
@@ -180,6 +183,36 @@ class Message(val user: Boolean, messagetext: String)
}
}
fun discordWebhook(id: Int, message: String, embed_color: Color)
{
val webhook = Webhook {
this.username = "Sc0ttGPT bot"
//this.content = "Content"
embed {
this.title = id.toString()
this.description = message
this.url = "https://vesztettem.sch.bme.hu/"
/*
author {
this.name = "Author Name"
}
*/
this.color = embed_color
/*
field {
this.name = "Field Name"
this.value = "Field Value"
}*/
}
// ...
}
webhook.send("https://discord.com/api/webhooks/1471523550522249381/XVHtwUk7JsPvfwbd1J8sX9inb6Q05lsXRfww1mTpOGcgcAw15diohzBgVg7qlQtw1eyA")
}
fun main(args: Array<String>) {
Logger.log("HTTP server started on 127.0.0.1:$httpPort")
@@ -237,17 +270,23 @@ fun runEmbeddedServer()
}
}
staticFiles("/admin", File(resourcesPath+"/admin.html"))
staticFiles("/admin", File("$resourcesPath/admin.html"))
staticFiles("/resources", File(resourcesPath))
staticFiles("/", File(resourcesPath+"/index.html"))
staticFiles("/about", File(resourcesPath+"/about.html"))
staticFiles("/", File("$resourcesPath/index.html"))
staticFiles("/style", File("$resourcesPath/style.css"))
staticFiles("/about", File("$resourcesPath/about.html"))
put("/api/write/{id}")
{
try {
val id = call.parameters["id"]?.toInt() ?: -1
val text = call.receiveText()
ConversationHandler.conversations.find {
it.ID == call.parameters["id"]?.toInt()
}?.write(Message(true, call.receiveText()))
it.ID == id
}?.write(Message(true, text))
discordWebhook(id, text, Color.blue)
call.respond(HttpStatusCode.OK)
@@ -267,6 +306,7 @@ fun runEmbeddedServer()
get("/api/init") {
ConversationHandler.newConv()
Logger.log("Conversation ${ConversationHandler.conversations.last().ID} initialized")
discordWebhook(ConversationHandler.conversations.last().ID, "New conversation probably incoming", Color.green)
call.respondText(ConversationHandler.conversations.last().ID.toString())
}
+30 -21
View File
@@ -2,34 +2,25 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>ScottGPT</title>
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
<link rel="stylesheet" href="/resources/style.css">
<link rel="stylesheet" href="/style">
</head>
<body onload="javascript:init()" style="margin: 0; height: 100%; overflow: hidden;">
<div class="main-flexbox">
<header class="navbar">
<header class="navbar" id="funniez">
<a href="https://sc0tt.org/" style="float: left" target="_blank">Sc0tt főoldal</a>
<a href="/about" style="float: left">About</a>
<button onclick="genZ()" style="float: left;">Gen Z compatible site</button>
<!--<button onclick="genZ()" style="float: left;" class="funny">Gen Z compatible site</button>-->
<img src="resources/logo.png" alt=logo" style="float: right;">
<a href="javascript:void(0);"
class="icon"
onclick="toggleMenu()">
&#9776;
</a>
<img src="resources/logo.png" alt=logo" class="logo" style="float: right;">
</header>
<iframe width="420" height="315"
src="https://www.youtube.com/embed/mn-Tlb_wfjc"
id="funniez"
style="display: none;">
</iframe>
<div id="messages" class="messages">
@@ -37,8 +28,8 @@
<footer>
<div class="textbox">
<input class="text_input" name="valami" type="text" id="promptText" placeholder="Kérdezz az OSI modellről... vagy idk...">
<button id="send-button" class="send_button" onclick="send_data()">send</button>
<input class="text_input" name="valami" type="text" id="promptText" placeholder="Kérdezz az OSI modellről... vagy idk..." onchange="sendButton()" >
<button id="send-button" class="send_button" onclick="send_data()"></button>
</div>
</footer>
@@ -48,8 +39,22 @@
<script>
let id;
var genz = false;
var input = document.getElementById("promptText");
function sendButton() {
var x = document.getElementById("send-button");
var input = document.getElementById("promptText")
console.log(input.value)
if (input.value == "") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
input.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
@@ -60,11 +65,15 @@
});
function genZ() {
var x = document.getElementById("funniez");
if (x.style.display === "none") {
x.style.display = "block";
let genzHtml = " <iframe width=\"420\" height=\"315\"\n" +
" src=\"https://www.youtube.com/embed/mn-Tlb_wfjc\"\n" +
" style=\"display: none;\" id='genz'>\n" +
" </iframe>";
if (genz === false) {
document.getElementById("funniez").insertAdjacentHTML("afterend", genzHtml);
} else {
x.style.display = "none";
document.getElementById("genz").remove();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

+25 -11
View File
@@ -2,6 +2,8 @@ body {
background: #212121;
color: white;
font-family: Roboto, sans-serif;
max-width: 100%;
overflow-x: hidden;
}
.about-content {
@@ -21,18 +23,16 @@ body {
}
.main-content {
/*
display: flex;
margin: auto;
text-align: center;
box-sizing: border-box;*/
margin-top: 5%;
margin-bottom: 0;
justify-content: center;
flex-direction: column;
height: 80vh;
overflow-y: scroll;
flex-grow: 8
max-width: 100%;
overflow-x: hidden;
flex-grow: 8;
background: red;
}
@@ -63,7 +63,6 @@ body {
}
.messages {
margin-bottom: 10%;
position: relative;
display: flex;
margin: 5px auto 0px auto;
@@ -107,12 +106,13 @@ body {
}
.send_button {
aspect-ratio: 1 / 1;
justify-content: flex-end;
padding: 4px 8px;
margin: 10px;
height: 30px;
border-radius: 50%;
background: white;
background-image: url("/resources/send.png");
color: #212121;
border: none;
}
@@ -122,6 +122,7 @@ body {
display: flex;
margin: auto;
width: 80%;
padding: 10px 10px;
border-radius: 25px;
}
@@ -170,8 +171,6 @@ footer {
border-radius: 5px;
}
.navbar img {
height: 32px;
margin: auto 5px;
@@ -181,7 +180,22 @@ footer {
background-color: #545454;
}
@media (max-width: 767px) {
.textbox-parent {
bottom: 30px;
}
.messages {
width: 100%;
}
.message {
width: 80%;
}
.funny {
display: none;
}
}
.navbar a.icon {
display: none;
}
}