telegram 包
telegram
包是由包作者维护的用户贡献包。
telegram
包提供了使用 Telegram Bot API 向 Telegram 发送消息的函数。导入 contrib/sranka/telegram
包
import "contrib/sranka/telegram"
设置 Telegram 机器人
Telegram Bot API 需要 机器人令牌 和 频道 ID。要设置 Telegram 机器人并获取所需的机器人令牌和频道 ID
创建新的 Telegram 帐户 或使用现有帐户。
创建 Telegram 机器人。Telegram 为新创建的机器人提供一个 机器人令牌。
使用 Telegram 应用程序 创建新频道。
将新机器人添加到频道 作为管理员。确保机器人拥有发布消息所需的权限。
在频道中向机器人发送消息。
向
https://api.telegram.org/bot$token/getUpdates
发送请求。curl https://api.telegram.org/bot$token/getUpdates
在响应的
id
字段中找到您的 频道 ID。
选项
option telegram.defaultDisableWebPagePreview = false
option telegram.defaultParseMode = "MarkdownV2"
option telegram.defaultSilent = true
option telegram.defaultURL = "https://api.telegram.org/bot"
defaultDisableWebPagePreview
defaultDisableWebPagePreview
- 默认使用 Telegram 网页预览。默认为 false
。
defaultParseMode
defaultParseMode
是默认的 Telegram 解析模式。默认为 MarkdownV2
。
defaultSilent
defaultSilent
- 默认发送静默 Telegram 通知。默认为 true
。
defaultURL
defaultURL
是默认的 Telegram 机器人 URL。默认为 https://api.telegram.org/bot
。
函数
此页是否对您有帮助?
感谢您的反馈!