mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-07 02:05:51 +00:00
fix(telegram): ignore unauthorized users silently
This commit is contained in:
parent
358997554c
commit
5aa61e08d3
@ -790,6 +790,8 @@ class TelegramChannel(BaseChannel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
|
if not self.is_allowed(self._sender_id(user)):
|
||||||
|
return
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
f"👋 Hi {user.first_name}! I'm nanobot.\n\n"
|
f"👋 Hi {user.first_name}! I'm nanobot.\n\n"
|
||||||
"Send me a message and I'll respond!\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:
|
async def _on_help(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
"""Handle /help command, bypassing ACL so all users can access it."""
|
"""Handle /help command for allowed users only."""
|
||||||
if not update.message:
|
if not update.message or not update.effective_user:
|
||||||
|
return
|
||||||
|
if not self.is_allowed(self._sender_id(update.effective_user)):
|
||||||
return
|
return
|
||||||
await update.message.reply_text(build_help_text())
|
await update.message.reply_text(build_help_text())
|
||||||
|
|
||||||
@ -1016,6 +1020,8 @@ class TelegramChannel(BaseChannel):
|
|||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
chat_id = message.chat_id
|
chat_id = message.chat_id
|
||||||
sender_id = self._sender_id(user)
|
sender_id = self._sender_id(user)
|
||||||
|
if not self.is_allowed(sender_id):
|
||||||
|
return
|
||||||
self._remember_thread_context(message)
|
self._remember_thread_context(message)
|
||||||
|
|
||||||
# Store chat_id for replies
|
# Store chat_id for replies
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user