Skip to content

Your lightweight open-source personal agent.

fix(telegram): ignore unauthorized users silently

DG Multica5aa61e08d351
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