Skip to content

Commit

Permalink
feat(telegram_bot.py): add support for quoting replied messages in gr…
Browse files Browse the repository at this point in the history
…oup chats

This allows users to quote a message when replying to it in a group chat, making the conversation context clearer.
  • Loading branch information
stanislavlysenko0912 committed May 5, 2023
1 parent 0fede20 commit b37946c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bot/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ async def prompt(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
trigger_keyword = self.config['group_trigger_keyword']
if prompt.lower().startswith(trigger_keyword.lower()):
prompt = prompt[len(trigger_keyword):].strip()

if update.message.reply_to_message and \
update.message.reply_to_message.text and \
update.message.reply_to_message.from_user.id != context.bot.id:
prompt = '"{reply}" {prompt}'.format(
reply=update.message.reply_to_message.text,
prompt=prompt
)
else:
if update.message.reply_to_message and update.message.reply_to_message.from_user.id == context.bot.id:
logging.info('Message is a reply to the bot, allowing...')
Expand Down

0 comments on commit b37946c

Please sign in to comment.