bot

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

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

Go to latest
Published: Aug 18, 2022 License: BSD-3-Clause Imports: 21 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 {
	RunningID      int64
	ConfigCounter  int64
	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
	Commander      *commander.Commander
	Output         *output.Output
	// 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 (t Bot) Connected(c *conpool.Con)

func (Bot) Disconnected

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

func (*Bot) ETag

func (b *Bot) ETag() string

func (*Bot) ExternalSay

func (b *Bot) ExternalSay(login string, frags []string, cmd bool, bp string) bool

func (*Bot) ExternalSayID

func (b *Bot) ExternalSayID(id string, frags []string, cmd bool, bp string) bool

func (*Bot) IDFromLogin

func (b *Bot) IDFromLogin(login string) string

func (*Bot) LoginFromID

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

func (*Bot) Message

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

func (*Bot) RemoveTarget

func (b *Bot) RemoveTarget(id, 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 outputs a message to the given channel.

func (Bot) SendInContext

func (t Bot) SendInContext(login, rawmsg string) bool

func (*Bot) SendRaw

func (b *Bot) SendRaw(raw string)

func (*Bot) SetLive

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

func (*Bot) SetTargetConfig

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

func (*Bot) Stream

func (b *Bot) Stream(ctx context.Context, login string, wr webservice.WebWriter) error

func (*Bot) TargetConfig

func (b *Bot) TargetConfig(login string) map[string]string

func (*Bot) Targets

func (b *Bot) Targets() (string, []Target)

type RawInputLogger

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

type RawMessageHook

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

type ServiceImpl

type ServiceImpl interface {
	IDFromLogin(login string) string
	SendRaw(raw string)
	ExternalSay(login string, frags []string, command bool, bp string) bool
	ExternalSayID(id string, frags []string, command bool, bp string) bool

	RemoveTarget(id, login string) error
	SetTargetConfig(id, login string, config map[string]string) (string, error)
	TargetConfig(login string) map[string]string
	Targets() (string, []Target)

	Stream(ctx context.Context, login string, wr webservice.WebWriter) error
}

type Target

type Target struct {
	Target   string            `json:"login"` // Twitch username
	TargetID string            `json:"id"`    // Twitch user ID
	Conf     map[string]string `json:"conf"`
}

Directories

Path Synopsis
Package ctxrl implements context-based rate limiting.
Package ctxrl implements context-based rate limiting.
examples
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 highlevel Twitch PubSub helpers.
Package pubsub implements highlevel 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.
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 chat commands in a table.
Package cmdtable implements tools to look up chat commands 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.
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