bnet

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-bnet: Say buffer full")
	ErrSayCommand    = errors.New("gw-bnet: Say prevented execution of command")
)

Errors

Functions

This section is empty.

Types

type Config

type Config struct {
	GatewayConfig
	bnet.Config
}

Config stores the configuration of a single BNet server

type Gateway

type Gateway struct {
	gateway.Common
	*bnet.Client

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

Gateway manages a BNet connection

func New

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

New initializes a new Gateway struct

func (*Gateway) Ban added in v0.9.0

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

Ban user from channel

func (*Gateway) Channel added in v0.9.0

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

Channel residing in

func (*Gateway) ChannelUsers added in v0.9.0

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

ChannelUsers online

func (*Gateway) FindTrigger added in v0.9.0

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 added in v0.9.0

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

Kick user from channel

func (*Gateway) Operator added in v0.9.0

func (b *Gateway) Operator() bool

Operator in chat

func (*Gateway) Ping added in v0.9.0

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 added in v0.9.0

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

SayPrivate sends a private chat message to uid

func (*Gateway) SetUserAccess added in v0.9.0

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

SetUserAccess overrides accesslevel for a specific user

func (*Gateway) Unban added in v0.9.0

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

Unban user from channel

func (*Gateway) User added in v0.9.0

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

User by ID

func (*Gateway) Users added in v0.9.0

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

Users with non-default access level

type GatewayConfig

type GatewayConfig struct {
	gateway.Config

	ReconnectDelay   time.Duration
	HomeChannel      string
	BufSize          uint8
	AvatarIconURL    string
	AvatarDefaultURL string

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

GatewayConfig stores the config additions of bnet.Gateway over bnet.Client

Jump to

Keyboard shortcuts

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