Skip to content

Commit f4156d2

Browse files
fix: incorrect text condition checks in chat handlers
Replaced `not message.text` with `message.text` to properly handle cases where messages are empty or invalid. This ensures the conditional logic works as intended and prevents unnecessary processing of certain messages. The changes improve code reliability and reduce potential edge case errors.
1 parent c92df41 commit f4156d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

WinxMusic/plugins/extras/chat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@app.on_message(filters.regex("winx", re.IGNORECASE) & ~BANNED_USERS)
2121
async def ai(_: Client, message: Message):
22-
if not message.text or message.text.startswith(tuple(PREFIXES)):
22+
if message.text and message.text.startswith(tuple(PREFIXES)):
2323
return
2424

2525
username = message.from_user.first_name
@@ -104,7 +104,7 @@ async def ai(_: Client, message: Message):
104104
filters.reply & ~filters.command(config.PREFIXES) & ~filters.private & ~BANNED_USERS
105105
)
106106
async def handle_reply(_: Client, message: Message):
107-
if not message.text or message.text.startswith(tuple(PREFIXES)):
107+
if message.text and message.text.startswith(tuple(PREFIXES)):
108108
return
109109

110110
me = await app.get_me()
@@ -140,7 +140,7 @@ async def handle_reply(_: Client, message: Message):
140140
# filter command
141141
@app.on_message(filters.group & (filters.chat([config.AI_GROUP_ID])) & ~BANNED_USERS)
142142
async def save_message_history(_, message: Message):
143-
if not message.text or message.text.startswith(tuple(PREFIXES)) or message.from_user.id == app.id:
143+
if message.text and message.text.startswith(tuple(PREFIXES)):
144144
return
145145

146146
me = await app.get_me()

0 commit comments

Comments
 (0)