mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-22 15:14:54 +01:00
feat(telegram_bot.py): add support for quoting replied messages in group chats
This allows users to quote a message when replying to it in a group chat, making the conversation context clearer.
This commit is contained in:
@@ -401,6 +401,14 @@ class ChatGPTTelegramBot:
|
|||||||
trigger_keyword = self.config['group_trigger_keyword']
|
trigger_keyword = self.config['group_trigger_keyword']
|
||||||
if prompt.lower().startswith(trigger_keyword.lower()):
|
if prompt.lower().startswith(trigger_keyword.lower()):
|
||||||
prompt = prompt[len(trigger_keyword):].strip()
|
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:
|
else:
|
||||||
if update.message.reply_to_message and update.message.reply_to_message.from_user.id == context.bot.id:
|
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...')
|
logging.info('Message is a reply to the bot, allowing...')
|
||||||
|
|||||||
Reference in New Issue
Block a user