简体   繁体   中英

How to get chat_id, user_id and time from telegram bot?

I am writing a telegram bot to handle conversations (one to one) with users and I am getting same for both userid and chat_id.

My code is:

chat_id = update.message.chat_id
user_id = update.effective_user.id

user_id is the Telegram ID of the user sending a message to bot. chat_id is the Telegram ID of the chat where a message is being sent to bot.

So, in one to one conversation, the user will send a message in his own chat (with respect to bot). That's the reason both are same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM