forked from rDrama/rDrama
fds
parent
bd8c090dab
commit
63f525c5d6
|
@ -5,26 +5,28 @@ from datetime import datetime
|
||||||
from flask_socketio import SocketIO, emit
|
from flask_socketio import SocketIO, emit
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
|
import sys
|
||||||
|
|
||||||
sex = SocketIO(app, async_mode='gevent-websocket')
|
if "load_chat" in sys.argv:
|
||||||
|
sex = SocketIO(app, async_mode='gevent-websocket')
|
||||||
|
|
||||||
@app.get("/chat")
|
@app.get("/chat")
|
||||||
@auth_required
|
@auth_required
|
||||||
def chat( v):
|
def chat( v):
|
||||||
return render_template("chat.html", v=v)
|
return render_template("chat.html", v=v)
|
||||||
|
|
||||||
|
|
||||||
@sex.on('speak')
|
@sex.on('speak')
|
||||||
@auth_required
|
@auth_required
|
||||||
def speak(data, v):
|
def speak(data, v):
|
||||||
|
|
||||||
data={
|
data={
|
||||||
"avatar": v.profile_url,
|
"avatar": v.profile_url,
|
||||||
"username":v.username,
|
"username":v.username,
|
||||||
"text":sanitize(data[:1000].strip()),
|
"text":sanitize(data[:1000].strip()),
|
||||||
"time": time.strftime("%d %b %Y at %H:%M:%S", time.gmtime(int(time.time()))),
|
"time": time.strftime("%d %b %Y at %H:%M:%S", time.gmtime(int(time.time()))),
|
||||||
"userlink":v.url
|
"userlink":v.url
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('speak', data)
|
emit('speak', data)
|
||||||
return '', 204
|
return '', 204
|
Loading…
Reference in New Issue