Documentation
¶
Overview ¶
Package notify delivers an unattended run's events to an external webhook: Discord, Telegram, or any endpoint that accepts a JSON `text` field.
The farm runs with nobody watching it, so the events that matter — an attack result, a village that halted, a scheduler pause — are only useful if they leave the machine. Desktop notifications already cover a human sitting at the same Mac (tools/run_bot_keepalive.sh); this covers the phone.
Delivery is deliberately fire-and-forget. Send never blocks the capture loop or the attack goroutine, and a webhook that is down must never change what the bot does: messages queue on one worker goroutine, and a full queue drops the event with a log line rather than applying backpressure to the bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool
Format Format
WebhookURL string
TelegramToken string
TelegramChatID string
}
Config is the notify block of config.json, already flattened.
type Format ¶
type Format string
Format is the wire shape of the configured endpoint.
const ( // FormatDiscord posts {"content": "..."} to a Discord webhook URL. FormatDiscord Format = "discord" // FormatTelegram posts sendMessage to the Bot API. FormatTelegram Format = "telegram" // FormatGeneric posts {"text","kind","at"} — Slack and most self-hosted // receivers accept the text field and ignore the rest. FormatGeneric Format = "generic" )
type Message ¶
type Message struct {
Kind string // "attack", "halt", "resume"
Title string
Lines []string
At time.Time
}
Message is one event. Lines are rendered in order under the title.
type Sender ¶
type Sender interface {
Send(Message)
}
Sender is what the bot calls. It is non-blocking and reports nothing back: a failed notification is a log line, not a bot failure.
func New ¶
New returns a Sender, or nil when notifications are off or misconfigured.
A nil return is the normal, silent case for every install that never enabled this, so callers only have to nil-check. A misconfigured block is logged once at construction and then behaves as disabled, because a bad URL must not take a farming session down.