telegram-support-bot icon indicating copy to clipboard operation
telegram-support-bot copied to clipboard

Bot Code Issues

Open wutlah opened this issue 3 years ago • 1 comments

When bot forwarded to a Telegram Group that have been set up to receive, it work normally.

Bot function normally by forwarding messages to the group. This include "From: @sadvibealone User above don't allow forward his messages. Reply to this message."

However , when reply to the "bot reply under user forwarded message" , it shows WRONG_REPLY error.

Much Thx

wutlah avatar Sep 21 '21 15:09 wutlah

This is wrong in your fork:

text=f'From: @{update.message.from_user.username}\n{REPLY_TO_THIS_MESSAGE}' Username not always available in user security policy, only friendly display name.

You must use numeric userID instead of username

But if you want use username, rewrite this user_id extraction

elif REPLY_TO_THIS_MESSAGE in update.message.reply_to_message.text:
        try:
            user_id = int(update.message.reply_to_message.text.split('\n')[0])
        except ValueError:
            user_id = None
    if user_id:
        context.bot.copy_message(
            message_id=update.message.message_id,
            chat_id=user_id,
            from_chat_id=update.message.chat_id
        )

rus-ai avatar Sep 26 '21 13:09 rus-ai