twitchbot

package module
v0.0.0-...-090371d Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

twitchbot

Go Twitch Bot Api wrapper, with an easy to use interface.

Example

package main

import (
	"github.com/witer33/twitchbot"
)

func main() {
	bot := twitchbot.NewBot("oauth:abcdef", "mybot", []string{"channel"})

	bot.OnMessage(func(bot *twitchbot.Bot, message *twitchbot.Message) {
		if message.Message == "!ping" {
			message.Reply("pong")
			message.Delete()
		}
	})

	bot.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadString

func ReadString(reader *strings.Reader, until byte) string

func ReadTags

func ReadTags(reader *strings.Reader) map[string]string

Types

type Bot

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

func NewBot

func NewBot(token string, nick string, channels []string) *Bot

func (*Bot) BanUser

func (bot *Bot) BanUser(channel string, user string) error

func (*Bot) DeleteMessage

func (bot *Bot) DeleteMessage(message *Message) error

func (*Bot) GetClient

func (bot *Bot) GetClient() *Client

func (*Bot) Join

func (bot *Bot) Join(channel string) error

func (*Bot) OnLogin

func (bot *Bot) OnLogin(f func(*Bot))

func (*Bot) OnMessage

func (bot *Bot) OnMessage(f func(*Bot, *Message))

func (*Bot) Run

func (bot *Bot) Run()

func (*Bot) SendMessage

func (bot *Bot) SendMessage(message *Message) error

func (*Bot) Start

func (bot *Bot) Start() error

type Client

type Client struct {
	Token string
	Nick  string
	// contains filtered or unexported fields
}

func (*Client) AddHandler

func (client *Client) AddHandler(command string, f func(*Command) bool)

func (*Client) Auth

func (client *Client) Auth() error

func (*Client) CapReq

func (client *Client) CapReq(cap string) error

func (*Client) Close

func (client *Client) Close()

func (*Client) Connect

func (client *Client) Connect(host string) error

func (*Client) Handle

func (client *Client) Handle() error

func (*Client) Join

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

func (*Client) Send

func (client *Client) Send(command *Command) error

type Command

type Command struct {
	Tags    map[string]string
	Prefix  string
	Command string
	Args    []string
	Suffix  string
}

func ParsePacket

func ParsePacket(packet string) *Command

func (*Command) Build

func (c *Command) Build() string

func (*Command) String

func (c *Command) String() string

type EventHandler

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

type Message

type Message struct {
	ID      string
	Channel string
	User    *User
	Message string
	Bot     *Bot
}

func ParseMessage

func ParseMessage(command *Command, bot *Bot) *Message

func (*Message) Ban

func (message *Message) Ban() error

func (*Message) Delete

func (message *Message) Delete() error

func (*Message) Reply

func (message *Message) Reply(msg string) error

type User

type User struct {
	ID   string
	Name string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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