I am doing a bot-moderator. I am doing a command ‘ban’. if I reply to somebody’s message by typing /ban
bot should get its id and restrict him.
my code now:
@bot.messsage_handler(commands=['ban'])
def ban(message):
#here I should get the id of a user which I replied in Telegram
#then bot should restrict him.
PyTelegramBotApi
python 3.7
thank you
2
Answers
You can restrict user at least at 30 seconds.
code to restrict:
unix time
In
Message
class, you have areply_to_message
which returns aMessage
object and you can find user id from this object. If user doesn’t reply to any message it’s equal toNone
. So this is what you want:message.reply_to_message.from_user
If you want more information you can read from Telegram bot API or check types.py in library github.