feat: Добавлена обработка сообщений, ивентов и подписок

This commit is contained in:
AURUMVORXX
2025-09-02 20:27:21 +05:00
parent 80d51cece4
commit 275bd6d8b1
3 changed files with 129 additions and 81 deletions

View File

@@ -0,0 +1,23 @@
import inspect
_EVENTS = {}
def event(event_name: str, priority: int = 9999):
def inlineEvent(func):
if not inspect.iscoroutinefunction(func):
raise TypeError(f'Декоратор event поддерживает только подпрограммы')
if event_name not in _EVENTS:
_EVENTS[event_name] = []
_EVENTS[event_name].append({'function': func, 'priority': priority})
_EVENTS[event_name].sort(key = lambda x: x['priority'])
return func
return inlineEvent
async def call_event(event_name: str, *args, **kwargs):
if event_name not in _EVENTS:
return
for item in _EVENTS[event_name]:
await item['function'](*args, **kwargs)