notify

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 12 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 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

func New(ctx context.Context, cfg Config, logger zerolog.Logger) Sender

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.

Jump to

Keyboard shortcuts

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