Compare commits
4
Commits
72be3434fc
...
elbasztam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c43d0e75c7 | ||
|
|
917b8c8add | ||
|
|
d698471fb8 | ||
|
|
b4f66aa635 |
@@ -14,6 +14,7 @@ version = "1.0-SNAPSHOT"
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url = uri("https://jitpack.io") }
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
@@ -26,6 +27,7 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
||||||
implementation("io.ktor:ktor-server-sessions:${ktor_version}")
|
implementation("io.ktor:ktor-server-sessions:${ktor_version}")
|
||||||
implementation("io.ktor:ktor-server-auth:${ktor_version}")
|
implementation("io.ktor:ktor-server-auth:${ktor_version}")
|
||||||
|
implementation("com.github.BinaryWriter:discord-webhooks:1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
container_name: "scottgpt"
|
container_name: "scottgpt"
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./src/main/resources:/srv/src
|
- ./src/main/resources:/srv/src
|
||||||
networks:
|
networks:
|
||||||
@@ -11,8 +12,7 @@ services:
|
|||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.scottgpt.rule=Host(`ai.sc0tt.org`)"
|
- "traefik.http.routers.scottgpt.rule=Host(`ai.sc0tt.org`)"
|
||||||
- "traefik.http.services.scottgpt.loadbalancer.server.port=8080"
|
- "traefik.http.services.scottgpt.loadbalancer.server.port=8080"
|
||||||
- "traefik.http.routers.scottgpt.tls.certresolver=myresolver"
|
# - "traefik.http.routers.scottgpt.tls.certresolver=letsencrypt"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
traefik:
|
traefik:
|
||||||
external: true
|
external: true
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import kotlin.random.nextInt
|
|||||||
import io.ktor.server.auth.*
|
import io.ktor.server.auth.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
|
||||||
|
import me.binarywriter.discordwebhooks.data.* //discord webhook
|
||||||
|
import java.awt.Color
|
||||||
|
|
||||||
//átlagos JAVA alapú fejlesztő
|
//átlagos JAVA alapú fejlesztő
|
||||||
|
|
||||||
val httpPort: Int = System.getenv("HTTP_PORT")?.toInt() ?: 8080
|
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>) {
|
fun main(args: Array<String>) {
|
||||||
Logger.log("HTTP server started on 127.0.0.1:$httpPort")
|
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("/resources", File(resourcesPath))
|
||||||
staticFiles("/", File(resourcesPath+"/index.html"))
|
staticFiles("/", File("$resourcesPath/index.html"))
|
||||||
staticFiles("/about", File(resourcesPath+"/about.html"))
|
staticFiles("/style", File("$resourcesPath/style.css"))
|
||||||
|
staticFiles("/about", File("$resourcesPath/about.html"))
|
||||||
|
|
||||||
put("/api/write/{id}")
|
put("/api/write/{id}")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
val id = call.parameters["id"]?.toInt() ?: -1
|
||||||
|
val text = call.receiveText()
|
||||||
|
|
||||||
ConversationHandler.conversations.find {
|
ConversationHandler.conversations.find {
|
||||||
it.ID == call.parameters["id"]?.toInt()
|
it.ID == id
|
||||||
}?.write(Message(true, call.receiveText()))
|
}?.write(Message(true, text))
|
||||||
|
|
||||||
|
discordWebhook(id, text, Color.blue)
|
||||||
|
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
|
|
||||||
@@ -267,6 +306,7 @@ fun runEmbeddedServer()
|
|||||||
get("/api/init") {
|
get("/api/init") {
|
||||||
ConversationHandler.newConv()
|
ConversationHandler.newConv()
|
||||||
Logger.log("Conversation ${ConversationHandler.conversations.last().ID} initialized")
|
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())
|
call.respondText(ConversationHandler.conversations.last().ID.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,34 +2,25 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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>
|
<title>ScottGPT</title>
|
||||||
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
|
<link rel="icon" type="image/x-icon" href="/resources/favicon.ico">
|
||||||
<link rel="stylesheet" href="/resources/style.css">
|
<link rel="stylesheet" href="/style">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body onload="javascript:init()" style="margin: 0; height: 100%; overflow: hidden;">
|
<body onload="javascript:init()" style="margin: 0; height: 100%; overflow: hidden;">
|
||||||
|
|
||||||
<div class="main-flexbox">
|
<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="https://sc0tt.org/" style="float: left" target="_blank">Sc0tt főoldal</a>
|
||||||
<a href="/about" style="float: left">About</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;">
|
<img src="resources/logo.png" alt=logo" class="logo" style="float: right;">
|
||||||
|
|
||||||
<a href="javascript:void(0);"
|
|
||||||
class="icon"
|
|
||||||
onclick="toggleMenu()">
|
|
||||||
☰
|
|
||||||
</a>
|
|
||||||
</header>
|
</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">
|
<div id="messages" class="messages">
|
||||||
|
|
||||||
@@ -37,8 +28,8 @@
|
|||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<div class="textbox">
|
<div class="textbox">
|
||||||
<input class="text_input" name="valami" type="text" id="promptText" placeholder="Kérdezz az OSI modellről... vagy idk...">
|
<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()">send</button>
|
<button id="send-button" class="send_button" onclick="send_data()"></button>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@@ -48,8 +39,22 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
let id;
|
let id;
|
||||||
|
var genz = false;
|
||||||
|
|
||||||
var input = document.getElementById("promptText");
|
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) {
|
input.addEventListener("keypress", function(event) {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
|
|
||||||
@@ -60,11 +65,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function genZ() {
|
function genZ() {
|
||||||
var x = document.getElementById("funniez");
|
let genzHtml = " <iframe width=\"420\" height=\"315\"\n" +
|
||||||
if (x.style.display === "none") {
|
" src=\"https://www.youtube.com/embed/mn-Tlb_wfjc\"\n" +
|
||||||
x.style.display = "block";
|
" style=\"display: none;\" id='genz'>\n" +
|
||||||
|
" </iframe>";
|
||||||
|
|
||||||
|
if (genz === false) {
|
||||||
|
document.getElementById("funniez").insertAdjacentHTML("afterend", genzHtml);
|
||||||
} else {
|
} else {
|
||||||
x.style.display = "none";
|
document.getElementById("genz").remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -2,6 +2,8 @@ body {
|
|||||||
background: #212121;
|
background: #212121;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: Roboto, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.about-content {
|
.about-content {
|
||||||
@@ -21,17 +23,15 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
/*
|
|
||||||
display: flex;
|
|
||||||
margin: auto;
|
|
||||||
text-align: center;
|
|
||||||
box-sizing: border-box;*/
|
|
||||||
margin-top: 5%;
|
margin-top: 5%;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 80vh;
|
height: 80vh;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
flex-grow: 8;
|
flex-grow: 8;
|
||||||
|
|
||||||
background: red;
|
background: red;
|
||||||
@@ -63,7 +63,6 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.messages {
|
.messages {
|
||||||
margin-bottom: 10%;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 5px auto 0px auto;
|
margin: 5px auto 0px auto;
|
||||||
@@ -107,12 +106,13 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.send_button {
|
.send_button {
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: white;
|
background-image: url("/resources/send.png");
|
||||||
color: #212121;
|
color: #212121;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
@@ -121,12 +121,7 @@ body {
|
|||||||
background: #323232;
|
background: #323232;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
@media (max-width: 600px) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
@media (min-width: 600px) {
|
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
|
||||||
|
|
||||||
padding: 10px 10px;
|
padding: 10px 10px;
|
||||||
border-radius: 25px;
|
border-radius: 25px;
|
||||||
@@ -185,6 +180,21 @@ footer {
|
|||||||
background-color: #545454;
|
background-color: #545454;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.textbox-parent {
|
||||||
|
bottom: 30px;
|
||||||
|
}
|
||||||
|
.messages {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.message {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
.funny {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.navbar a.icon {
|
.navbar a.icon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user