This commit is contained in:
sShemet
2025-12-31 16:57:55 +05:00
parent ade2833df7
commit d114970eec
8 changed files with 149 additions and 208 deletions

View File

@@ -2,12 +2,6 @@
"folders": [
{
"path": "."
},
{
"path": "csharp/Chapter01/HelloCS"
},
{
"path": "repos"
}
],
"settings": {}

Binary file not shown.

View File

@@ -3,7 +3,7 @@ bot_secret = 6454033742:AAFj2rUoVb2jJ_Lew4eiIecdr7s7xbrqeNU
enabled = 1
[Youtube]
video_id = coYw-eVU0Ks
video_id = SsC29jqiNto
[Twitch]
channel = wanderbraun

9
huy.py
View File

@@ -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

View File

@@ -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()

View File

@@ -1,48 +1,36 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>template</title>
<title>SSH UltraChat</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
<style>
body {
margin: 0;
padding: 0;
background-color: #494949;
display: flex;
align-items: center;
align-items: flex-start;
justify-content: center;
align-content: flex-end;
height: 100vh;
font-family: "Roboto Condensed", sans-serif;
font-size: 1em;
letter-spacing: 0.1px;
color: lighter;
text-rendering: optimizeLegibility;
text-shadow: 1px 1px 1px rgba(0,0,0,0.004);
-webkit-font-smoothing: antialiased;
color: #fff;
}
#chatwin {
/* color: white; */
height: 100%;
min-width: 150px;
height: 80vh;
max-width: 500px;
min-width: 150px;
display: flex;
flex-direction: column;
padding: 10px;
position: relative;
}
.chatRow {
display: flex;
flex-direction: row;
margin-bottom: 1px;
margin-bottom: 5px;
width: 100%;
}
.nameline {
@@ -50,38 +38,7 @@ body {
padding: 5px;
width: 25%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
flex-direction: column;
vertical-align: auto;
}
.yt {
background-image: url('data:image/svg+xml,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><g fill="%239C92AC" fill-opacity="0.4" fill-rule="evenodd"><path d="M0 40L40 0H20L0 20M40 40V20L20 40"/></g></svg>');
background-color: #E53935A0;
}
.tg {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill-rule="evenodd"><g fill="%239C92AC" fill-opacity="0.4"><path opacity=".5" d="M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z"/><path d="M6 5V0H5v5H0v1h5v94h1V6h94V5H6z"/></g></g></svg>');
background-color: #2196F3A0;
}
.tw {
background-color: #6034b2A0 ;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='60' viewBox='0 0 20 12'><g fill-rule='evenodd'><g id='charlie-brown' fill='%236441a5' fill-opacity='0.35'><path d='M9.8 12L0 2.2V.8l10 10 10-10v1.4L10.2 12h-.4zm-4 0L0 6.2V4.8L7.2 12H5.8zm8.4 0L20 6.2V4.8L12.8 12h1.4zM9.8 0l.2.2.2-.2h-.4zm-4 0L10 4.2 14.2 0h-1.4L10 2.8 7.2 0H5.8z'/></g></g></svg>");
}
/* <svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><rect fill='#6441A5' width='120' height='120'/><polygon fill='#5C3C98' fill-opacity='1' points='120 120 60 120 90 90 120 60 120 0 120 0 60 60 0 0 0 60 30 90 60 120 120 120 '/></svg> */
.donate {
background-image: url('back-coin.jpg');
/* background-size: 500px; */
color: black !important;
}
.hello {
background-color: #00bb77;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='59' height='59' viewBox='0 0 120 120'><polygon fill='%23000' fill-opacity='0.11' points='120 0 120 60 90 30 60 0 0 0 0 0 60 60 0 120 60 120 90 90 120 60 120 0'/></svg>");
}
.msgline {
@@ -89,37 +46,35 @@ body {
width: 75%;
color: #fff;
}
/* Сохраняем оригинальные стили фона */
.yt {
background-image: url('data:image/svg+xml,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><g fill="%239C92AC" fill-opacity="0.4" fill-rule="evenodd"><path d="M0 40L40 0H20L0 20M40 40V20L20 40"/></g></svg>');
background-color: #E53935A0;
}
.tg {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill-rule="evenodd"><g fill="%239C92AC" fill-opacity="0.4"><path opacity=".5" d="M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z"/><path d="M6 5V0H5v5H0v1h5v94h1V6h94V5H6z"/></g></g></svg>');
background-color: #2196F3A0;
}
.tw {
background-color: #6034b2A0 ;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='60' viewBox='0 0 20 12'><g fill-rule='evenodd'><g id='charlie-brown' fill='%236441a5' fill-opacity='0.35'><path d='M9.8 12L0 2.2V.8l10 10 10-10v1.4L10.2 12h-.4zm-4 0L0 6.2V4.8L7.2 12H5.8zm8.4 0L20 6.2V4.8L12.8 12h1.4zM9.8 0l.2.2.2-.2h-.4zm-4 0L10 4.2 14.2 0h-1.4L10 2.8 7.2 0H5.8z'/></g></g></svg>");
}
.donate {
background-image: url('back-coin.jpg');
color: black !important;
}
.hello {
background-color: #00bb77;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='59' height='59' viewBox='0 0 120 120'><polygon fill='%23000' fill-opacity='0.11' points='120 0 120 60 90 30 60 0 0 0 0 0 60 60 0 120 60 120 90 90 120 60 120 0'/></svg>");
}
</style>
</head>
<body>
<div id="chatwin">
<!--
<div idd="1" class="chatRow">
<div class="nameline tg">Edvard Force</div>
<div class="msgline">вот Тенчу Великому зашла , он в ней быстро разобрался и втащил за один стрим )))) ждем когда до нее доберется ))))</div>
</div>
<div idd="2" class="chatRow">
<div class="nameline tg" >Диванный Воин</div>
<div class="msgline">dc или если ты действительно решишь дать бан то мышкой два клика не сделаешь?</div>
</div>
<div idd="3" class="chatRow">
<div class="nameline tg">Yoshka's Cat</div>
<div class="msgline">великий ну эта часть ванпис лутьше чем вариорсы надо признать</div>
</div>
<div idd="4" class="chatRow">
<div class="nameline yt">XAOSHammer</div>
<div class="msgline">Великий а куда друг твой пропал спец по японскому языку ?))))</div>
</div>
<div idd="5" class="chatRow">
<div class="nameline tg">Kino Konformist</div>
<div class="msgline">вот Тенчу Великому зашла , он в ней быстро разобрался и втащил за один стрим )))) ждем когда до нее доберется ))))</div>
</div>
-->
<div id="anchor"></div>
</div>
<div id="chatwin"></div>
<script src="script.js"></script>
</body>

View File

@@ -41,108 +41,91 @@ let messages = [
"Kino Konformist" ];
const chatwin = document.getElementById("chatwin");
const anchor = document.getElementById("anchor");
function randomMessage() {
return messages[(Math.random() * messages.length) | 0];
}
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 randomChat() {
return Math.random() > 0.5 ? "tg" : "yt";
}
function removeElementsByClass(className){
const elements = document.getElementsByClassName(className);
while(elements.length > 15){
elements[0].parentNode.removeChild(elements[0]);
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();
chatwin.appendChild(rw);
scrollToBottom();
removeOldMessages();
}
function createNewLine(json) {
json.forEach(element => {
//checking new IDs on screen and print
//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"]
const existing = document.getElementById(element.id);
if (existing) {
existing.querySelector('.msgline').textContent = 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 + '<br><p style="color: red">' + element['amount']+"</p>" }
nm.className = "nameline " + element.type;
nm.textContent = element.sendr;
if (element.type === "donate") {
nm.innerHTML += `<br><p style="color: red">${element.amount}</p>`;
}
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" }
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.setAttribute("name", element["id"]);
rw.appendChild(nm);
rw.appendChild(msg);
//console.log(rw);
chatwin.insertBefore(rw, anchor);
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);
// setInterval(createChatLine, 3000);

10
yttest.py Normal file
View File

@@ -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())