basic Kick support

This commit is contained in:
Luxferre
2024-09-15 14:58:30 +03:00
parent 430d67913b
commit 030dfdb956
4 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -285,7 +285,7 @@ Work in progress. Needs additional testing. Basic messages work as expected.
### Kick (internal) ### Kick (internal)
Work in progress. Relies on an API that hasn't been officially released yet. Needs additional testing. Basic messages work as expected. Work in progress. Relies on an API that hasn't been officially released yet and an external library to bypass CloudFlare checks. Needs additional testing. Basic messages work as expected.
## FAQ ## FAQ
+2 -2
View File
@@ -79,7 +79,7 @@ func kk_handle_emotes(text string) string {
re := regexp.MustCompile(regexp.QuoteMeta("[emote:") + "[^:]+:[^" + mbracket + "]+" + mbracket) re := regexp.MustCompile(regexp.QuoteMeta("[emote:") + "[^:]+:[^" + mbracket + "]+" + mbracket)
text = re.ReplaceAllStringFunc(text, func(emotestr string) string { text = re.ReplaceAllStringFunc(text, func(emotestr string) string {
parts := strings.Split(emotestr, ":") parts := strings.Split(emotestr, ":")
return "#KKEMOTE-" + parts[1] + "#" return " #KKEMOTE-" + parts[1] + "# "
}) })
return text return text
} }
@@ -126,7 +126,7 @@ func kk_process_message(rawmsg map[string]interface{}) {
if _, ok := metadata["badges"]; ok && len(metadata["badges"].([]interface{})) > 0 { if _, ok := metadata["badges"]; ok && len(metadata["badges"].([]interface{})) > 0 {
for _, badge := range metadata["badges"].([]interface{}) { for _, badge := range metadata["badges"].([]interface{}) {
if badge.(map[string]interface{})["active"].(bool) { if badge.(map[string]interface{})["active"].(bool) {
out_message.Type += "-" + badge.(map[string]interface{})["text"].(string) out_message.Type += "-" + strings.ToLower(badge.(map[string]interface{})["text"].(string))
} }
} }
} }
+3
View File
@@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"log" "log"
"strings" "strings"
"slices"
"encoding/json" "encoding/json"
"net/http" "net/http"
"io/ioutil" "io/ioutil"
@@ -98,6 +99,8 @@ func sseHandler(w http.ResponseWriter, r *http.Request) {
/* close the channel after exiting the function */ /* close the channel after exiting the function */
defer func() { defer func() {
close(transport) close(transport)
idx := slices.IndexFunc(sse_transports, func(c chan string) bool { return c == transport })
sse_transports[idx] = nil
transport = nil transport = nil
}() }()
+1 -1
View File
@@ -59,7 +59,7 @@ function gooseAppendMessage(id, type, timestamp, username, text, icon) {
} }
document.getElementById("msglist").innerHTML += html document.getElementById("msglist").innerHTML += html
/* autoscroll to the end */ /* autoscroll to the end */
window.scrollTo(0, document.body.scrollHeight) window.setTimeout(function(){window.scrollTo(0, document.body.scrollHeight)}, 100)
} }
/* entry point, set up an event source */ /* entry point, set up an event source */