capi

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MPL-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSayBufferFull = errors.New("gw-capi: Say buffer full")
)

Errors

Functions

This section is empty.

Types

type Config

type Config struct {
	GatewayConfig
	chat.Config
}

Config stores the configuration of a single CAPI connection

type Gateway

type Gateway struct {
	gateway.Common
	*chat.Bot

	// Set once before Run(), read-only after that
	*GatewayConfig
	// contains filtered or unexported fields
}

Gateway manages a CAPI connection

func New

func New(conf *Config) (*Gateway, error)

New initializes a new Gateway struct

func (*Gateway) Ban

func (b *Gateway) Ban(uid string) error

Ban user from channel

func (*Gateway) Channel

func (b *Gateway) Channel() *gateway.Channel

Channel residing in

func (*Gateway) ChannelUsers

func (b *Gateway) ChannelUsers() []gateway.User

ChannelUsers online

func (*Gateway) FindTrigger

func (b *Gateway) FindTrigger(s string) *gateway.Trigger

FindTrigger checks if s starts with trigger, return Trigger{} if true

func (*Gateway) InitDefaultHandlers

func (b *Gateway) InitDefaultHandlers()

InitDefaultHandlers adds the default callbacks for relevant packets

func (*Gateway) Kick

func (b *Gateway) Kick(uid string) error

Kick user from channel

func (*Gateway) Operator

func (b *Gateway) Operator() bool

Operator in chat

func (*Gateway) Ping

func (b *Gateway) Ping(uid string) (time.Duration, error)

Ping user to calculate RTT in milliseconds

func (*Gateway) Relay

func (b *Gateway) Relay(ev *network.Event, from gateway.Gateway) error

Relay dumps the event content in current channel

func (*Gateway) Run

func (b *Gateway) Run(ctx context.Context) error

Run reads packets and emits an event for each received packet

func (*Gateway) Say

func (b *Gateway) Say(s string) error

Say sends a chat message

func (*Gateway) SayPrivate

func (b *Gateway) SayPrivate(uid string, s string) error

SayPrivate sends a private chat message to uid

func (*Gateway) SetUserAccess

func (b *Gateway) SetUserAccess(uid string, a gateway.AccessLevel) (*gateway.AccessLevel, error)

SetUserAccess overrides accesslevel for a specific user

func (*Gateway) Unban

func (b *Gateway) Unban(uid string) error

Unban user from channel

func (*Gateway) User

func (b *Gateway) User(uid string) (*gateway.User, error)

User by ID

func (*Gateway) Users

func (b *Gateway) Users() map[string]gateway.AccessLevel

Users with non-default access level

type GatewayConfig

type GatewayConfig struct {
	gateway.Config

	ReconnectDelay   time.Duration
	BufSize          uint8
	AvatarDefaultURL string

	AccessWhisper  gateway.AccessLevel
	AccessTalk     gateway.AccessLevel
	AccessOperator gateway.AccessLevel
	AccessUser     map[string]gateway.AccessLevel
}

GatewayConfig stores the config additions of capi.Gateway over chat.Bot

Jump to

Keyboard shortcuts

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