telegram.message() 函数
telegram.message() 是一个由 包作者 维护的用户贡献函数。
telegram.message() 向 Telegram 频道发送单个消息,使用 Telegram Bot API 的 sendMessage 方法。
函数类型签名
(
channel: A,
text: B,
token: string,
?disableWebPagePreview: C,
?parseMode: D,
?silent: E,
?url: string,
) => int
有关更多信息,请参见 Function type signatures。
参数
网址
Telegram 机器人端点的 URL。默认是 https://api.telegram.org/bot。
令牌
(必填) Telegram 机器人令牌。
频道
(必填) Telegram频道ID。
文本
(必填) 消息文本。
解析模式
解析模式
消息文本的。
默认为 MarkdownV2.
禁用网页预览
禁用发送消息中网页链接的预览。 默认值是 false。
沉默
静默发送消息 silently。
默认值是 true。
示例
将最后报告的状态发送到Telegram
import "influxdata/influxdb/secrets"
import "contrib/sranka/telegram"
token = secrets.get(key: "TELEGRAM_TOKEN")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
telegram.message(token: token, channel: "-12345", text: "Disk usage is **${lastReported.status}**.")