-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpatch_data_pool.py
More file actions
32 lines (24 loc) · 940 Bytes
/
Copy pathpatch_data_pool.py
File metadata and controls
32 lines (24 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from dataclasses import dataclass
from typing import Union
from pyrogram_patch.fsm import BaseStorage
from contextlib import suppress
@dataclass()
class PatchDataPool:
update_pool: dict
pyrogram_patch_middlewares: list
pyrogram_patch_outer_middlewares: list
pyrogram_patch_fsm_storage: Union[BaseStorage, None]
@staticmethod
def include_helper_to_pool(update, patch_helper) -> None:
PatchDataPool.update_pool[id(update)] = patch_helper
@staticmethod
def exclude_helper_from_pool(update) -> None:
with suppress(KeyError):
PatchDataPool.update_pool.pop(id(update))
@staticmethod
def get_helper_from_pool(update) -> Union[object, None]:
return PatchDataPool.update_pool[id(update)]
PatchDataPool.update_pool = {}
PatchDataPool.pyrogram_patch_middlewares = []
PatchDataPool.pyrogram_patch_outer_middlewares = []
PatchDataPool.pyrogram_patch_fsm_storage = None