Skip to content

Commit

Permalink
Merge pull request #186 from JokerQyou/userid-patch-1
Browse files Browse the repository at this point in the history
Ignore empty value when validating user IDs
  • Loading branch information
n3d1117 authored Apr 6, 2023
2 parents 7881921 + 9c4c2e7 commit 5ffe144
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bot/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ async def is_allowed(self, update: Update, context: CallbackContext) -> bool:
if self.is_group_chat(update):
admin_user_ids = self.config['admin_user_ids'].split(',')
for user in itertools.chain(allowed_user_ids, admin_user_ids):
if not user.strip():
continue
if await self.is_user_in_group(update, context, user):
logging.info(f'{user} is a member. Allowing group chat message...')
return True
Expand Down Expand Up @@ -702,6 +704,8 @@ async def is_within_budget(self, update: Update, context: CallbackContext) -> bo
if self.is_group_chat(update):
admin_user_ids = self.config['admin_user_ids'].split(',')
for user in itertools.chain(allowed_user_ids, admin_user_ids):
if not user.strip():
continue
if await self.is_user_in_group(update, context, user):
if 'guests' not in self.usage:
self.usage['guests'] = UsageTracker('guests', 'all guest users in group chats')
Expand Down

0 comments on commit 5ffe144

Please sign in to comment.