2023-10-04 21:55:43 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import logging
|
2023-10-07 15:29:50 +08:00
|
|
|
from abc import abstractmethod
|
2023-10-04 21:55:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Event(object):
|
|
|
|
_message_callback_func = {}
|
|
|
|
_message_callback_func_list = []
|
|
|
|
_loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(Event, self).__init__()
|
|
|
|
self._message = None
|
|
|
|
self._logger: logging = logging.getLogger()
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def _add_callback(self, func, *args, **kwargs):
|
|
|
|
"""
|
|
|
|
消息处理函数加载器
|
|
|
|
:param func: 消息处理函数
|
|
|
|
:param args: 消息处理函数参数
|
|
|
|
:param kwargs: 消息处理函数参数
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def _run_func(self):
|
|
|
|
"""
|
|
|
|
消息分发器, 将消息发送给所有消息处理函数
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|