|
@@ -1,6 +1,6 @@
|
|
|
import logging
|
|
|
from typing import Optional, Dict, Any
|
|
|
-from telegram import Update
|
|
|
+from telegram import Update, Message
|
|
|
from telegram.ext import ContextTypes
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
@@ -20,17 +20,21 @@ class InfoCommandsBase:
|
|
|
return False
|
|
|
return True # Add your authorization logic here
|
|
|
|
|
|
- async def _reply(self, update: Update, text: str, parse_mode: str = 'HTML') -> None:
|
|
|
+ async def _reply(self, update: Update, text: str, parse_mode: str = 'HTML') -> Optional[Message]:
|
|
|
"""Common reply method for all commands."""
|
|
|
try:
|
|
|
if update.callback_query:
|
|
|
await update.callback_query.answer()
|
|
|
- await update.callback_query.edit_message_text(
|
|
|
+ result = await update.callback_query.edit_message_text(
|
|
|
text=text,
|
|
|
parse_mode=parse_mode
|
|
|
)
|
|
|
- else:
|
|
|
- await update.message.reply_text(
|
|
|
+ if isinstance(result, Message):
|
|
|
+ return result
|
|
|
+ return update.callback_query.message # Fallback for True case
|
|
|
+
|
|
|
+ elif update.message:
|
|
|
+ return await update.message.reply_text(
|
|
|
text=text,
|
|
|
parse_mode=parse_mode
|
|
|
)
|
|
@@ -45,6 +49,8 @@ class InfoCommandsBase:
|
|
|
)
|
|
|
except Exception as e2:
|
|
|
self.logger.error(f"Error sending fallback reply: {e2}")
|
|
|
+
|
|
|
+ return None
|
|
|
|
|
|
def _get_formatter(self):
|
|
|
"""Get the token display formatter."""
|