chatpush

package
v0.1.5434 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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.

View Source
var PushoverAPI = "https://api.pushover.net/1/messages.json"

PushoverAPI is Pushover's message API; a var for tests, as TelegramAPI.

View Source
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

func PushDingTalk(ctx context.Context, d DingTalk, title, body string) error

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

func PushDiscord(ctx context.Context, d Discord, title, body string) error

PushDiscord posts title and body to d's channel, as magpie, mentioning no one whatever the words hold.

func PushPushover

func PushPushover(ctx context.Context, p Pushover, title, body string) error

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

func PushTelegram(ctx context.Context, t Telegram, title, body string) error

PushTelegram sends title and body to t's chat as one plain-text message.

func ServerChanURL

func ServerChanURL(key string) string

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.

func (DingTalk) On

func (d DingTalk) On() bool

On is whether there is a webhook to send to.

type Discord

type Discord struct {
	Webhook string
}

Discord is a channel's webhook address, as its Integrations page copies it.

func (Discord) On

func (d Discord) On() bool

On is whether there is a webhook to send to.

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.

func (Pushover) On

func (p Pushover) On() bool

On is whether there is a token and a user key to send 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.

func (ServerChan) On

func (c ServerChan) On() bool

On is whether there is a SendKey to send with.

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.

func (Telegram) On

func (t Telegram) On() bool

On is whether there is a token and a chat to send to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL