Skip to content

Commit

Permalink
Merge pull request n3d1117#298 from stanislavlysenko0912/reply-messages
Browse files Browse the repository at this point in the history
Add support for quoting replied messages
  • Loading branch information
n3d1117 committed May 6, 2023
2 parents 0fede20 + b37946c commit e9bed78
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 e9bed78

Please sign in to comment.