Skip to content

Commit

Permalink
modules: ask: fixup! Guard against empty reply_to_message field
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimifr committed Mar 26, 2024
1 parent e94784d commit c4df604
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ async def cmd_ask(app: Client, message: Message):
my_id: int = (await app.get_me()).id
previous_prompts: list[dict[str, str]] = LoggedList()

# If we were to use message.reply_to_message directly, we cannot get subsequent replies
reply_to_message = await app.get_messages(message.chat.id, message.reply_to_message.id, replies=20)
if message.reply_to_message:
# If we were to use message.reply_to_message directly, we cannot get subsequent replies
reply_to_message = await app.get_messages(message.chat.id, message.reply_to_message.id, replies=20)
else:
reply_to_message = None

# Track (at max 20) replies to preserve context
while reply_to_message is not None:
Expand Down

0 comments on commit c4df604

Please sign in to comment.