From 5aa61e08d3518d3d1edf1e6b43d5afe0d8a7a99a Mon Sep 17 00:00:00 2001 From: DG Multica Date: Tue, 5 May 2026 13:03:38 +0700 Subject: [PATCH] fix(telegram): ignore unauthorized users silently --- nanobot/channels/telegram.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.py index 793419917..eecb73225 100644 --- a/nanobot/channels/telegram.py +++ b/nanobot/channels/telegram.py @@ -790,6 +790,8 @@ class TelegramChannel(BaseChannel): return user = update.effective_user + if not self.is_allowed(self._sender_id(user)): + return await update.message.reply_text( f"👋 Hi {user.first_name}! I'm nanobot.\n\n" "Send me a message and I'll respond!\n" @@ -797,8 +799,10 @@ class TelegramChannel(BaseChannel): ) async def _on_help(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: - """Handle /help command, bypassing ACL so all users can access it.""" - if not update.message: + """Handle /help command for allowed users only.""" + if not update.message or not update.effective_user: + return + if not self.is_allowed(self._sender_id(update.effective_user)): return await update.message.reply_text(build_help_text()) @@ -1016,6 +1020,8 @@ class TelegramChannel(BaseChannel): user = update.effective_user chat_id = message.chat_id sender_id = self._sender_id(user) + if not self.is_allowed(sender_id): + return self._remember_thread_context(message) # Store chat_id for replies