twitch

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AverageMessageWindow = 5
View Source
const BotAlertsKey = "twitch/bot-modules/alerts/config"
View Source
const BotConfigKey = "twitch/bot-config"
View Source
const BotCounterPrefix = "twitch/bot-counters/"
View Source
const BotTimersKey = "twitch/bot-modules/timers/config"
View Source
const ChatEventKey = "twitch/ev/chat-message"
View Source
const ChatHistoryKey = "twitch/chat-history"
View Source
const ConfigKey = "twitch/config"
View Source
const CustomCommandsKey = "twitch/bot-custom-commands"
View Source
const WriteMessageRPC = "twitch/@send-chat-message"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLevelType

type AccessLevelType string
const (
	ALTEveryone    AccessLevelType = "everyone"
	ALTSubscribers AccessLevelType = "subscriber"
	ALTVIP         AccessLevelType = "vip"
	ALTModerators  AccessLevelType = "moderators"
	ALTStreamer    AccessLevelType = "streamer"
)

type Bot

type Bot struct {
	Client *irc.Client

	// Module specific vars
	Loyalty *loyalty.Manager
	Timers  *BotTimerModule
	Alerts  *BotAlertsModule
	// contains filtered or unexported fields
}

func NewBot

func NewBot(api *Client, config BotConfig) *Bot

func (*Bot) Connect

func (b *Bot) Connect() error

func (*Bot) IsActive

func (b *Bot) IsActive(user string) bool

func (*Bot) IsBanned

func (b *Bot) IsBanned(user string) bool

func (*Bot) LoadModules added in v1.5.2

func (b *Bot) LoadModules() error

func (*Bot) ResetActivity

func (b *Bot) ResetActivity()

func (*Bot) SetBanList

func (b *Bot) SetBanList(banned []string)

func (*Bot) SetupLoyalty

func (b *Bot) SetupLoyalty(loyalty *loyalty.Manager)

func (*Bot) WriteMessage added in v1.5.2

func (b *Bot) WriteMessage(message string)

type BotAlertsConfig added in v1.7.0

type BotAlertsConfig struct {
	Follow struct {
		Enabled  bool     `json:"enabled"`
		Messages []string `json:"messages"`
	} `json:"follow"`
	Subscription struct {
		Enabled    bool     `json:"enabled"`
		Messages   []string `json:"messages"`
		Variations []struct {
			MinStreak *int     `json:"min_streak,omitempty"`
			IsGifted  *bool    `json:"is_gifted,omitempty"`
			Messages  []string `json:"messages"`
		} `json:"variations"`
	} `json:"subscription"`
	GiftSub struct {
		Enabled    bool     `json:"enabled"`
		Messages   []string `json:"messages"`
		Variations []struct {
			MinCumulative *int     `json:"min_cumulative,omitempty"`
			IsAnonymous   *bool    `json:"is_anonymous,omitempty"`
			Messages      []string `json:"messages"`
		} `json:"variations"`
	} `json:"gift_sub"`
	Raid struct {
		Enabled    bool     `json:"enabled"`
		Messages   []string `json:"messages"`
		Variations []struct {
			MinViewers *int     `json:"min_viewers,omitempty"`
			Messages   []string `json:"messages"`
		} `json:"variations"`
	} `json:"raid"`
	Cheer struct {
		Enabled    bool     `json:"enabled"`
		Messages   []string `json:"messages"`
		Variations []struct {
			MinAmount *int     `json:"min_amount,omitempty"`
			Messages  []string `json:"messages"`
		} `json:"variations"`
	} `json:"cheer"`
}

type BotAlertsModule added in v1.7.0

type BotAlertsModule struct {
	Config BotAlertsConfig
	// contains filtered or unexported fields
}

func SetupAlerts added in v1.7.0

func SetupAlerts(bot *Bot) *BotAlertsModule

type BotCommand

type BotCommand struct {
	Description string
	Usage       string
	AccessLevel AccessLevelType
	Handler     BotCommandHandler
	Enabled     bool
}

type BotCommandHandler

type BotCommandHandler func(bot *Bot, message irc.PrivateMessage)

type BotConfig

type BotConfig struct {
	Username       string `json:"username"`
	Token          string `json:"oauth"`
	Channel        string `json:"channel"`
	EnableChatKeys bool   `json:"chat_keys"`
	ChatHistory    int    `json:"chat_history"`
}

type BotCustomCommand added in v1.5.0

type BotCustomCommand struct {
	Description string          `json:"description"`
	AccessLevel AccessLevelType `json:"access_level"`
	Response    string          `json:"response"`
	Enabled     bool            `json:"enabled"`
}

type BotTimer added in v1.5.2

type BotTimer struct {
	Enabled             bool     `json:"enabled"`               // Whether the timer is enabled
	Name                string   `json:"name"`                  // Timer name (must be unique)
	MinimumChatActivity int      `json:"minimum_chat_activity"` // Minimum chat messages in the last 5 minutes
	MinimumDelay        int      `json:"minimum_delay"`         // In seconds
	Messages            []string `json:"messages"`              // Messages to write (randomly chosen)
}

type BotTimerModule added in v1.5.2

type BotTimerModule struct {
	Config BotTimersConfig
	// contains filtered or unexported fields
}

func SetupTimers added in v1.5.2

func SetupTimers(bot *Bot) *BotTimerModule

func (*BotTimerModule) OnMessage added in v1.5.2

func (m *BotTimerModule) OnMessage(message irc.PrivateMessage)

type BotTimersConfig added in v1.5.2

type BotTimersConfig struct {
	Timers map[string]BotTimer `json:"timers"`
}

type Client

type Client struct {
	Bot *Bot

	API *helix.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(manager *modules.Manager) (*Client, error)

func (*Client) Close added in v1.6.1

func (c *Client) Close() error

func (*Client) RunBot added in v1.6.1

func (c *Client) RunBot() error

type Config

type Config struct {
	EnableBot       bool   `json:"enable_bot"`
	APIClientID     string `json:"api_client_id"`
	APIClientSecret string `json:"api_client_secret"`
}

Jump to

Keyboard shortcuts

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