fixes global
This commit is contained in:
1 parent
13dc4f39c8
commit
cad0f6aebe
64 files changed
+10379
-254
No files matched your search
@@ -37,10 +37,20 @@ class Wrapped_CBotChat(T, PlayerTemplates):
|
||||
|
||||
@property
|
||||
def bot_id(self):
|
||||
return {
|
||||
TELEGRAM_API_KEY: 0,
|
||||
CLIENT_TELEGRAM_API_KEY: 1
|
||||
}[self._bot_key]
|
||||
"""
|
||||
Map known tokens to stable bot IDs.
|
||||
If tokens are empty/None (Telegram disabled), fall back to hash-based mapping to avoid KeyError.
|
||||
"""
|
||||
mapping = {}
|
||||
if TELEGRAM_API_KEY:
|
||||
mapping[TELEGRAM_API_KEY] = 0
|
||||
if CLIENT_TELEGRAM_API_KEY:
|
||||
mapping[CLIENT_TELEGRAM_API_KEY] = 1
|
||||
# Try direct mapping first
|
||||
if self._bot_key in mapping:
|
||||
return mapping[self._bot_key]
|
||||
# Fallback: deterministic bucket (keeps old behavior of 0/1 classes)
|
||||
return 0 if (str(self._chat_id) + str(self._bot_key)).__hash__() % 2 == 0 else 1
|
||||
|
||||
async def return_result(self, result, message_type='common', message_meta={}, content_id=None, **kwargs):
|
||||
if self.db_session:
|
||||
|
||||
Reference in new issue
Block a user