Merge pull request #298 from stanislavlysenko0912/reply-messages

Add support for quoting replied messages
This commit is contained in:
ned
2023-05-06 11:09:12 +02:00
committed by GitHub

View File

@@ -401,6 +401,14 @@ class ChatGPTTelegramBot:
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...')