python - Telegram API:如何从 id (Python telepot) 获取用户名?
问题描述
我将我的机器人的所有用户的 ID 保存在数据库中,但是如果我知道 ID,如何获取他们当前的用户名?我正在使用 Python 3 和 Telepot 框架。
解决方案
user_id中的用户信息可以通过 中的getChat
方法获取telepot
。
bot = telepot.Bot(TOKEN)
info = bot.getChat(user_id)
print(info)
推荐阅读
- wpf - 在 wpf 中更改按钮形状
- c# - C# 如何使用 SelectToken 操作 JSON
- python - 如何将 DSN6 文件解压缩为可读格式?
- c# - 基于 CheckBox 状态禁用 ComboBox 项
- ios - 在 Swift 中使用 XMLParser 解析特定标签并保存为字符串
- flutter - 遇到了 rrousselGit / provider 的问题
- ruby-on-rails - 主动存储与 CarrierWave 和 PaperClip 相比的优缺点
- string - MVC API 路由参数
- python - How to add key value pair to django queryset
- c# - 如何根据 WPF 中的单元格值设置网格列的背景颜色?