|
6 | 6 | from nonebot_plugin_uninfo import get_session |
7 | 7 |
|
8 | 8 | _IdType = str | int |
| 9 | +BYPASS_ENTITY = "__bypass" |
9 | 10 |
|
10 | 11 |
|
11 | 12 | class CooldownEntity: |
@@ -69,13 +70,13 @@ def __init__(self, *, whitelist: None | tuple[_IdType, ...] = None, permission: |
69 | 70 | async def get_entity_id(self, bot: Bot, event: Event) -> str: |
70 | 71 | sess = await get_session(bot, event) |
71 | 72 | if sess is None: |
72 | | - return "__bypass" |
| 73 | + return BYPASS_ENTITY |
73 | 74 |
|
74 | 75 | user_id = sess.user.id |
75 | 76 | if self.whitelist is not None and user_id in self.whitelist: |
76 | | - return "__bypass" |
| 77 | + return BYPASS_ENTITY |
77 | 78 | if self.permission is not None and (await self.permission(bot, event)): |
78 | | - return "__bypass" |
| 79 | + return BYPASS_ENTITY |
79 | 80 | return f"u`{user_id}`" |
80 | 81 |
|
81 | 82 |
|
@@ -106,13 +107,13 @@ def __init__(self, *, whitelist: None | tuple[_IdType, ...] = None, permission: |
106 | 107 | async def get_entity_id(self, bot: Bot, event: Event) -> str: |
107 | 108 | sess = await get_session(bot, event) |
108 | 109 | if sess is None: |
109 | | - return "__bypass" |
| 110 | + return BYPASS_ENTITY |
110 | 111 |
|
111 | 112 | scene_id = sess.scene.id |
112 | 113 | if self.whitelist is not None and scene_id in self.whitelist: |
113 | | - return "__bypass" |
| 114 | + return BYPASS_ENTITY |
114 | 115 | if self.permission is not None and (await self.permission(bot, event)): |
115 | | - return "__bypass" |
| 116 | + return BYPASS_ENTITY |
116 | 117 | return f"s`{scene_id}`" |
117 | 118 |
|
118 | 119 |
|
@@ -151,16 +152,16 @@ def __init__( |
151 | 152 | async def get_entity_id(self, bot: Bot, event: Event) -> str: |
152 | 153 | sess = await get_session(bot, event) |
153 | 154 | if sess is None: |
154 | | - return "__bypass" |
| 155 | + return BYPASS_ENTITY |
155 | 156 |
|
156 | 157 | user_id = sess.user.id |
157 | 158 | scene_id = sess.scene.id |
158 | 159 | if self.whitelist is not None: |
159 | 160 | for uid, sid in self.whitelist: |
160 | 161 | if (uid == "*" or uid == user_id) and (sid == "*" or sid == scene_id): |
161 | | - return "__bypass" |
| 162 | + return BYPASS_ENTITY |
162 | 163 | if self.permission is not None and (await self.permission(bot, event)): |
163 | | - return "__bypass" |
| 164 | + return BYPASS_ENTITY |
164 | 165 | return f"u`{user_id}`_s`{scene_id}`" |
165 | 166 |
|
166 | 167 |
|
@@ -193,13 +194,13 @@ def __init__(self, *, whitelist: None | tuple[_IdType, ...] = None, permission: |
193 | 194 | async def get_entity_id(self, bot: Bot, event: Event) -> str: |
194 | 195 | sess = await get_session(bot, event) |
195 | 196 | if sess is None or not sess.scene.is_private: |
196 | | - return "__bypass" |
| 197 | + return BYPASS_ENTITY |
197 | 198 |
|
198 | 199 | user_id = sess.user.id |
199 | 200 | if self.whitelist is not None and user_id in self.whitelist: |
200 | | - return "__bypass" |
| 201 | + return BYPASS_ENTITY |
201 | 202 | if self.permission is not None and (await self.permission(bot, event)): |
202 | | - return "__bypass" |
| 203 | + return BYPASS_ENTITY |
203 | 204 | return f"u`{user_id}`" |
204 | 205 |
|
205 | 206 |
|
@@ -232,11 +233,11 @@ def __init__(self, *, whitelist: None | tuple[_IdType, ...] = None, permission: |
232 | 233 | async def get_entity_id(self, bot: Bot, event: Event) -> str: |
233 | 234 | sess = await get_session(bot, event) |
234 | 235 | if sess is None or sess.scene.is_private: |
235 | | - return "__bypass" |
| 236 | + return BYPASS_ENTITY |
236 | 237 |
|
237 | 238 | user_id = sess.user.id |
238 | 239 | if self.whitelist is not None and user_id in self.whitelist: |
239 | | - return "__bypass" |
| 240 | + return BYPASS_ENTITY |
240 | 241 | if self.permission is not None and (await self.permission(bot, event)): |
241 | | - return "__bypass" |
| 242 | + return BYPASS_ENTITY |
242 | 243 | return f"u`{user_id}`" |
0 commit comments