Documentation
¶
Overview ¶
Package chatpush sends an alert's words to a chat app beside Bark (gandli on X): a Telegram bot's message to one chat (Bot API sendMessage), a Discord channel's webhook, and a Pushover app's message to a user or group (VersunPan on X), a DingTalk group's custom robot and a ServerChan (Server酱) SendKey's WeChat push (yingxianyu on X). Each is one POST of JSON. The bot token, the webhook addresses, Pushover's token and user key, DingTalk's signing secret and the SendKey are secrets: an error names the server's answer, never them, as the token sits in Telegram's address, the webhook's token in its own and the SendKey in ServerChan's.
Index ¶
- Variables
- func PushDingTalk(ctx context.Context, d DingTalk, title, body string) error
- func PushDiscord(ctx context.Context, d Discord, title, body string) error
- func PushPushover(ctx context.Context, p Pushover, title, body string) error
- func PushServerChan(ctx context.Context, c ServerChan, title, body string) error
- func PushTelegram(ctx context.Context, t Telegram, title, body string) error
- func ServerChanURL(key string) string
- type DingTalk
- type Discord
- type Pushover
- type ServerChan
- type Telegram
Constants ¶
This section is empty.
Variables ¶
var ( ServerChanAPI = "https://sctapi.ftqq.com/" ServerChan3API = "https://%s.push.ft07.com/send/" ServerChanMaxAPI = "https://%s.max.ft07.com/" )
ServerChan's push servers, by the SendKey's kind, as its own SDK (easychen/serverchan-sdk) picks them: Turbo's (SCT…) is the address the key and ".send" follow; Server酱³'s (sctp<uid>t…) and Max's (scx-<uid>-…) take the key's uid for %s. Vars for tests.
var PushoverAPI = "https://api.pushover.net/1/messages.json"
PushoverAPI is Pushover's message API; a var for tests, as TelegramAPI.
var TelegramAPI = "https://api.telegram.org"
TelegramAPI is the Bot API's server; a var for tests, here and in the packages that send alerts.
Functions ¶
func PushDingTalk ¶
PushDingTalk sends title and body to d's group as one text message. A robot whose security is a keyword sends only what holds it, so a text that doesn't name magpie is headed "magpie · ", and "magpie" is a keyword every alert holds.
func PushDiscord ¶
PushDiscord posts title and body to d's channel, as magpie, mentioning no one whatever the words hold.
func PushPushover ¶
PushPushover sends title and body to p's user as one plain-text message: the title as Pushover's title, the body as its message.
func PushServerChan ¶
func PushServerChan(ctx context.Context, c ServerChan, title, body string) error
PushServerChan sends title and body with c's SendKey: the title (one line, cut to 32 characters) as its title, the body as desp, which ServerChan reads as Markdown, so each line is its own paragraph. A title that was cut goes whole over the body.
func PushTelegram ¶
PushTelegram sends title and body to t's chat as one plain-text message.
func ServerChanURL ¶
ServerChanURL is where key's pushes go, as ServerChan's SDK picks it from the key's start; "" for an sctp or scx- key with no uid in it, which its SDK refuses too rather than send it to Turbo.
Types ¶
type DingTalk ¶
type DingTalk struct {
Webhook, Secret string
}
DingTalk is a DingTalk group's custom robot (自定义机器人): its webhook address, as the robot's settings copy it (https://oapi.dingtalk.com/robot/send?access_token=…), and its signing secret (加签, SEC…), "" for a robot that checks a keyword or the sender's IP instead.
type Discord ¶
type Discord struct {
Webhook string
}
Discord is a channel's webhook address, as its Integrations page copies it.
type Pushover ¶
type Pushover struct {
Token, User string
}
Pushover is an application's API token, from the app made on pushover.net, and the user's (or a group's) key it sends to.
type ServerChan ¶
type ServerChan struct {
Key string
}
ServerChan is a ServerChan (Server酱) SendKey: Turbo's SCT…, Server酱³'s sctp<uid>t… or Max's scx-<uid>-…, as sct.ftqq.com or sc3.ft07.com shows it.
type Telegram ¶
type Telegram struct {
Token, Chat, API string
}
Telegram is a bot's token, from @BotFather, and the chat it writes to: a user's, group's or channel's numeric id, or a public @name. API is the Bot API server to ask, where api.telegram.org is blocked: a self-hosted telegram-bot-api or a proxy to Telegram's (Hexguu on X); "" is TelegramAPI. The token still goes in its path.