bot

package
v0.0.0-...-162a0df Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Profile
	Start Time

	State *State
	Login *Login

	Tasks *Tasks
	// contains filtered or unexported fields
}

func NewBot

func NewBot(ctx context.Context, p Profile) (_ *Bot, err error)

func (*Bot) AddStage

func (b *Bot) AddStage(s Stage)

func (*Bot) Close

func (b *Bot) Close()

func (*Bot) Ctx

func (b *Bot) Ctx() context.Context

func (*Bot) RLock

func (b *Bot) RLock()

func (*Bot) RUnlock

func (b *Bot) RUnlock()

func (*Bot) RxMsgs

func (b *Bot) RxMsgs() uint64

func (*Bot) TeeMsg

func (b *Bot) TeeMsg() *TeeMsgConn

func (*Bot) TxMsgs

func (b *Bot) TxMsgs() uint64

func (*Bot) Update

func (b *Bot) Update(p Profile) error

func (*Bot) Write

func (b *Bot) Write(tid TaskId, msg irc.Message) error

type Cmd

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

func NewCmd

func NewCmd(ctx context.Context, cmdname string, args []string, env []string) (*Cmd, error)

func (*Cmd) Close

func (c *Cmd) Close() error

func (*Cmd) Lines

func (c *Cmd) Lines() <-chan string

type Dispatcher

type Dispatcher struct {
	*Tasks
	*Profile
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(p *Profile, t *Tasks) *Dispatcher

func (*Dispatcher) Env

func (d *Dispatcher) Env() []string

func (*Dispatcher) Process

func (d *Dispatcher) Process(msg irc.Message) error

func (*Dispatcher) Update

func (d *Dispatcher) Update(pats, rawpats []Pattern) error

type Gang

type Gang struct {
	Bots map[string]*Bot
	// contains filtered or unexported fields
}

func NewGang

func NewGang() *Gang

func (*Gang) Delete

func (g *Gang) Delete(id string) error

func (*Gang) LockBots

func (g *Gang) LockBots()

func (*Gang) Lookup

func (g *Gang) Lookup(id string) *Bot

func (*Gang) Post

func (g *Gang) Post(p Profile) error

func (*Gang) UnlockBots

func (g *Gang) UnlockBots()

type Log

type Log struct {
	Stage
}

func (*Log) Process

func (l *Log) Process(msg irc.Message) error

type Login

type Login struct {
	*ProfileLogin
	Netpfx *irc.Prefix
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin(p *ProfileLogin, t *Tasks) *Login

func (*Login) Process

func (l *Login) Process(msg irc.Message) error

func (*Login) Run

func (l *Login) Run() error

func (*Login) Welcome

func (l *Login) Welcome() <-chan struct{}

type MsgConn

type MsgConn struct {
	*irc.Conn
	MsgConnStats
	// contains filtered or unexported fields
}

func NewMsgConn

func NewMsgConn(ctx context.Context, conn net.Conn, invl time.Duration) (*MsgConn, error)

func (*MsgConn) Close

func (mc *MsgConn) Close() error

func (*MsgConn) ReadChan

func (mc *MsgConn) ReadChan() <-chan irc.Message

func (*MsgConn) WriteMsg

func (mc *MsgConn) WriteMsg(m irc.Message) error

type MsgConnStats

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

func (*MsgConnStats) RxMsgs

func (m *MsgConnStats) RxMsgs() uint64

func (*MsgConnStats) TxMsgs

func (m *MsgConnStats) TxMsgs() uint64

type Pattern

type Pattern struct {
	Match    string
	Template string
}

type PatternMatcher

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

func NewPatternMatcher

func NewPatternMatcher(pats []Pattern) (*PatternMatcher, error)

func (*PatternMatcher) Apply

func (pm *PatternMatcher) Apply(txt string) string

type Profile

type Profile struct {
	ProfileLogin
	Chans     []string
	RateMs    int
	Verbosity int

	// Id is the way to reference this bot.
	Id          string
	Patterns    []Pattern
	PatternsRaw []Pattern
}

func DecodeProfiles

func DecodeProfiles(r io.Reader) (ret []*Profile, err error)

func UnmarshalProfile

func UnmarshalProfile(b []byte) (*Profile, error)

func (*Profile) Dial

func (p *Profile) Dial(ctx context.Context) (c net.Conn, err error)

type ProfileLogin

type ProfileLogin struct {
	ServerURL string
	ProxyURL  string `json:",omitempty"`
	Nick      string
	User      string
	Pass      string `json:",omitempty"`
}

type Stage

type Stage interface {
	Process(msg irc.Message) error
}

type State

type State struct {
	Channels map[string]*room
	Users    map[string]*user
	sync.RWMutex
}

func NewState

func NewState() *State

func (*State) Process

func (s *State) Process(msg irc.Message) error

type Task

type Task struct {
	Name    string
	Start   Time
	Command string
	// contains filtered or unexported fields
}

func (*Task) Lines

func (t *Task) Lines() uint32

func (*Task) PipeCmd

func (t *Task) PipeCmd(cmdtxt, tgt string, env []string) (err error)

func (*Task) Write

func (t *Task) Write(msg irc.Message) error

type TaskFunc

type TaskFunc func(*Task) error

type TaskId

type TaskId uint64

type Tasks

type Tasks struct {
	Tasks map[TaskId]*Task
	// contains filtered or unexported fields
}

func NewTasks

func NewTasks(ctx context.Context, l *rate.Limiter, mc *MsgConn) *Tasks

func (*Tasks) Close

func (t *Tasks) Close()

func (*Tasks) Kill

func (t *Tasks) Kill(tid TaskId) error

func (*Tasks) Run

func (t *Tasks) Run(name, cmdtxt string, f TaskFunc)

Run puts a command in the task list and schedules it to run.

func (*Tasks) Write

func (t *Tasks) Write(tid TaskId, msg irc.Message) error

type TeeMsgConn

type TeeMsgConn struct {
	*MsgConn
	// contains filtered or unexported fields
}

func NewTeeMsgConn

func NewTeeMsgConn(ctx context.Context, conn net.Conn, ms int) (*TeeMsgConn, error)

func (*TeeMsgConn) DropReadChan

func (mc *TeeMsgConn) DropReadChan(rc <-chan irc.Message)

func (*TeeMsgConn) NewReadChan

func (tmc *TeeMsgConn) NewReadChan() (<-chan irc.Message, chan<- struct{})

type Time

type Time time.Time

func (Time) Elapsed

func (t Time) Elapsed() time.Duration

func (Time) T

func (t Time) T() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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