Answer the question
In order to leave comments, you need to log in
How to get user id through forwarded message?
In general, it is necessary that when replaying a forwarded message, the bot throws this message to the user, from whom he threw the initial one. Some kind of feedback
owner = #мойайдишник
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.chat.id == owner:
if hasattr(message.reply_to_message, 'text'):
bot.send_message(message.reply_to_message.from_user.id, message.text)
else:
pass
else:
if hasattr(message, 'text'):
x = message.chat.id
bot.forward_message(owner, message.chat.id, message.message_id)
bot.send_message(x, 'Отправлено')
Answer the question
In order to leave comments, you need to log in
This code reacts to the replay of the forwarded message:
@bot.message_handler(content_types = ['text'])
def testing(message):
if message.reply_to_message!=None and message.reply_to_message.forward_from!=None:
bot.send_message(message.reply_to_message.forward_from.id, 'test')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question