Allow the bot to specify the original sender

This commit is contained in:
bursa-pastoris 2023-11-17 20:08:32 +01:00
parent fb6b86128d
commit 7c6409e626
3 changed files with 9 additions and 5 deletions

View File

@ -30,6 +30,7 @@ makedirs(CHAT_PATH+'/data', exist_ok=True)
# user returned
OWNER_ID = config['user_returned']['owner_id']
SEND_SENDER = config['user_returned'].getboolean('send_sender')
REDIRECT_MSG = config['user_returned']['redirect_msg']
# internal

View File

@ -27,5 +27,7 @@ chat_path:
[user_returned]
owner_id:
# Whether the bot must send a message specifing the sender before forwarding
send_sender: false
# The message to send to users contacting the bot
redirect_msg = The user is back. You can can contact him directly now.

View File

@ -28,11 +28,12 @@ async def user_back(update, context):
chat_id=update.effective_chat.id,
reply_to_message_id=update.effective_message.id,
text=REDIRECT_MSG)
sender = USER_NAMES[str(update.effective_chat.id)]
await context.bot.send_message(
chat_id=OWNER_ID,
text=f'*Message from {sender}:*',
parse_mode='MarkdownV2')
if SEND_SENDER:
sender = USER_NAMES[str(update.effective_chat.id)]
await context.bot.send_message(
chat_id=OWNER_ID,
text=f'*Message from {sender}:*',
parse_mode='MarkdownV2')
await context.bot.forward_message(
chat_id=OWNER_ID,
from_chat_id=update.effective_chat.id,