fixes
This commit is contained in:
@@ -2,12 +2,6 @@
|
|||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": "."
|
"path": "."
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "csharp/Chapter01/HelloCS"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "repos"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {}
|
"settings": {}
|
||||||
|
|||||||
BIN
__pycache__/twitch.cpython-314.pyc
Normal file
BIN
__pycache__/twitch.cpython-314.pyc
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@ bot_secret = 6454033742:AAFj2rUoVb2jJ_Lew4eiIecdr7s7xbrqeNU
|
|||||||
enabled = 1
|
enabled = 1
|
||||||
|
|
||||||
[Youtube]
|
[Youtube]
|
||||||
video_id = coYw-eVU0Ks
|
video_id = SsC29jqiNto
|
||||||
|
|
||||||
[Twitch]
|
[Twitch]
|
||||||
channel = wanderbraun
|
channel = wanderbraun
|
||||||
|
|||||||
9
huy.py
9
huy.py
@@ -21,7 +21,7 @@ from zoneinfo import *
|
|||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
import pytchat
|
import pytchat
|
||||||
import telegram
|
import telegram
|
||||||
from donationalerts import DonationAlertsAPI, Scope
|
from donationalerts import DonationAlertsAPI, Scopes
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
sys.path.append('twitchchatirc')
|
sys.path.append('twitchchatirc')
|
||||||
import twitch
|
import twitch
|
||||||
@@ -37,8 +37,7 @@ alerts = DonationAlertsAPI(
|
|||||||
config['Alerts']['api_key'],
|
config['Alerts']['api_key'],
|
||||||
"http://127.0.0.1:8008/login",
|
"http://127.0.0.1:8008/login",
|
||||||
[
|
[
|
||||||
Scope.OAUTH_USER_SHOW,
|
Scopes.USER_SHOW,
|
||||||
Scope.OAUTH_DONATION_INDEX
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ class DateTimeEncoder(json.JSONEncoder):
|
|||||||
return json.JSONEncoder.default(self, o)
|
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()
|
# twitchConn = twitch_chat_irc.TwitchChatIRC()
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +175,7 @@ def makeJSONObject(): #we are parsing TG and YT
|
|||||||
tw_comments = twitch_socket.all_messages
|
tw_comments = twitch_socket.all_messages
|
||||||
|
|
||||||
|
|
||||||
get_yt() #Get YouTube
|
# get_yt() #Get YouTube
|
||||||
|
|
||||||
try:
|
try:
|
||||||
get_alerts() #Get Donations
|
get_alerts() #Get Donations
|
||||||
|
|||||||
10
huySeek.py
10
huySeek.py
@@ -12,7 +12,7 @@ from zoneinfo import ZoneInfo
|
|||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
import pytchat
|
import pytchat
|
||||||
import telegram
|
import telegram
|
||||||
from donationalerts import DonationAlertsAPI, Scope
|
from donationalerts import DonationAlertsAPI, Scopes
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
import emoji
|
import emoji
|
||||||
sys.path.append('twitchchatirc')
|
sys.path.append('twitchchatirc')
|
||||||
@@ -73,7 +73,7 @@ class DonationAlertsService:
|
|||||||
config.alerts_app_id,
|
config.alerts_app_id,
|
||||||
config.alerts_api_key,
|
config.alerts_api_key,
|
||||||
"http://127.0.0.1:8008/login",
|
"http://127.0.0.1:8008/login",
|
||||||
[Scope.OAUTH_USER_SHOW, Scope.OAUTH_DONATION_INDEX]
|
[Scopes.USER_SHOW]
|
||||||
)
|
)
|
||||||
self.access_token = None
|
self.access_token = None
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ class ChatAggregator:
|
|||||||
self.services = {
|
self.services = {
|
||||||
'alerts': DonationAlertsService(self.config),
|
'alerts': DonationAlertsService(self.config),
|
||||||
'telegram': TelegramService(self.config),
|
'telegram': TelegramService(self.config),
|
||||||
'youtube': YouTubeService(self.config),
|
# 'youtube': YouTubeService(self.config),
|
||||||
'twitch': TwitchService(self.config)
|
'twitch': TwitchService(self.config)
|
||||||
}
|
}
|
||||||
self.comments = []
|
self.comments = []
|
||||||
@@ -265,7 +265,7 @@ class ChatAggregator:
|
|||||||
new_comments.extend(self.services['alerts'].get_donations())
|
new_comments.extend(self.services['alerts'].get_donations())
|
||||||
|
|
||||||
# YouTube
|
# YouTube
|
||||||
new_comments.extend(self.services['youtube'].get_messages())
|
# new_comments.extend(self.services['youtube'].get_messages())
|
||||||
|
|
||||||
# Telegram
|
# Telegram
|
||||||
if self.config.telegram_enabled:
|
if self.config.telegram_enabled:
|
||||||
@@ -352,7 +352,7 @@ class ChatAggregator:
|
|||||||
def log_message(self, format, *args):
|
def log_message(self, format, *args):
|
||||||
return
|
return
|
||||||
|
|
||||||
server_address = ('', 8008)
|
server_address = ('127.0.0.1', 8008)
|
||||||
httpd = HTTPServer(server_address, lambda *args: Handler(*args, aggregator=self))
|
httpd = HTTPServer(server_address, lambda *args: Handler(*args, aggregator=self))
|
||||||
print(f'Starting HTTP server on port 8008...')
|
print(f'Starting HTTP server on port 8008...')
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|||||||
169
index.html
169
index.html
@@ -1,125 +1,80 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>template</title>
|
<title>SSH UltraChat</title>
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
|
||||||
<style>
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #494949;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
font-family: "Roboto Condensed", sans-serif;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
#chatwin {
|
||||||
|
height: 80vh;
|
||||||
|
max-width: 500px;
|
||||||
|
min-width: 150px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 10px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chatRow {
|
||||||
background-color: #494949;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
display: flex;
|
.nameline {
|
||||||
align-items: center;
|
color: white;
|
||||||
justify-content: center;
|
padding: 5px;
|
||||||
align-content: flex-end;
|
width: 25%;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#chatwin {
|
.msgline {
|
||||||
/* color: white; */
|
padding: 5px;
|
||||||
height: 100%;
|
width: 75%;
|
||||||
min-width: 150px;
|
color: #fff;
|
||||||
max-width: 500px;
|
}
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Сохраняем оригинальные стили фона */
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
.chatRow {
|
.tg {
|
||||||
display: flex;
|
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>');
|
||||||
flex-direction: row;
|
background-color: #2196F3A0;
|
||||||
margin-bottom: 1px;
|
}
|
||||||
|
|
||||||
}
|
.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>");
|
||||||
|
}
|
||||||
|
|
||||||
.nameline {
|
.donate {
|
||||||
color: white;
|
background-image: url('back-coin.jpg');
|
||||||
padding: 5px;
|
color: black !important;
|
||||||
width: 25%;
|
}
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
font-weight: bold;
|
|
||||||
flex-direction: column;
|
|
||||||
vertical-align: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.yt {
|
.hello {
|
||||||
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: #00bb77;
|
||||||
background-color: #E53935A0;
|
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>
|
||||||
.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 {
|
|
||||||
padding: 5px;
|
|
||||||
width: 75%;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="chatwin"></div>
|
||||||
<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>
|
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
151
script.js
151
script.js
@@ -40,109 +40,92 @@ let messages = [
|
|||||||
"XAOSHammer",
|
"XAOSHammer",
|
||||||
"Kino Konformist" ];
|
"Kino Konformist" ];
|
||||||
|
|
||||||
const chatwin = document.getElementById("chatwin");
|
const chatwin = document.getElementById("chatwin");
|
||||||
const anchor = document.getElementById("anchor");
|
|
||||||
|
function randomMessage() {
|
||||||
function randomMessage() {
|
|
||||||
return messages[(Math.random() * messages.length) | 0];
|
return messages[(Math.random() * messages.length) | 0];
|
||||||
}
|
}
|
||||||
function randomNick() {
|
|
||||||
|
function randomNick() {
|
||||||
return nicks[(Math.random() * nicks.length) | 0];
|
return nicks[(Math.random() * nicks.length) | 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomChat() { if (Math.random() * 2 > 1) {return "tg"} else { return "yt" } }
|
function randomChat() {
|
||||||
|
return Math.random() > 0.5 ? "tg" : "yt";
|
||||||
function goDown() {
|
}
|
||||||
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
|
|
||||||
}
|
function scrollToBottom() {
|
||||||
|
chatwin.scrollTop = chatwin.scrollHeight;
|
||||||
function removeElementsByClass(className){
|
}
|
||||||
const elements = document.getElementsByClassName(className);
|
|
||||||
while(elements.length > 15){
|
function removeOldMessages() {
|
||||||
elements[0].parentNode.removeChild(elements[0]);
|
const children = Array.from(chatwin.children);
|
||||||
}
|
while (children.length > 15) {
|
||||||
}
|
chatwin.removeChild(children[0]);
|
||||||
|
}
|
||||||
function createChatLine() {
|
}
|
||||||
|
|
||||||
|
function createChatLine() {
|
||||||
const nm = document.createElement("div");
|
const nm = document.createElement("div");
|
||||||
nm.className = "nameline " + randomChat();
|
nm.className = "nameline " + randomChat();
|
||||||
nm.innerHTML = randomNick();
|
nm.textContent = randomNick();
|
||||||
|
|
||||||
const msg = document.createElement("div");
|
const msg = document.createElement("div");
|
||||||
msg.className = "msgline";
|
msg.className = "msgline";
|
||||||
msg.innerHTML = randomMessage();
|
msg.textContent = randomMessage();
|
||||||
|
|
||||||
const rw = document.createElement("div");
|
const rw = document.createElement("div");
|
||||||
rw.className = "chatRow";
|
rw.className = "chatRow";
|
||||||
rw.appendChild(nm);
|
rw.appendChild(nm);
|
||||||
rw.appendChild(msg);
|
rw.appendChild(msg);
|
||||||
console.log(rw);
|
|
||||||
|
|
||||||
chatwin.insertBefore(rw, anchor);
|
|
||||||
|
|
||||||
|
|
||||||
goDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function createNewLine(json) {
|
chatwin.appendChild(rw);
|
||||||
|
scrollToBottom();
|
||||||
json.forEach(element => {
|
removeOldMessages();
|
||||||
|
}
|
||||||
//checking new IDs on screen and print
|
|
||||||
|
|
||||||
//const elements = document.getElementsByName(element["id"]);
|
function createNewLine(json) {
|
||||||
//if (elements.length > 0) { //if this id is present on screen
|
json.forEach(element => {
|
||||||
|
const existing = document.getElementById(element.id);
|
||||||
let curline = document.getElementById(element["id"])
|
if (existing) {
|
||||||
if (curline) {
|
existing.querySelector('.msgline').textContent = element.msg;
|
||||||
curline.innerHTML = element["msg"]
|
return;
|
||||||
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>" }
|
|
||||||
|
|
||||||
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" }
|
|
||||||
|
|
||||||
|
const nm = document.createElement("div");
|
||||||
const rw = document.createElement("div");
|
nm.className = "nameline " + element.type;
|
||||||
rw.className = "chatRow";
|
nm.textContent = element.sendr;
|
||||||
rw.setAttribute("name", element["id"]);
|
|
||||||
|
|
||||||
rw.appendChild(nm);
|
|
||||||
rw.appendChild(msg);
|
|
||||||
//console.log(rw);
|
|
||||||
|
|
||||||
chatwin.insertBefore(rw, anchor);
|
|
||||||
|
|
||||||
|
if (element.type === "donate") {
|
||||||
|
nm.innerHTML += `<br><p style="color: red">${element.amount}</p>`;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
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() {
|
function requestNewLines() {
|
||||||
|
fetch("http://localhost:8008/")
|
||||||
var request = new XMLHttpRequest();
|
.then(response => response.json())
|
||||||
request.open('GET', "http://localhost:8008/");
|
.then(data => createNewLine(data))
|
||||||
request.responseType = 'json';
|
.catch(error => console.error('Ошибка:', error));
|
||||||
request.send();
|
|
||||||
|
|
||||||
request.onload = function() {
|
|
||||||
var chatJSON = request.response;
|
|
||||||
createNewLine(chatJSON);
|
|
||||||
goDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(requestNewLines,1000);
|
setInterval(requestNewLines, 1000);
|
||||||
|
// setInterval(createChatLine, 3000);
|
||||||
Reference in New Issue
Block a user