From beaef5f7efc52890d3119126debbc9e954eb1143 Mon Sep 17 00:00:00 2001 From: adk23333 <2633103794@qq.com> Date: Tue, 19 Dec 2023 00:10:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9AQQ=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 264b4c7..04f8f3f 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,5 @@ import tomllib -from typing import Dict, Any +from typing import Dict, Any, List, Tuple from nacl.signing import SigningKey from sanic import Sanic, Request @@ -9,6 +9,7 @@ from socketio import AsyncClient from gitea_model import WebHookIssueComment, WebHookIssue, GiteaEvent from model import Ctx, SioConfig, Message +from unit import sio_log_format app = Sanic('GiteaPush', ctx=Ctx) @@ -112,6 +113,41 @@ def start_sio_listener(): def update_room(data: Dict[str, Any]): logger.info(f"update_room: {data}") + @app.ctx.sio.on('deleteMessage') + def delete_message(message_id: str): + logger.debug(sio_log_format('delete_message:', message_id)) + + @app.ctx.sio.on('setMessages') + def set_messages(data: Dict[str, Any]): + logger.debug(f"{sio_log_format('set_messages:', data)}" + f"{sio_log_format('message_len:', len(data['messages']))}") + + @app.ctx.sio.on('setAllRooms') + def set_all_rooms(rooms: List[Dict[str, Any]]): + logger.debug(f"{sio_log_format('set_all_rooms:', rooms)}" + f"{sio_log_format('len:', len(rooms))}") + + @app.ctx.sio.on('setAllChatGroups') + def set_all_chat_groups(groups: List[Dict[str, Any]]): + logger.debug(f"{sio_log_format('set_all_chat_groups:', groups)}" + f"{sio_log_format('len:', len(groups))}") + + @app.ctx.sio.on('notify') + def notify(data: List[Tuple[str, Any]]): + logger.debug(sio_log_format('notify:', data)) + + @app.ctx.sio.on('closeLoading') + def close_loading(_): + logger.debug(sio_log_format('close_loading', '')) + + @app.ctx.sio.on('onlineData') + def online_data(data: Dict[str, Any]): + logger.debug(sio_log_format('online_data:', data)) + + @app.ctx.sio.on('*') + def catch_all(event, data): + logger.debug(sio_log_format('catch_all:', f'{event}|{data}')) + if __name__ == "__main__": app.run(host='0.0.0.0', port=80, dev=True)