bot

package
v0.0.0-...-fb49ba0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

Package bot implements the core HortBot IRC message handling logic.

Index

Constants

View Source
const (
	// DefaultBullet is the default bullet used when the channel's bullet is unset.
	DefaultBullet = "[HB]"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

Bot is an IRC bot. It should only be used once.

func New

func New(config *Config) *Bot

New creates a new Bot with the given config.

func (*Bot) Handle

func (b *Bot) Handle(ctx context.Context, origin string, m Message)

Handle handles a single IRC message, sent via the specific origin. It always succeeds, but may log information about any internal errors.

func (*Bot) Init

func (b *Bot) Init(ctx context.Context) error

Init initializes the bot, starting any underlying tasks. It should only be called once.

func (*Bot) Stop

func (b *Bot) Stop()

Stop instructs the bot to stop.

type Config

type Config struct {
	DB       *sql.DB
	Redis    *redis.DB
	Sender   Sender
	Notifier Notifier
	Clock    clock.Clock
	Rand     Rand

	LastFM    lastfm.API
	YouTube   youtube.API
	XKCD      xkcd.API
	ExtraLife extralife.API
	Twitch    twitch.API
	Steam     steam.API
	TinyURL   tinyurl.API
	Urban     urban.API
	Simple    simple.API
	HLTB      hltb.API

	BulletMap map[string]string
	Cooldown  int

	Admins      []string
	SuperAdmins []string

	WhitelistEnabled bool
	Whitelist        []string

	WebAddr    string
	WebAddrMap map[string]string

	NoDedupe bool

	PublicJoin         bool
	PublicJoinDisabled []string

	BetaFeatures []string

	GlobalIgnore []string

	Cron CronConfig

	PassthroughPanics bool
}

Config configures the bot.

type CronConfig

type CronConfig struct {
	ValidateTokens          bool
	UpdateModeratedChannels bool
}

type Message

type Message interface {
	Command() string
	Tags() map[string]string
	Params() []string
	Trailing() string
	PrefixName() string
	Message() (message string, me bool)
}

type Notifier

type Notifier interface {
	NotifyChannelUpdates(ctx context.Context, botName string) error
}

Notifier sends notifications.

type Rand

type Rand interface {
	Intn(n int) int
	Float64() float64
}

Rand provides random number generation.

type Sender

type Sender interface {
	SendMessage(ctx context.Context, origin, target, message string) error
}

Sender sends a single message back via an origin (bot name) to the specified target (channel).

Directories

Path Synopsis
Package btest implements a script test system for the bot package.
Package btest implements a script test system for the bot package.

Jump to

Keyboard shortcuts

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