添加更多QQ监听

This commit is contained in:
San Liy 2023-12-18 23:21:41 +08:00
parent 2f168f1287
commit 6cc45eff8c

View File

@ -1,5 +1,5 @@
import tomllib import tomllib
from typing import Dict from typing import Dict, Any
from nacl.signing import SigningKey from nacl.signing import SigningKey
from sanic import Sanic, Request from sanic import Sanic, Request
@ -85,6 +85,27 @@ def start_sio_listener():
await app.ctx.sio.emit('auth', signature.signature) await app.ctx.sio.emit('auth', signature.signature)
logger.info(f"{Colors.BLUE}send auth emit{Colors.END}") logger.info(f"{Colors.BLUE}send auth emit{Colors.END}")
@app.ctx.sio.on('auth')
async def auth(data: Dict[str, Any]):
logger.info(f"auth: {data}")
@app.ctx.sio.on('authFailed')
async def auth_failed():
logger.warn(f"authFailed")
await app.ctx.sio.disconnect()
@app.ctx.sio.on('authSucceed')
def auth_succeed():
logger.info(f"authSucceed")
@app.ctx.sio.on('connect_error')
def connect_error(*args, **kwargs):
logger.warn(f"连接错误 {args}, {kwargs}")
@app.ctx.sio.on('updateRoom')
def update_room(data: Dict[str, Any]):
logger.info(f"update_room: {data}")
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='0.0.0.0', port=80, dev=True) app.run(host='0.0.0.0', port=80, dev=True)