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