Telegram API:如何从id(Python telepot)获取用户名?

问题描述 投票:0回答:1

我将我机器人的所有用户的ID保存在数据库中,但如果我知道id,我怎样才能获得他们当前的用户名?我正在使用Python 3和Telepot框架。

python telegram telegram-bot python-telegram-bot telepot
1个回答
0
投票

您可以通过检查实体来获取帐户的信息。

您可以尝试使用此方法获取实体:

entity = client.get_entity(chat_id)

然后Print实体,并试图从那里得到像name = entity.chat.name这样的名字

© www.soinside.com 2019 - 2024. All rights reserved.