Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将我的机器人的所有用户的 ID 保存在数据库中,但是如果我知道 ID,如何获取他们当前的用户名?我正在使用 Python 3 和 Telepot 框架。
user_id中的用户信息可以通过 中的getChat方法获取telepot。
getChat
telepot
bot = telepot.Bot(TOKEN) info = bot.getChat(user_id) print(info)
您可以通过检查实体来获取帐户的信息。
您可以尝试使用此方法获取实体:
entity = client.get_entity(chat_id)
然后Print实体并尝试从那里获取名称,例如name = entity.chat.name
Print
name = entity.chat.name