tmi

package
v4.0.0-...-ac11496 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StandardCommandCallbacks = map[string]CommandCallback{
	"001": IgnoreCommand,
	"002": IgnoreCommand,
	"003": IgnoreCommand,
	"004": IgnoreCommand,
	"005": IgnoreCommand,
	"353": IgnoreCommand,
	"366": IgnoreCommand,
	"372": IgnoreCommand,
	"375": IgnoreCommand,
	"376": IgnoreCommand,

	"CAP":        IgnoreCommand,
	"JOIN":       IgnoreCommand,
	"PART":       IgnoreCommand,
	"ROOMSTATE":  IgnoreCommand,
	"NOTICE":     IgnoreCommand,
	"USERNOTICE": IgnoreCommand,
	"CLEARCHAT":  IgnoreCommand,

	"PING": func(client *Client, message *Message) error {
		_, err := client.Send(&Message{
			Command:   "PONG",
			Arguments: message.Arguments,
		})

		return err
	},

	"RECONNECT": func(client *Client, _ *Message) error {
		_, err := client.Send(&Message{Command: "QUIT"})

		return err
	},
}

Functions

func IgnoreCommand

func IgnoreCommand(_ *Client, _ *Message) error

Types

type Client

type Client struct {
	Username          string
	Token             string
	Connection        *tls.Conn
	Reader            *bufio.Reader
	Channels          map[string]int
	ChannelsMutex     sync.Mutex
	CommandCallbacks  map[string]CommandCallback
	ReconnectAttempts int
}

func NewAnonClient

func NewAnonClient() *Client

func (*Client) Backoff

func (client *Client) Backoff()

func (*Client) Connect

func (client *Client) Connect() error

func (*Client) Forever

func (client *Client) Forever()

func (*Client) Join

func (client *Client) Join(channel string) error

func (*Client) Loop

func (client *Client) Loop() error

func (*Client) Part

func (client *Client) Part(channel string) error

func (*Client) Receive

func (client *Client) Receive() (*Message, error)

func (*Client) Send

func (client *Client) Send(message *Message) (int, error)

func (*Client) SendRegistration

func (client *Client) SendRegistration() error

type CommandCallback

type CommandCallback func(client *Client, message *Message) error

type Message

type Message struct {
	Badges  map[string]int
	Channel string
	Message string

	Tags      map[string]string
	Source    string
	Command   string
	Arguments []string
}

func ParseMessage

func ParseMessage(stringMessage string) (*Message, error)

func (*Message) Bytes

func (message *Message) Bytes() []byte

func (*Message) IsBroadcaster

func (message *Message) IsBroadcaster() bool

func (*Message) IsModerator

func (message *Message) IsModerator() bool

func (*Message) IsModeratorOrBroadcaster

func (message *Message) IsModeratorOrBroadcaster() bool

func (*Message) String

func (message *Message) String() string

Jump to

Keyboard shortcuts

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