fgMerge branch 'frost' of https://github.com/Aevann1/Drama into frost

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-20 00:17:25 +00:00
commit b27fa75440
4 changed files with 112 additions and 3 deletions

View File

@ -1,5 +1,4 @@
import gevent.monkey
gevent.monkey.patch_all()
from os import environ, path
import secrets
from flask import *

View File

@ -15,4 +15,5 @@ from .votes import *
from .feeds import *
from .awards import *
from .giphy import *
from .subs import *
from .subs import *
from .chat import *

View File

@ -0,0 +1,33 @@
import time
from files.helpers.wrappers import auth_required
from files.helpers.sanitize import sanitize
from files.helpers.const import *
from datetime import datetime
from flask_socketio import SocketIO, emit
from files.__main__ import app
from flask import render_template
import sys
if SITE=='devrama.xyz':
@app.get("/chat")
@auth_required
def chat( v):
return render_template("chat.html", v=v)
sex = SocketIO(app, logger=True, engineio_logger=True, debug=True, async_mode='gevent')
@sex.on('speak')
@auth_required
def speak(data, v):
data={
"avatar": v.profile_url,
"username":v.username,
"text":sanitize(data[:1000].strip()),
"time": time.strftime("%d %b %Y at %H:%M:%S", time.gmtime(int(time.time()))),
"userlink":v.url
}
emit('speak', data, broadcast=True)
return '', 204

View File

@ -0,0 +1,76 @@
{% extends "default.html" %}
{% block title %}
<title>Chat</title>
<meta name="description" content="Chat">
{% endblock %}
{% block content %}
<div id="chat-line-template" class="d-none">
<div class="chat-line my-2">
<div class="d-flex align-items-center">
<span class="rounded mb-auto d-none d-md-block chat-profile">
<img class="desktop-avatar rounded-circle w-100">
</span>
<div class="pl-md-3 text-muted">
<div>
<img class="mobile-avatar profile-pic-30 mr-2 d-inline-block d-md-none" data-toggle="tooltip" data-placement="right">
<a href="" class="font-weight-bold text-black userlink" target="_blank">@<span class="username"></span></a>
<div style="overflow:hidden">
<span class="chat-message text-black text-break"></span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container p-md-0 chat-container">
<div id="chat-window">
<div id="chat-text" class="fullchat">
</div>
<div id="system-template">
<div class="system-line">
<p class="message text-muted"></p>
</div>
</div>
</div>
<div class="position-relative form-group d-flex pb-3">
<div class="position-absolute text-muted text-small" style="bottom: -1.5rem; line-height: 1;">
<span id="typing-indicator"></span>
<span id="loading-indicator" class="d-none"></span>
</div>
<input id="input-text" type="text" class="form-control" placeholder="Message" autocomplete="off" autofocus />
<button id="chatsend" class="btn btn-primary ml-3" type="submit">Send</button>
</div>
</div>
<script src="/assets/js/socketio.js"></script>
<script src="/assets/js/chat.js?v=11"></script>
<style>
#chat-window {
max-height:calc(100vh - 300px);
overflow-y: scroll;
}
.fullchat .chat-profile {
min-width: 42px;
width: 42px;
height: 42px;
}
#chat-window::-webkit-scrollbar {
display: none;
}
#chat-window {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>
{% endblock %}