ErisPulse 2.1.14.dev2__py3-none-any.whl → 2.2.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ErisPulse/Core/Event/__init__.py +49 -0
- ErisPulse/Core/Event/base.py +118 -0
- ErisPulse/Core/Event/cmd.py +212 -0
- ErisPulse/Core/Event/exceptions.py +37 -0
- ErisPulse/Core/Event/manager.py +128 -0
- ErisPulse/Core/Event/message.py +91 -0
- ErisPulse/Core/Event/meta.py +82 -0
- ErisPulse/Core/Event/notice.py +97 -0
- ErisPulse/Core/Event/request.py +67 -0
- ErisPulse/Core/__init__.py +6 -0
- ErisPulse/Core/adapter.py +7 -1
- ErisPulse/Core/config.py +4 -0
- ErisPulse/Core/env.py +8 -535
- ErisPulse/Core/logger.py +78 -1
- ErisPulse/Core/mods.py +22 -18
- ErisPulse/Core/router.py +6 -1
- ErisPulse/Core/storage.py +547 -0
- ErisPulse/__init__.py +29 -18
- ErisPulse/__main__.py +991 -71
- {erispulse-2.1.14.dev2.dist-info → erispulse-2.2.0.dev0.dist-info}/METADATA +40 -19
- erispulse-2.2.0.dev0.dist-info/RECORD +26 -0
- {erispulse-2.1.14.dev2.dist-info → erispulse-2.2.0.dev0.dist-info}/licenses/LICENSE +7 -1
- erispulse-2.1.14.dev2.dist-info/RECORD +0 -16
- {erispulse-2.1.14.dev2.dist-info → erispulse-2.2.0.dev0.dist-info}/WHEEL +0 -0
- {erispulse-2.1.14.dev2.dist-info → erispulse-2.2.0.dev0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ErisPulse 元事件处理模块
|
|
3
|
+
|
|
4
|
+
提供基于装饰器的元事件处理功能
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .base import BaseEventHandler
|
|
8
|
+
from .manager import event_manager
|
|
9
|
+
from typing import Callable, Dict, Any
|
|
10
|
+
|
|
11
|
+
class MetaHandler:
|
|
12
|
+
"""
|
|
13
|
+
元事件处理器
|
|
14
|
+
|
|
15
|
+
提供元事件(如连接、断开连接、心跳等)的处理功能
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
"""
|
|
20
|
+
初始化元事件处理器
|
|
21
|
+
"""
|
|
22
|
+
self.handler = event_manager.create_event_handler("meta", "meta")
|
|
23
|
+
|
|
24
|
+
def on_meta(self, priority: int = 0):
|
|
25
|
+
"""
|
|
26
|
+
通用元事件装饰器
|
|
27
|
+
|
|
28
|
+
:param priority: 处理器优先级
|
|
29
|
+
:return: 装饰器函数
|
|
30
|
+
"""
|
|
31
|
+
def decorator(func: Callable):
|
|
32
|
+
self.handler.register(func, priority)
|
|
33
|
+
return func
|
|
34
|
+
return decorator
|
|
35
|
+
|
|
36
|
+
def on_connect(self, priority: int = 0):
|
|
37
|
+
"""
|
|
38
|
+
连接事件装饰器
|
|
39
|
+
|
|
40
|
+
:param priority: 处理器优先级
|
|
41
|
+
:return: 装饰器函数
|
|
42
|
+
"""
|
|
43
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
44
|
+
return event.get("detail_type") == "connect"
|
|
45
|
+
|
|
46
|
+
def decorator(func: Callable):
|
|
47
|
+
self.handler.register(func, priority, condition)
|
|
48
|
+
return func
|
|
49
|
+
return decorator
|
|
50
|
+
|
|
51
|
+
def on_disconnect(self, priority: int = 0):
|
|
52
|
+
"""
|
|
53
|
+
断开连接事件装饰器
|
|
54
|
+
|
|
55
|
+
:param priority: 处理器优先级
|
|
56
|
+
:return: 装饰器函数
|
|
57
|
+
"""
|
|
58
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
59
|
+
return event.get("detail_type") == "disconnect"
|
|
60
|
+
|
|
61
|
+
def decorator(func: Callable):
|
|
62
|
+
self.handler.register(func, priority, condition)
|
|
63
|
+
return func
|
|
64
|
+
return decorator
|
|
65
|
+
|
|
66
|
+
def on_heartbeat(self, priority: int = 0):
|
|
67
|
+
"""
|
|
68
|
+
心跳事件装饰器
|
|
69
|
+
|
|
70
|
+
:param priority: 处理器优先级
|
|
71
|
+
:return: 装饰器函数
|
|
72
|
+
"""
|
|
73
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
74
|
+
return event.get("detail_type") == "heartbeat"
|
|
75
|
+
|
|
76
|
+
def decorator(func: Callable):
|
|
77
|
+
self.handler.register(func, priority, condition)
|
|
78
|
+
return func
|
|
79
|
+
return decorator
|
|
80
|
+
|
|
81
|
+
# 创建全局元事件处理器实例
|
|
82
|
+
meta = MetaHandler()
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ErisPulse 通知处理模块
|
|
3
|
+
|
|
4
|
+
提供基于装饰器的通知事件处理功能
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .base import BaseEventHandler
|
|
8
|
+
from .manager import event_manager
|
|
9
|
+
from typing import Callable, Dict, Any
|
|
10
|
+
|
|
11
|
+
class NoticeHandler:
|
|
12
|
+
"""
|
|
13
|
+
通知处理器
|
|
14
|
+
|
|
15
|
+
提供不同类型通知事件的处理功能
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
"""
|
|
20
|
+
初始化通知处理器
|
|
21
|
+
"""
|
|
22
|
+
self.handler = event_manager.create_event_handler("notice", "notice")
|
|
23
|
+
|
|
24
|
+
def on_notice(self, priority: int = 0):
|
|
25
|
+
"""
|
|
26
|
+
通用通知事件装饰器
|
|
27
|
+
|
|
28
|
+
:param priority: 处理器优先级
|
|
29
|
+
:return: 装饰器函数
|
|
30
|
+
"""
|
|
31
|
+
def decorator(func: Callable):
|
|
32
|
+
self.handler.register(func, priority)
|
|
33
|
+
return func
|
|
34
|
+
return decorator
|
|
35
|
+
|
|
36
|
+
def on_friend_add(self, priority: int = 0):
|
|
37
|
+
"""
|
|
38
|
+
好友添加通知事件装饰器
|
|
39
|
+
|
|
40
|
+
:param priority: 处理器优先级
|
|
41
|
+
:return: 装饰器函数
|
|
42
|
+
"""
|
|
43
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
44
|
+
return event.get("detail_type") == "friend_increase"
|
|
45
|
+
|
|
46
|
+
def decorator(func: Callable):
|
|
47
|
+
self.handler.register(func, priority, condition)
|
|
48
|
+
return func
|
|
49
|
+
return decorator
|
|
50
|
+
|
|
51
|
+
def on_friend_remove(self, priority: int = 0):
|
|
52
|
+
"""
|
|
53
|
+
好友删除通知事件装饰器
|
|
54
|
+
|
|
55
|
+
:param priority: 处理器优先级
|
|
56
|
+
:return: 装饰器函数
|
|
57
|
+
"""
|
|
58
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
59
|
+
return event.get("detail_type") == "friend_decrease"
|
|
60
|
+
|
|
61
|
+
def decorator(func: Callable):
|
|
62
|
+
self.handler.register(func, priority, condition)
|
|
63
|
+
return func
|
|
64
|
+
return decorator
|
|
65
|
+
|
|
66
|
+
def on_group_increase(self, priority: int = 0):
|
|
67
|
+
"""
|
|
68
|
+
群成员增加通知事件装饰器
|
|
69
|
+
|
|
70
|
+
:param priority: 处理器优先级
|
|
71
|
+
:return: 装饰器函数
|
|
72
|
+
"""
|
|
73
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
74
|
+
return event.get("detail_type") == "group_member_increase"
|
|
75
|
+
|
|
76
|
+
def decorator(func: Callable):
|
|
77
|
+
self.handler.register(func, priority, condition)
|
|
78
|
+
return func
|
|
79
|
+
return decorator
|
|
80
|
+
|
|
81
|
+
def on_group_decrease(self, priority: int = 0):
|
|
82
|
+
"""
|
|
83
|
+
群成员减少通知事件装饰器
|
|
84
|
+
|
|
85
|
+
:param priority: 处理器优先级
|
|
86
|
+
:return: 装饰器函数
|
|
87
|
+
"""
|
|
88
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
89
|
+
return event.get("detail_type") == "group_member_decrease"
|
|
90
|
+
|
|
91
|
+
def decorator(func: Callable):
|
|
92
|
+
self.handler.register(func, priority, condition)
|
|
93
|
+
return func
|
|
94
|
+
return decorator
|
|
95
|
+
|
|
96
|
+
# 创建全局通知处理器实例
|
|
97
|
+
notice = NoticeHandler()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ErisPulse 请求处理模块
|
|
3
|
+
|
|
4
|
+
提供基于装饰器的请求事件处理功能
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .base import BaseEventHandler
|
|
8
|
+
from .manager import event_manager
|
|
9
|
+
from typing import Callable, Dict, Any
|
|
10
|
+
|
|
11
|
+
class RequestHandler:
|
|
12
|
+
"""
|
|
13
|
+
请求处理器
|
|
14
|
+
|
|
15
|
+
提供不同类型请求事件的处理功能(如好友申请、群邀请等)
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
"""
|
|
20
|
+
初始化请求处理器
|
|
21
|
+
"""
|
|
22
|
+
self.handler = event_manager.create_event_handler("request", "request")
|
|
23
|
+
|
|
24
|
+
def on_request(self, priority: int = 0):
|
|
25
|
+
"""
|
|
26
|
+
通用请求事件装饰器
|
|
27
|
+
|
|
28
|
+
:param priority: 处理器优先级
|
|
29
|
+
:return: 装饰器函数
|
|
30
|
+
"""
|
|
31
|
+
def decorator(func: Callable):
|
|
32
|
+
self.handler.register(func, priority)
|
|
33
|
+
return func
|
|
34
|
+
return decorator
|
|
35
|
+
|
|
36
|
+
def on_friend_request(self, priority: int = 0):
|
|
37
|
+
"""
|
|
38
|
+
好友请求事件装饰器
|
|
39
|
+
|
|
40
|
+
:param priority: 处理器优先级
|
|
41
|
+
:return: 装饰器函数
|
|
42
|
+
"""
|
|
43
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
44
|
+
return event.get("detail_type") == "friend"
|
|
45
|
+
|
|
46
|
+
def decorator(func: Callable):
|
|
47
|
+
self.handler.register(func, priority, condition)
|
|
48
|
+
return func
|
|
49
|
+
return decorator
|
|
50
|
+
|
|
51
|
+
def on_group_request(self, priority: int = 0):
|
|
52
|
+
"""
|
|
53
|
+
群邀请请求事件装饰器
|
|
54
|
+
|
|
55
|
+
:param priority: 处理器优先级
|
|
56
|
+
:return: 装饰器函数
|
|
57
|
+
"""
|
|
58
|
+
def condition(event: Dict[str, Any]) -> bool:
|
|
59
|
+
return event.get("detail_type") == "group"
|
|
60
|
+
|
|
61
|
+
def decorator(func: Callable):
|
|
62
|
+
self.handler.register(func, priority, condition)
|
|
63
|
+
return func
|
|
64
|
+
return decorator
|
|
65
|
+
|
|
66
|
+
# 创建全局请求处理器实例
|
|
67
|
+
request = RequestHandler()
|
ErisPulse/Core/__init__.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .adapter import AdapterFather, SendDSL, adapter
|
|
2
|
+
from .storage import storage
|
|
2
3
|
from .env import env
|
|
3
4
|
from .logger import logger
|
|
4
5
|
from .mods import mods
|
|
@@ -6,13 +7,18 @@ from .router import router, adapter_server
|
|
|
6
7
|
from .config import config
|
|
7
8
|
from . import exceptions
|
|
8
9
|
|
|
10
|
+
from . import Event
|
|
11
|
+
|
|
9
12
|
BaseAdapter = AdapterFather
|
|
10
13
|
|
|
11
14
|
__all__ = [
|
|
15
|
+
'Event',
|
|
16
|
+
|
|
12
17
|
'BaseAdapter',
|
|
13
18
|
'AdapterFather',
|
|
14
19
|
'SendDSL',
|
|
15
20
|
'adapter',
|
|
21
|
+
'storage',
|
|
16
22
|
'env',
|
|
17
23
|
'logger',
|
|
18
24
|
'mods',
|
ErisPulse/Core/adapter.py
CHANGED