forked from rDrama/rDrama
chat improvements
parent
0f4de38141
commit
c1b1ccedff
|
@ -194,12 +194,13 @@ textbox.addEventListener("keyup", function(e) {
|
||||||
|
|
||||||
socket.on('online', function(data){
|
socket.on('online', function(data){
|
||||||
document.getElementsByClassName('board-chat-count')[0].innerHTML = data[0].length
|
document.getElementsByClassName('board-chat-count')[0].innerHTML = data[0].length
|
||||||
|
const admin_level = parseInt(document.getElementById('admin_level').value)
|
||||||
let online = ''
|
let online = ''
|
||||||
let online2 = '<b>Users Online</b>'
|
let online2 = '<b>Users Online</b>'
|
||||||
for (const u of data[0])
|
for (const u of data[0])
|
||||||
{
|
{
|
||||||
online += `<li>`
|
online += `<li>`
|
||||||
if (Object.keys(data[1]).includes(u.toLowerCase()))
|
if (admin_level && Object.keys(data[1]).includes(u.toLowerCase()))
|
||||||
online += '<b class="text-danger muted" data-bs-toggle="tooltip" title="Muted">X</b> '
|
online += '<b class="text-danger muted" data-bs-toggle="tooltip" title="Muted">X</b> '
|
||||||
online += `<a href="/@${u}">@${u}</a></li>`
|
online += `<a href="/@${u}">@${u}</a></li>`
|
||||||
online2 += `<br>@${u}`
|
online2 += `<br>@${u}`
|
||||||
|
|
|
@ -77,23 +77,26 @@ def speak(data, v):
|
||||||
self_only = True
|
self_only = True
|
||||||
else:
|
else:
|
||||||
del muted[vname]
|
del muted[vname]
|
||||||
|
emit("online", [online, muted], broadcast=True)
|
||||||
|
|
||||||
def shut_up():
|
if SITE == 'rdrama.net':
|
||||||
self_only = True
|
def shut_up():
|
||||||
muted_until = int(time.time() + 3600)
|
self_only = True
|
||||||
muted[vname] = muted_until
|
muted_until = int(time.time() + 3600)
|
||||||
|
muted[vname] = muted_until
|
||||||
|
emit("online", [online, muted], broadcast=True)
|
||||||
|
|
||||||
if not self_only:
|
if not self_only:
|
||||||
identical = [x for x in list(messages[request.referrer].values())[-10:] if v.id == x['user_id'] and text == x['text']]
|
identical = [x for x in list(messages[request.referrer].values())[-5:] if v.id == x['user_id'] and text == x['text']]
|
||||||
if len(identical) >= 3: shut_up()
|
if len(identical) >= 3: shut_up()
|
||||||
|
|
||||||
if not self_only:
|
if not self_only:
|
||||||
count = len([x for x in list(messages[request.referrer].values())[-10:] if v.id == x['user_id']])
|
count = len([x for x in list(messages[request.referrer].values())[-12:] if v.id == x['user_id']])
|
||||||
if count >= 5: shut_up()
|
if count >= 10: shut_up()
|
||||||
|
|
||||||
if not self_only:
|
if not self_only:
|
||||||
count = len([x for x in list(messages[request.referrer].values())[-50:] if v.id == x['user_id']])
|
count = len([x for x in list(messages[request.referrer].values())[-25:] if v.id == x['user_id']])
|
||||||
if count >= 20: shut_up()
|
if count >= 20: shut_up()
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"id": id,
|
"id": id,
|
||||||
|
@ -115,6 +118,7 @@ def speak(data, v):
|
||||||
username = i.group(1).lower()
|
username = i.group(1).lower()
|
||||||
muted_until = int(int(i.group(2)) * 60 + time.time())
|
muted_until = int(int(i.group(2)) * 60 + time.time())
|
||||||
muted[username] = muted_until
|
muted[username] = muted_until
|
||||||
|
emit("online", [online, muted], broadcast=True)
|
||||||
self_only = True
|
self_only = True
|
||||||
|
|
||||||
if self_only or v.shadowbanned or not execute_blackjack(v, None, text, "chat"):
|
if self_only or v.shadowbanned or not execute_blackjack(v, None, text, "chat"):
|
||||||
|
@ -140,24 +144,22 @@ def speak(data, v):
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
def refresh_online(v):
|
def refresh_online():
|
||||||
if v.admin_level >= PERMS['USER_BAN']:
|
emit("online", [online, muted], broadcast=True)
|
||||||
emit("online", [online, muted], broadcast=True)
|
|
||||||
else:
|
|
||||||
emit("online", [online, []], broadcast=True)
|
|
||||||
if request.referrer == f'{SITE_FULL}/chat':
|
if request.referrer == f'{SITE_FULL}/chat':
|
||||||
cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
|
cache.set(CHAT_ONLINE_CACHE_KEY, len(online), timeout=0)
|
||||||
|
|
||||||
@socketio.on('connect')
|
@socketio.on('connect')
|
||||||
@admin_level_required(PERMS['CHAT'])
|
@admin_level_required(PERMS['CHAT'])
|
||||||
def connect(v):
|
def connect(v):
|
||||||
join_room(request.referrer)
|
if request.referrer:
|
||||||
|
join_room(request.referrer)
|
||||||
|
|
||||||
if v.username not in online:
|
if v.username not in online:
|
||||||
online.append(v.username)
|
online.append(v.username)
|
||||||
refresh_online(v)
|
refresh_online()
|
||||||
|
|
||||||
emit('typing', typing[request.referrer], room=request.referrer)
|
emit('typing', typing[request.referrer], room=request.referrer)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
@socketio.on('disconnect')
|
@socketio.on('disconnect')
|
||||||
|
@ -165,13 +167,15 @@ def connect(v):
|
||||||
def disconnect(v):
|
def disconnect(v):
|
||||||
if v.username in online:
|
if v.username in online:
|
||||||
online.remove(v.username)
|
online.remove(v.username)
|
||||||
refresh_online(v)
|
refresh_online()
|
||||||
|
|
||||||
for val in typing.values():
|
for val in typing.values():
|
||||||
if v.username in val:
|
if v.username in val:
|
||||||
val.remove(v.username)
|
val.remove(v.username)
|
||||||
|
|
||||||
leave_room(request.referrer)
|
if request.referrer:
|
||||||
|
leave_room(request.referrer)
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
@socketio.on('typing')
|
@socketio.on('typing')
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
<input id="vid" hidden value="{{v.id}}">
|
<input id="vid" hidden value="{{v.id}}">
|
||||||
<input id="site_name" hidden value="{{SITE_NAME}}">
|
<input id="site_name" hidden value="{{SITE_NAME}}">
|
||||||
<input id="slurreplacer" hidden value="{{v.slurreplacer}}">
|
<input id="slurreplacer" hidden value="{{v.slurreplacer}}">
|
||||||
<input id="slurreplacer" hidden value="{{v.slurreplacer}}">
|
<input id="admin_level" hidden value="{{v.admin_level}}">
|
||||||
<script defer src="{{'js/vendor/socketio.js' | asset}}"></script>
|
<script defer src="{{'js/vendor/socketio.js' | asset}}"></script>
|
||||||
<script defer src="{{'js/chat.js' | asset}}"></script>
|
<script defer src="{{'js/chat.js' | asset}}"></script>
|
||||||
<script defer src="{{'js/vendor/lozad.js' | asset}}"></script>
|
<script defer src="{{'js/vendor/lozad.js' | asset}}"></script>
|
||||||
|
|
Loading…
Reference in New Issue