visual-studio-code - 如何使用我的 Telegram Bot 使用他们的用户名向某人发送消息

标签 visual-studio-code python telegram telegram-bot python-telegram-bot

我正在使用 telepot python 库,我知道当你有某人的用户 ID(这是一个数字)时,你可以发送消息。 我想知道是否可以在没有用户 ID 而只使用用户名(以“@”开头的用户名)的情况下向某人发送消息,此外,如果有一种方法可以将用户名转换为用户 ID。

最佳答案

  1. 从用户向机器人发送一条消息。
  2. 打开https://api.telegram.org/bot<Bot_token>/getUpdates页面。
  3. 找到这条消息并导航到结果->消息->聊天->id 键。
  4. 使用此 ID 作为 [chat_id] 参数向用户发送个人消息。

关于visual-studio-code - 如何使用我的 Telegram Bot 使用他们的用户名向某人发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41664810/

相关文章:

telegram - 使用 sendPhoto( Telegram Bot )发送动画 GIF

spring-boot - 如何让 VS Code 识别嵌套的 gradle 项目?

VSCode 中的 Python : Set working directory to python file's path everytime

python - PYCFunctionWithKeywords 从 python 中被错误调用

api - 如何在 Requests 中指定和实现 Telegram API 方法?

Python Telegram 机器人从列表中添加处理程序

javascript - Visual Studio Code - 跨 JS 模块的智能感知

visual-studio-code - 如何在Visual Studio Code中更改标尺的颜色

python - 如何使用最大值提取Python数据框中的特定列

python - 使用 Python 将 mp4 AAC 转换为 AVC