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 0000000..d0819a3 Binary files /dev/null and b/__pycache__/twitch.cpython-314.pyc differ diff --git a/config.ini b/config.ini index 4abff32..d89c5b7 100644 --- a/config.ini +++ b/config.ini @@ -3,7 +3,7 @@ bot_secret = 6454033742:AAFj2rUoVb2jJ_Lew4eiIecdr7s7xbrqeNU 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 @@
-' + 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