twitchchat

package
v0.0.0-...-c315c21 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketClosed = fmt.Errorf("Error: Sink Closed")
View Source
var MessageCommandLookup = map[string]MessageCommand{
	"CLEARCHAT":       CLEARCHAT,
	"CLEARMSG":        CLEARMSG,
	"GLOBALUSERSTATE": GLOBALUSERSTATE,
	"HOSTTARGET":      HOSTTARGET,
	"JOIN":            JOIN,
	"NOTICE":          NOTICE,
	"PART":            PART,
	"PING":            PING,
	"PRIVMSG":         PRIVMSG,
	"RECONNECT":       RECONNECT,
	"ROOMSTATE":       ROOMSTATE,
	"USERNOTICE":      USERNOTICE,
	"USERSTATE":       USERSTATE,
}

Functions

This section is empty.

Types

type Bucket

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

Bucket controls the flow of events into the sink

func NewBucket

func NewBucket(emitter Emitter, tokenRate rate.Limit, burstLimit int) *Bucket

Makes a new bucket that can be filled with events. Events are dripped at the passed in rate with given burstLimit. To have no rate limit, rate.Inf should be passed in

func (*Bucket) AddEvent

func (bucket *Bucket) AddEvent(event Event, highPriority bool) error

Add event into bucket. If it's high priority the event will be pushed to the front of the list

func (*Bucket) Close

func (bucket *Bucket) Close() error

type ClearChat

type ClearChat struct {
	RawIrcMessage
	BanDuration uint
	Channel     string
	User        string
}

type ClearMsg

type ClearMsg struct {
	RawIrcMessage
	Channel     string
	Login       string
	Message     string
	TargetMsgId string
}

type Emitter

type Emitter interface {
	// Emit event
	Emit(event Event) error

	OnError(err error)

	Close() error
}

Emitter accepts and emits events

type Event

type Event interface{}

inspiration from github.com/Docker/go-events

type GlobalUserState

type GlobalUserState struct {
	RawIrcMessage
	BadgeInfo   string
	Badges      string
	Color       string
	DisplayName string
	EmoteSets   string
	Turbo       string
	UserId      string
	UserType    string
}

type HostTarget

type HostTarget struct {
	RawIrcMessage
	Channel         string
	NumberOfViewers uint
	TargetChannel   string
}

type Irc

type Irc struct {
	OutChan chan<- IrcMessage
	// contains filtered or unexported fields
}

func NewIrc

func NewIrc() (*Irc, error)

func (*Irc) CapReq

func (irc *Irc) CapReq(req string) error

func (*Irc) Connect

func (irc *Irc) Connect(user string, pass string, tags bool, outChan chan<- IrcMessage) error

func (*Irc) Disconnect

func (irc *Irc) Disconnect() error

func (*Irc) Join

func (irc *Irc) Join(channel string) error

func (*Irc) Part

func (irc *Irc) Part(channel string) error

func (*Irc) Pong

func (irc *Irc) Pong(server string) error

func (*Irc) Privmsg

func (irc *Irc) Privmsg(channel, msg string) error

type IrcMessage

type IrcMessage interface{}

Empty interface for handling IRC messages

type Join

type Join struct {
	RawIrcMessage
	Channel string
}

type MessageCommand

type MessageCommand int
const (
	UNKNOWN MessageCommand = iota
	CLEARCHAT
	CLEARMSG
	GLOBALUSERSTATE
	HOSTTARGET
	JOIN
	NOTICE
	PART
	PING
	PRIVMSG
	RECONNECT
	ROOMSTATE
	USERNOTICE
	USERSTATE
)

type Notice

type Notice struct {
	RawIrcMessage
	Channel string
	Message string
	MsgId   string
}

type Options

type Options struct {
	Nick       string
	Pass       string
	ChatLimit  int // Defaults to 20
	JoinLimit  int // Defaults to 20
	AuthLimit  int // Defaults to 20
	EnableTags bool
}

type Part

type Part struct {
	RawIrcMessage
	Channel string
}

type Ping

type Ping struct {
	RawIrcMessage
	Servers []string
}

type PrivMsg

type PrivMsg struct {
	RawIrcMessage
	BadgeInfo   string
	Badges      string
	Bits        string
	Channel     string
	Color       string
	DisplayName string
	Emotes      string
	Id          string
	Message     string
	Mod         string
	RoomId      string
	Subscriber  string
	TmiSentTs   string
	Turbo       string
	UserId      string
	UserType    string
}

type RawIrcMessage

type RawIrcMessage struct {
	RawMessage []byte
	RawTags    map[string]string

	RawCommand MessageCommand
	RawParams  [][]byte
	// contains filtered or unexported fields
}

type Reconnect

type Reconnect struct {
	RawIrcMessage
}

type RoomState

type RoomState struct {
	RawIrcMessage
	Channel       string
	EmoteOnly     bool
	FollowersOnly int
	R9K           bool
	Slow          uint
	SubsOnly      bool
}

type TwitchChat

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

func NewTwitchChat

func NewTwitchChat(options *Options) (*TwitchChat, error)

func (*TwitchChat) Chat

func (tc *TwitchChat) Chat(channel, msg string) error

func (*TwitchChat) Connect

func (tc *TwitchChat) Connect() error

func (*TwitchChat) Disconnect

func (tc *TwitchChat) Disconnect() error

func (*TwitchChat) Join

func (tc *TwitchChat) Join(channel string) error

func (*TwitchChat) Part

func (tc *TwitchChat) Part(channel string) error

func (*TwitchChat) Pong

func (tc *TwitchChat) Pong(ping *Ping)

func (*TwitchChat) RegisterCallback

func (tc *TwitchChat) RegisterCallback(cb interface{}) error

type UserNotice

type UserNotice struct {
	RawIrcMessage
	BadgeInfo   string
	Badges      string
	Channel     string
	Color       string
	DisplayName string
	Emotes      string
	Id          string
	Login       string
	Message     string
	Mod         string
	MsgId       string
	RoomId      string
	Subscriber  bool
	SystemMsg   string
	TmiSentTs   string
	Turbo       string
	UserId      string
	UserType    string
}

type UserState

type UserState struct {
	RawIrcMessage
	BadgeInfo   string
	Badges      string
	Channel     string
	Color       string
	DisplayName string
	EmoteSets   string
	Mod         string
	Subscriber  bool
	Turbo       string
	UserType    string
}

Jump to

Keyboard shortcuts

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