Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ async def set_custom(client, message, pre_event, key, direct=False):
user_id = message.from_user.id
handler_dict[user_id] = False
value = message.text
if value:
value = value.strip()
Comment on lines 332 to +334
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The None check is incomplete. If message.text is None:

  1. The condition if value: evaluates to False, so value remains None
  2. Subsequent operations will fail: line 341 (is_goapi(value)), line 349 (value.split()), line 368 (value.split()), and line 385 (value.encode()) will all raise AttributeError when value is None

While the event_filter at line 458 should prevent None text from reaching this function (since mtype = event.text and the filter requires mtype to be truthy), defensive programming would make this more robust.

Consider: value = (message.text or "").strip() to ensure value is always a string.

Suggested change
value = message.text
if value:
value = value.strip()
value = (message.text or "").strip()

Copilot uses AI. Check for mistakes.
return_key = 'leech'
n_key = key
user_dict = user_data.get(user_id, {})
Expand Down Expand Up @@ -453,7 +455,7 @@ async def event_filter(_, __, event):
else:
mtype = event.text
user = event.from_user or event.sender_chat
return bool(user.id == user_id and event.chat.id == query.message.chat.id and mtype)
return bool(user and user.id == user_id and event.chat.id == query.message.chat.id and mtype)

handler = client.add_handler(MessageHandler(
pfunc, filters=create(event_filter)), group=-1)
Expand Down
Loading