fix: handle /help command directly in Telegram, bypassing ACL check
The /help command was routed through _forward_command → _handle_message → is_allowed(), which denied access to users not in the allowFrom list. Since /help is purely informational, it should be accessible to all users — similar to how /start already works with its own handler. Add a dedicated _on_help handler that replies directly without going through the message bus access control. Closes #687
This commit is contained in:
@@ -146,7 +146,7 @@ class TelegramChannel(BaseChannel):
|
|||||||
# Add command handlers
|
# Add command handlers
|
||||||
self._app.add_handler(CommandHandler("start", self._on_start))
|
self._app.add_handler(CommandHandler("start", self._on_start))
|
||||||
self._app.add_handler(CommandHandler("new", self._forward_command))
|
self._app.add_handler(CommandHandler("new", self._forward_command))
|
||||||
self._app.add_handler(CommandHandler("help", self._forward_command))
|
self._app.add_handler(CommandHandler("help", self._on_help))
|
||||||
|
|
||||||
# Add message handler for text, photos, voice, documents
|
# Add message handler for text, photos, voice, documents
|
||||||
self._app.add_handler(
|
self._app.add_handler(
|
||||||
@@ -266,6 +266,20 @@ class TelegramChannel(BaseChannel):
|
|||||||
"Type /help to see available commands."
|
"Type /help to see available commands."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def _on_help(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
|
"""Handle /help command directly, bypassing access control.
|
||||||
|
|
||||||
|
/help is informational and should be accessible to all users,
|
||||||
|
even those not in the allowFrom list.
|
||||||
|
"""
|
||||||
|
if not update.message:
|
||||||
|
return
|
||||||
|
await update.message.reply_text(
|
||||||
|
"🐈 nanobot commands:\n"
|
||||||
|
"/new — Start a new conversation\n"
|
||||||
|
"/help — Show available commands"
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _sender_id(user) -> str:
|
def _sender_id(user) -> str:
|
||||||
"""Build sender_id with username for allowlist matching."""
|
"""Build sender_id with username for allowlist matching."""
|
||||||
|
|||||||
Reference in New Issue
Block a user