gpt4 book ai didi

c# - 如何在C#中使用Telegram API发送消息

转载 作者:行者123 更新时间:2023-12-01 16:15:47 25 4
gpt4 key购买 nike

我想使用 C# 中的 Telegram API 向某个号码发送简单的消息。我在 GitHub 上找到了一些库,但无法使用它们。

谁能给个简单的代码吗?我可以简单地进行 HTTP 调用吗?

最佳答案

  1. 安装包 Telegram.Bot
  2. 使用 botfather 创建机器人
  3. 使用/token 命令获取 api key (仍在 botfather 中)
  4. 使用此代码:
var bot = new Api("your api key here");
var t = await bot.SendTextMessage("@channelname or chat_id", "text message");

You can now pass a channel username (in the format @channelusername)in the place of chat_id in all methods (and instead of from_chat_id inforwardMessage). For this to work, the bot must be an administrator inthe channel.

https://core.telegram.org/bots/api

关于c# - 如何在C#中使用Telegram API发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31271355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com