chat

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package chat implements the official classic Battle.net chat API.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedPacket = errors.New("chat: Received unexpected packet")
)

Errors

Functions

This section is empty.

Types

type Bot

type Bot struct {
	network.EventEmitter
	network.CAPIConn

	// Set once before Connect(), read-only after that
	Config
	// contains filtered or unexported fields
}

Bot implements a basic chat bot using the official classic Battle.net chat API Public methods/fields are thread-safe unless explicitly stated otherwise

func NewBot

func NewBot(conf *Config) (*Bot, error)

NewBot initializes a Bot struct

func (*Bot) BanUser

func (b *Bot) BanUser(uid int64) error

BanUser bans a user from the channel

func (*Bot) Channel

func (b *Bot) Channel() string

Channel currently chatting in

func (*Bot) Connect

func (b *Bot) Connect() error

Connect opens a new connection to server and joins chat

func (*Bot) InitDefaultHandlers

func (b *Bot) InitDefaultHandlers()

InitDefaultHandlers adds the default callbacks for relevant packets

func (*Bot) KickUser

func (b *Bot) KickUser(uid int64) error

KickUser kicks a user from the channel

func (*Bot) RPC

func (b *Bot) RPC(command string, arg ...interface{}) (interface{}, error)

RPC executes Remote Procedure Call cmd asynchronously, retries on timeout/rate-limit Needs to called in a goroutine while Run() is running asynchronously to process incoming packets

func (*Bot) Run

func (b *Bot) Run() error

Run reads packets and emits an event for each received packet Not safe for concurrent invocation

func (*Bot) SendEmote

func (b *Bot) SendEmote(s string) error

SendEmote sends an emote on behalf of a bot

func (*Bot) SendMessage

func (b *Bot) SendMessage(s string) error

SendMessage sends a chat message to the channel

func (*Bot) SendWhisper

func (b *Bot) SendWhisper(uid int64, s string) error

SendWhisper sends a chat message to one user in the channel

func (*Bot) SetModerator

func (b *Bot) SetModerator(uid int64) error

SetModerator sets the current chat moderator to a member of the current chat

func (*Bot) UnbanUser

func (b *Bot) UnbanUser(username string) error

UnbanUser un-bans a user from the channel

func (*Bot) User

func (b *Bot) User(uid int64) (*User, bool)

User in channel by id

func (*Bot) Users

func (b *Bot) Users() map[int64]User

Users in channel

type Config

type Config struct {
	Endpoint   string
	APIKey     string
	RPCTimeout time.Duration
}

Config for chat.Bot

type User

type User struct {
	capi.UserUpdateEvent
	Joined   time.Time
	LastSeen time.Time
}

User in chat

func (*User) Operator

func (u *User) Operator() bool

Operator in channel

Jump to

Keyboard shortcuts

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