From d114970eec90ed3fe86c183968f1469d5838cd1d Mon Sep 17 00:00:00 2001 From: sShemet Date: Wed, 31 Dec 2025 16:57:55 +0500 Subject: [PATCH] fixes --- UltraChat.code-workspace | 6 - __pycache__/twitch.cpython-314.pyc | Bin 0 -> 5167 bytes config.ini | 2 +- huy.py | 9 +- huySeek.py | 10 +- index.html | 169 +++++++++++------------------ script.js | 151 ++++++++++++-------------- yttest.py | 10 ++ 8 files changed, 149 insertions(+), 208 deletions(-) create mode 100644 __pycache__/twitch.cpython-314.pyc create mode 100644 yttest.py diff --git a/UltraChat.code-workspace b/UltraChat.code-workspace index b40612d..876a149 100644 --- a/UltraChat.code-workspace +++ b/UltraChat.code-workspace @@ -2,12 +2,6 @@ "folders": [ { "path": "." - }, - { - "path": "csharp/Chapter01/HelloCS" - }, - { - "path": "repos" } ], "settings": {} diff --git a/__pycache__/twitch.cpython-314.pyc b/__pycache__/twitch.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d0819a3bc76a1aac6acdeb0d9bab53bc72462de4 GIT binary patch literal 5167 zcmb6dTWlN0aqsv#QX;80X-lHWP%rA`*pXvJmS54!jADv8$#fgjBF^MVzL>AxEu)BT z9sR{dTi7XrhHg+;K@mhoP((mcKp*``f0}$1R3ux(RV{+XK%1Y!v0NlbKib(NkECej zqf20RZ+2#Oc6N4Vmc16U2|;`Kug@38%m{r+KGdcy40cb$U>VIJmhvJ@dfH1JrQ66z zUc^b*1pi!eQBz?vqM02M$SjdiRB>sc)}3?R&0GWr|Jh2+PehHj9`k8u^Nw;^23 z8UUJE2B3vC0<^Mbw#tU06s}>bacuzMI@ScrT4eL=qJYC!Mz3(#%Z{e&1Tj1ihK~WP z;0N&QvgNgugoXG#7k~cP;E`u#)6D4EbJNp)uXkLiI*3rZ>vZ=(@2T!nCxTM%u*Wmd z<7d5rb2F0{=Y}u!40m6g3yQ(`r5;bXU@1jeJwPx6vx@+`jDq523y?R7unCk)Z{AO&LRB_Ib8J5Lzr8T z(mM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eNU enabled = 1 [Youtube] -video_id = coYw-eVU0Ks +video_id = SsC29jqiNto [Twitch] channel = wanderbraun diff --git a/huy.py b/huy.py index 2479c3b..b7e68a8 100644 --- a/huy.py +++ b/huy.py @@ -21,7 +21,7 @@ from zoneinfo import * from http.server import BaseHTTPRequestHandler, HTTPServer import pytchat import telegram -from donationalerts import DonationAlertsAPI, Scope +from donationalerts import DonationAlertsAPI, Scopes from urllib import parse sys.path.append('twitchchatirc') import twitch @@ -37,8 +37,7 @@ alerts = DonationAlertsAPI( config['Alerts']['api_key'], "http://127.0.0.1:8008/login", [ - Scope.OAUTH_USER_SHOW, - Scope.OAUTH_DONATION_INDEX + Scopes.USER_SHOW, ] ) @@ -52,7 +51,7 @@ class DateTimeEncoder(json.JSONEncoder): return json.JSONEncoder.default(self, o) -chat = pytchat.create(video_id=config['Youtube']['video_id']) +# chat = pytchat.create(video_id=config['Youtube']['video_id']) # twitchConn = twitch_chat_irc.TwitchChatIRC() @@ -176,7 +175,7 @@ def makeJSONObject(): #we are parsing TG and YT tw_comments = twitch_socket.all_messages - get_yt() #Get YouTube + # get_yt() #Get YouTube try: get_alerts() #Get Donations diff --git a/huySeek.py b/huySeek.py index a8c3974..4806314 100644 --- a/huySeek.py +++ b/huySeek.py @@ -12,7 +12,7 @@ from zoneinfo import ZoneInfo from http.server import BaseHTTPRequestHandler, HTTPServer import pytchat import telegram -from donationalerts import DonationAlertsAPI, Scope +from donationalerts import DonationAlertsAPI, Scopes from urllib import parse import emoji sys.path.append('twitchchatirc') @@ -73,7 +73,7 @@ class DonationAlertsService: config.alerts_app_id, config.alerts_api_key, "http://127.0.0.1:8008/login", - [Scope.OAUTH_USER_SHOW, Scope.OAUTH_DONATION_INDEX] + [Scopes.USER_SHOW] ) self.access_token = None @@ -222,7 +222,7 @@ class ChatAggregator: self.services = { 'alerts': DonationAlertsService(self.config), 'telegram': TelegramService(self.config), - 'youtube': YouTubeService(self.config), + # 'youtube': YouTubeService(self.config), 'twitch': TwitchService(self.config) } self.comments = [] @@ -265,7 +265,7 @@ class ChatAggregator: new_comments.extend(self.services['alerts'].get_donations()) # YouTube - new_comments.extend(self.services['youtube'].get_messages()) + # new_comments.extend(self.services['youtube'].get_messages()) # Telegram if self.config.telegram_enabled: @@ -352,7 +352,7 @@ class ChatAggregator: def log_message(self, format, *args): return - server_address = ('', 8008) + server_address = ('127.0.0.1', 8008) httpd = HTTPServer(server_address, lambda *args: Handler(*args, aggregator=self)) print(f'Starting HTTP server on port 8008...') httpd.serve_forever() diff --git a/index.html b/index.html index 36a7519..6ab8e1f 100644 --- a/index.html +++ b/index.html @@ -1,125 +1,80 @@ - template + SSH UltraChat - - + .hello { + background-color: #00bb77; + background-image: url("data:image/svg+xml,"); + } + - -
- -
-
- +
diff --git a/script.js b/script.js index 8c98f28..e4a18d2 100644 --- a/script.js +++ b/script.js @@ -40,109 +40,92 @@ let messages = [ "XAOSHammer", "Kino Konformist" ]; - const chatwin = document.getElementById("chatwin"); - const anchor = document.getElementById("anchor"); - - function randomMessage() { +const chatwin = document.getElementById("chatwin"); + +function randomMessage() { return messages[(Math.random() * messages.length) | 0]; - } - function randomNick() { +} + +function randomNick() { return nicks[(Math.random() * nicks.length) | 0]; - } - - function randomChat() { if (Math.random() * 2 > 1) {return "tg"} else { return "yt" } } - - function goDown() { - window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }); - } - - function removeElementsByClass(className){ - const elements = document.getElementsByClassName(className); - while(elements.length > 15){ - elements[0].parentNode.removeChild(elements[0]); - } - } - - function createChatLine() { - +} + +function randomChat() { + return Math.random() > 0.5 ? "tg" : "yt"; +} + +function scrollToBottom() { + chatwin.scrollTop = chatwin.scrollHeight; +} + +function removeOldMessages() { + const children = Array.from(chatwin.children); + while (children.length > 15) { + chatwin.removeChild(children[0]); + } +} + +function createChatLine() { const nm = document.createElement("div"); nm.className = "nameline " + randomChat(); - nm.innerHTML = randomNick(); - + nm.textContent = randomNick(); + const msg = document.createElement("div"); msg.className = "msgline"; - msg.innerHTML = randomMessage(); - + msg.textContent = randomMessage(); + const rw = document.createElement("div"); rw.className = "chatRow"; rw.appendChild(nm); rw.appendChild(msg); - console.log(rw); - - chatwin.insertBefore(rw, anchor); - - - goDown(); - } - - function createNewLine(json) { - - json.forEach(element => { - - //checking new IDs on screen and print + chatwin.appendChild(rw); + scrollToBottom(); + removeOldMessages(); +} - //const elements = document.getElementsByName(element["id"]); - //if (elements.length > 0) { //if this id is present on screen - - let curline = document.getElementById(element["id"]) - if (curline) { - curline.innerHTML = element["msg"] - return; - }; //Updating text... - - const nm = document.createElement("div"); - nm.className = "nameline " + element["type"]; - nm.innerHTML = element["sendr"]; - if (element["type"] == "donate") { nm.innerHTML = nm.innerHTML + '

' + element['amount']+"

" } - - const msg = document.createElement("div"); - msg.className = "msgline"; - msg.innerHTML = element["msg"]; - msg.setAttribute("id", element["id"]); - if (element["type"] == "donate") { msg.style="background-color: #0000FF20" } +function createNewLine(json) { + json.forEach(element => { + const existing = document.getElementById(element.id); + if (existing) { + existing.querySelector('.msgline').textContent = element.msg; + return; + } - - const rw = document.createElement("div"); - rw.className = "chatRow"; - rw.setAttribute("name", element["id"]); - - rw.appendChild(nm); - rw.appendChild(msg); - //console.log(rw); - - chatwin.insertBefore(rw, anchor); + const nm = document.createElement("div"); + nm.className = "nameline " + element.type; + nm.textContent = element.sendr; + if (element.type === "donate") { + nm.innerHTML += `

${element.amount}

`; + } - }); + const msg = document.createElement("div"); + msg.className = "msgline"; + msg.textContent = element.msg; + msg.id = element.id; + if (element.type === "donate") { + msg.style.backgroundColor = "#0000FF20"; + } + const rw = document.createElement("div"); + rw.className = "chatRow"; + rw.appendChild(nm); + rw.appendChild(msg); + chatwin.appendChild(rw); + scrollToBottom(); + removeOldMessages(); + }); } function requestNewLines() { - - var request = new XMLHttpRequest(); - request.open('GET', "http://localhost:8008/"); - request.responseType = 'json'; - request.send(); - - request.onload = function() { - var chatJSON = request.response; - createNewLine(chatJSON); - goDown(); - } - + fetch("http://localhost:8008/") + .then(response => response.json()) + .then(data => createNewLine(data)) + .catch(error => console.error('Ошибка:', error)); } - - setInterval(requestNewLines,1000); \ No newline at end of file + +setInterval(requestNewLines, 1000); +// setInterval(createChatLine, 3000); \ No newline at end of file diff --git a/yttest.py b/yttest.py new file mode 100644 index 0000000..a22c396 --- /dev/null +++ b/yttest.py @@ -0,0 +1,10 @@ +from donationalerts import DonationAlertsAPI, Scopes + +api = DonationAlertsAPI( + client_id="your_id", + client_secret="your_secret", + redirect_uri="http://127.0.0.1:8008/login", + scopes=[Scopes.USER_SHOW] +) + +print("Auth URL:", api.authorize.login()) \ No newline at end of file