bot

package module
v0.0.0-...-9648343 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: BSD-3-Clause Imports: 24 Imported by: 0

README

Bot framework

This repository contains a composable bot framework for creating Twitch bots. It also contains a reference framework for a somewhat atypical bot design, based on the idea of separating Twitch connectivity from the actual interactive bot implementation, to make development without direct code reloading faster.

Currently not in a stable state, see the TODO for more information.

Documentation

Overview

Package bot implements a DRY-bot framework, implementing a common base for writing various types of Twitch bots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	RawInputLogger RawInputLogger
	RawMessageHook RawMessageHook
	WS             *webservice.Server

	ConfigPropagation func(id, login string, conf map[string]string) (string, error)

	PartFeedback interface {
		Parted(login string) error
	}

	ChannelManager chanmgr.Executor

	CPool *conpool.Pool

	Commander *Commander
	// contains filtered or unexported fields
}

func New

func New(login, oauth string, verified bool) *Bot

func (*Bot) AddTarget

func (b *Bot) AddTarget(id, login string, conf map[string]string)

func (*Bot) Connected

func (b *Bot) Connected(c *conpool.Con)

func (*Bot) Disconnected

func (b *Bot) Disconnected(c *conpool.Con, err error)

func (*Bot) LoginFromID

func (b *Bot) LoginFromID(id string) string

func (*Bot) Message

func (b *Bot) Message(con *conpool.Con, msg *ircon.Message)

Message handles messages received on a specific connection, which may happen concurrently across multiple connections.

func (*Bot) RemoveTarget

func (b *Bot) RemoveTarget(id, login string)

func (*Bot) RemoveTargetLogin

func (b *Bot) RemoveTargetLogin(login string) error

func (*Bot) Run

func (b *Bot) Run(targets []Target) context.Context

Run starts the bot threads and returns a context that will be closed when the bot should stop running.

func (*Bot) Say

func (b *Bot) Say(login, msg string)

Say publishes a message to the given channel.

func (*Bot) SetLive

func (b *Bot) SetLive(id string, live bool)

func (*Bot) Table

func (b *Bot) Table() *cmdtable.Table

Table returns a command table that can modified during the configuration state to provide static commands.

type Commander

type Commander struct {
	Admins map[string]bool

	CommandHook     func(login string)
	CommandPreHook  func(string, string) string
	CommandPostHook func(string, string) string
	MutateConfHook  func(string, map[string]string) map[string]string
	// contains filtered or unexported fields
}

func NewCommander

func NewCommander(login string) *Commander

func (Commander) Config

func (c Commander) Config()

func (*Commander) Configure

func (c *Commander) Configure(login string, conf map[string]string)

func (Commander) Message

func (c Commander) Message()

func (*Commander) Remove

func (c *Commander) Remove(login string)

func (*Commander) RunningConf

func (c *Commander) RunningConf(login string) chanconf

func (*Commander) SetLive

func (c *Commander) SetLive(id, login string, live bool)

func (*Commander) SyncHighRL

func (c *Commander) SyncHighRL(login string, highrl bool)

func (*Commander) SyncSlowMode

func (c *Commander) SyncSlowMode(login string, slow int)

type RawInputLogger

type RawInputLogger interface {
	LogRawInput(context string, message string)
}

type RawMessageHook

type RawMessageHook interface {
	RawMessage(msg *ircon.Message)
}

type RoomState

type RoomState interface {
	Joined(room string)
	Parted(room string)

	// <ID from room state>
	SlowMode(room string, secs int)
	HighRL(room string, yesno bool)
}

Provides:

type TMI

type TMI struct {
}

func (*TMI) AddRoom

func (tmi *TMI) AddRoom(room string)

Implements:

func (*TMI) RemoveRoom

func (tmi *TMI) RemoveRoom(room string)

type Target

type Target struct {
	Target   string // Twitch username
	TargetID string // Twitch user ID
	Conf     map[string]string
}

Directories

Path Synopsis
Package ctxrl implements context-based rate limiting.
Package ctxrl implements context-based rate limiting.
Package globalrl implements global rate limiting for the Twitch Message Interface.
Package globalrl implements global rate limiting for the Twitch Message Interface.
internal
signal
Package signal contains helpers for common signalling operations.
Package signal contains helpers for common signalling operations.
Package pubsub implements highlivel Twitch PubSub helpers.
Package pubsub implements highlivel Twitch PubSub helpers.
unstable
admincmd
Package admincmd implements standard administrative commands for managing channels and channel configuration.
Package admincmd implements standard administrative commands for managing channels and channel configuration.
argparse
Package argparse implements lidl argument parsing.
Package argparse implements lidl argument parsing.
cmdclient
Package cmdclient implements execution of commands using a remote service.
Package cmdclient implements execution of commands using a remote service.
cmdqueue
Package cmdqueue implements a command queueing and execution management system.
Package cmdqueue implements a command queueing and execution management system.
cmdservice
Package cmdservice implements hosting of command-sets which can be called by clients via an HTTP-based API.
Package cmdservice implements hosting of command-sets which can be called by clients via an HTTP-based API.
cmdtable
Package cmdtable implements tools to look up messages in a table.
Package cmdtable implements tools to look up messages in a table.
conpool
Package conpool implements connection pooling based on assigning a context (typically, a channel) to a specific connection.
Package conpool implements connection pooling based on assigning a context (typically, a channel) to a specific connection.
gql
ipc
Package ipc describes an IPC request/response protocol for communicating chat commands and chat response messages.
Package ipc describes an IPC request/response protocol for communicating chat commands and chat response messages.
joinmgr
Package joinmgr implements channel JOIN management in an environment with connection pooling and a global rate-limit in JOIN commands.
Package joinmgr implements channel JOIN management in an environment with connection pooling and a global rate-limit in JOIN commands.
log
Package log implements a convenient wrapper for zerolog.
Package log implements a convenient wrapper for zerolog.
paramhelper
Package paramhelper helps parse input as pseudo-YAML, which allows for flexible handling of e.g.
Package paramhelper helps parse input as pseudo-YAML, which allows for flexible handling of e.g.
partyline
Package partyline implements Redis-based communication of command-sets for command-set hosts and their clients.
Package partyline implements Redis-based communication of command-sets for command-set hosts and their clients.
s3
webservice
Package webservice implements an API server that works with HTTP requests in JSON and form-request format.
Package webservice implements an API server that works with HTTP requests in JSON and form-request format.

Jump to

Keyboard shortcuts

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