0

I can't solve the problem: I can't get the id of the user whose message I forwarded to the bot. When i forward a message i get my id. I'll be glad to help!!!! My cod:

import telebot

bot = telebot.TeleBot('TOKEN')

@bot.message_handler(func=lambda message: True)
def send_welcome(message):
    user_id = message.from_user.id

    bot.send_message(message.chat.id, "ID: " + str(user_id))


if __name__ == '__main__':
    bot.polling(none_stop=True)
arnold
  • 177
  • 7

1 Answers1

0

Change message.from_user.id to message.forward_from.id

import telebot
    
    bot = telebot.TeleBot('TOKEN')
    
    @bot.message_handler(func=lambda message: True)
    def send_welcome(message):
        user_id = message.forward_from.id
    
        bot.send_message(message.chat.id, "ID: " + str(user_id))
    
    
    if __name__ == '__main__':
        bot.polling(none_stop=True)