bot

package
v0.0.0-...-f448633 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFirstLine

func ExtractFirstLine(s string) string

Types

type Bot

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

Bot is an IRC bot and command handler

func New

func New(c *BotConfig) *Bot

New creates a new bot with the given config.

func (*Bot) EvalCmd

func (b *Bot) EvalCmd(args string, reply ReplyFunc)

EvalCommand is the callback for the `eval` IRC command. It wraps the passed argument in some boilerplate to make it valid go source, resolves any imports it can, formats it, and executes it on the go playground

func (*Bot) HelpCmd

func (b *Bot) HelpCmd(args string, reply ReplyFunc)

HelpCmd responds with help for commands.

func (*Bot) PlayCmd

func (b *Bot) PlayCmd(args string, reply ReplyFunc)

PlayCmd is the callback for the ~play IRC command, and responds with any errors the playground code has

func (*Bot) PlayRun

func (b *Bot) PlayRun(args string, reply ReplyFunc)

PlayRun runs the given go playground link and responds with either the errors, its the callback for the ~runplay command

func (*Bot) Run

func (b *Bot) Run()

Run connects the bot to IRC, and blocks forever

type BotConfig

type BotConfig struct {
	Nick            string `toml:"nick"`
	User            string `toml:"user"`
	RealName        string `toml:"real_name"`
	VersionResponse string `toml:"-"`
	SASLUser        string `toml:"sasl_user"`
	SASLPassword    string `toml:"sasl_password"`
	CommandPrefix   string `toml:"command_prefix"`

	Server       string   `toml:"server"`
	UseTLS       bool     `toml:"use_tls"`
	JoinChannels []string `toml:"join_channels"`
	Debug        bool     `toml:"debug"`
}

BotConfig represents the config for Bot, and can be unmarshalled directly from toml

type Callback

type Callback func(args string, reply ReplyFunc)

type Command

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

Command represents a single IRC command and its callback.

type ReplyFunc

type ReplyFunc func(string, ...interface{}) error

Jump to

Keyboard shortcuts

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