diff --git a/files/__main__.py b/files/__main__.py index 891f364ce..61e6249dc 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -1,5 +1,4 @@ -import gevent.monkey -gevent.monkey.patch_all() + from os import environ, path import secrets from flask import * diff --git a/files/routes/__init__.py b/files/routes/__init__.py index e9121b46a..bcca8b043 100644 --- a/files/routes/__init__.py +++ b/files/routes/__init__.py @@ -15,4 +15,5 @@ from .votes import * from .feeds import * from .awards import * from .giphy import * -from .subs import * \ No newline at end of file +from .subs import * +from .chat import * \ No newline at end of file diff --git a/files/routes/chat.py b/files/routes/chat.py new file mode 100644 index 000000000..5011434de --- /dev/null +++ b/files/routes/chat.py @@ -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 \ No newline at end of file diff --git a/files/templates/chat.html b/files/templates/chat.html new file mode 100644 index 000000000..5b3689646 --- /dev/null +++ b/files/templates/chat.html @@ -0,0 +1,76 @@ +{% extends "default.html" %} + +{% block title %} + Chat + +{% endblock %} + +{% block content %} + +
+
+
+ + + +
+
+ + @ +
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+

+
+
+
+
+
+ + +
+ + +
+
+ + + + + + +{% endblock %} \ No newline at end of file