twitch

package
v0.0.0-...-14cf17c Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeUnset = iota
	ModeEnabled
	ModeDisabled
)
View Source
const (
	CommandConnect   = 0x01
	CommandGetPoints = 0x02
	CommandBulkEdit  = 0x03
	CommandAdd       = 0x04
	CommandRemove    = 0x05
	CommandRank      = 0x06
)
View Source
const DELIMETER_BYTE = ';'

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
}

type Bot

type Bot struct {
	*twitch.Client

	DatabaseID int

	QuitChannel chan string

	Flags botFlags

	IsConnected bool
	// contains filtered or unexported fields
}

Bot is a wrapper around go-twitch-irc's twitch.Client with a few extra features

func NewBot

func NewBot(databaseID int, twitchAccount pkg.TwitchAccount, tokenSource oauth2.TokenSource, token *oauth2.Token, helixClient *apirequest.HelixWrapper, app pkg.Application) (*Bot, error)

func (*Bot) AddPoints

func (b *Bot) AddPoints(channel pkg.Channel, userID string, points uint64) (bool, uint64)

func (*Bot) Application

func (b *Bot) Application() pkg.Application

func (*Bot) AuthenticatedUser

func (b *Bot) AuthenticatedUser() pkg.User

func (*Bot) Ban

func (b *Bot) Ban(channel pkg.Channel, user pkg.User, reason string)

func (*Bot) BulkEdit

func (b *Bot) BulkEdit(channel string, userIDs []string, points int32)

func (*Bot) ChannelIDs

func (b *Bot) ChannelIDs() (channelIDs []string)

func (*Bot) ConnectToPointServer

func (b *Bot) ConnectToPointServer() (err error)

func (*Bot) Connected

func (b *Bot) Connected() bool

func (*Bot) Connection

func (b *Bot) Connection() pkg.PubSubConnection

func (*Bot) DeleteMessage

func (b *Bot) DeleteMessage(channel pkg.Channel, message string)

func (*Bot) Disconnect

func (b *Bot) Disconnect()

Disconnect function should only ever be used for development purposes

func (*Bot) FetchDatabaseID

func (b *Bot) FetchDatabaseID() int

func (*Bot) ForceRemovePoints

func (b *Bot) ForceRemovePoints(channel pkg.Channel, userID string, points uint64) uint64

func (*Bot) GetAccessToken

func (b *Bot) GetAccessToken() (string, error)

func (*Bot) GetBotChannel

func (b *Bot) GetBotChannel(channelName string) pkg.BotChannel

func (*Bot) GetBotChannelByID

func (b *Bot) GetBotChannelByID(channelID string) pkg.BotChannel

func (*Bot) GetPoints

func (b *Bot) GetPoints(channel pkg.Channel, userID string) uint64

func (*Bot) GetTokenSource

func (b *Bot) GetTokenSource() oauth2.TokenSource

func (*Bot) GetUserContext

func (b *Bot) GetUserContext() pkg.UserContext

func (*Bot) GetUserStore

func (b *Bot) GetUserStore() pkg.UserStore

func (*Bot) HandleClearChatMessage

func (b *Bot) HandleClearChatMessage(message *twitch.ClearChatMessage)

func (*Bot) HandleMessage

func (b *Bot) HandleMessage(channelName string, user twitch.User, rawMessage *twitch.PrivateMessage)

func (*Bot) HandleRoomstateMessage

func (b *Bot) HandleRoomstateMessage(message twitch.RoomStateMessage)

func (*Bot) HandleWhisper

func (b *Bot) HandleWhisper(message twitch.WhisperMessage)

func (*Bot) HelixClient

func (b *Bot) HelixClient() *apirequest.HelixWrapper

func (*Bot) InChannel

func (b *Bot) InChannel(channelID string) bool

func (*Bot) InChannelName

func (b *Bot) InChannelName(channelName string) bool

func (*Bot) IsApplication

func (b *Bot) IsApplication() bool

func (*Bot) Join

func (b *Bot) Join(channelName string)

func (*Bot) JoinChannel

func (b *Bot) JoinChannel(channelID string) error

func (*Bot) JoinChannels

func (b *Bot) JoinChannels()

func (*Bot) LeaveChannel

func (b *Bot) LeaveChannel(channelID string) error

func (*Bot) LoadChannels

func (b *Bot) LoadChannels(sql *sql.DB) error

func (*Bot) MakeChannel

func (b *Bot) MakeChannel(channelName string) pkg.Channel

func (*Bot) MakeUser

func (b *Bot) MakeUser(username string) pkg.User

func (*Bot) Mention

func (b *Bot) Mention(channel pkg.Channel, user pkg.User, message string)

func (*Bot) MessageReceived

func (b *Bot) MessageReceived(source pkg.PubSubSource, topic string, data []byte) error

func (*Bot) OnNewChannelJoined

func (b *Bot) OnNewChannelJoined(cb func(channel pkg.Channel))

func (*Bot) PointRank

func (b *Bot) PointRank(channel pkg.Channel, userID string) uint64

func (*Bot) Quit

func (b *Bot) Quit(message string)

Quit quits the entire application

func (*Bot) RefreshToken

func (b *Bot) RefreshToken() error

func (*Bot) RemovePoints

func (b *Bot) RemovePoints(channel pkg.Channel, userID string, points uint64) (bool, uint64)

func (*Bot) Reply

func (b *Bot) Reply(channel pkg.Channel, user pkg.User, message string)

Reply will reply to the message in the same way it received the message If the message was received in a twitch channel, reply in that twitch channel. IF the message was received in a twitch whisper, reply using twitch whispers.

func (*Bot) Say

func (b *Bot) Say(channel pkg.Channel, message string)

func (*Bot) StartChatterPoller

func (b *Bot) StartChatterPoller()

func (*Bot) Timeout

func (b *Bot) Timeout(channel pkg.Channel, user pkg.User, duration int, reason string)

Timeout will time a user out two times with a delay inbetween to ensure no sneaky messages come through

func (*Bot) TwitchAccount

func (b *Bot) TwitchAccount() pkg.TwitchAccount

func (*Bot) Unban

func (b *Bot) Unban(channel pkg.Channel, user pkg.User)

func (*Bot) Untimeout

func (b *Bot) Untimeout(channel pkg.Channel, user pkg.User)

func (*Bot) UpdateChatSettings

func (b *Bot) UpdateChatSettings(channel pkg.Channel, params *helix.UpdateChatSettingsParams)

func (*Bot) Whisper

func (b *Bot) Whisper(user pkg.User, message string)

func (*Bot) Whisperf

func (b *Bot) Whisperf(user pkg.User, format string, a ...interface{})

type BotChannel

type BotChannel struct {
	ID int64

	BotUser User
	// contains filtered or unexported fields
}

BotChannel describes a bot account that's connected to a channel

func (*BotChannel) Ban

func (c *BotChannel) Ban(user pkg.User, reason string)

func (*BotChannel) Bot

func (c *BotChannel) Bot() pkg.Sender

func (*BotChannel) Channel

func (c *BotChannel) Channel() pkg.Channel

func (*BotChannel) ChannelID

func (c *BotChannel) ChannelID() string

func (*BotChannel) ChannelName

func (c *BotChannel) ChannelName() string

func (*BotChannel) DatabaseID

func (c *BotChannel) DatabaseID() int64

func (*BotChannel) DeleteMessage

func (c *BotChannel) DeleteMessage(message string)

func (*BotChannel) DisableModule

func (c *BotChannel) DisableModule(moduleID string) error

DisableModule disables a module with the given id Returns an error if the module is already disabled We assume that modulesMutex is locked already

func (*BotChannel) EnableModule

func (c *BotChannel) EnableModule(moduleID string) error

EnableModule enables a module with the given id Returns an error if the module is not registered Returns an error if the module is already enabled We assume that modulesMutex is locked already

func (*BotChannel) Events

func (c *BotChannel) Events() *eventemitter.EventEmitter

func (*BotChannel) GetID

func (c *BotChannel) GetID() string

func (*BotChannel) GetModule

func (c *BotChannel) GetModule(moduleID string) (pkg.Module, error)

func (*BotChannel) GetName

func (c *BotChannel) GetName() string

func (*BotChannel) HandleEventSubNotification

func (c *BotChannel) HandleEventSubNotification(notification pkg.TwitchEventSubNotification) error

func (*BotChannel) HandleMessage

func (c *BotChannel) HandleMessage(user pkg.User, message pkg.Message) error

func (*BotChannel) Initialize

func (c *BotChannel) Initialize(b *Bot) error

func (*BotChannel) Mention

func (c *BotChannel) Mention(user pkg.User, message string)

func (*BotChannel) OnModules

func (c *BotChannel) OnModules(cb func(module pkg.Module) pkg.Actions, stop bool) (actions []pkg.Actions)

func (*BotChannel) Say

func (c *BotChannel) Say(message string)

func (*BotChannel) SetEmoteOnly

func (c *BotChannel) SetEmoteOnly(state bool) error

func (*BotChannel) SetFollowerMode

func (c *BotChannel) SetFollowerMode(state bool, durationM int) error

func (*BotChannel) SetNonModChatDelay

func (c *BotChannel) SetNonModChatDelay(state bool, durationS int) error

func (*BotChannel) SetSlowMode

func (c *BotChannel) SetSlowMode(state bool, durationS int) error

func (*BotChannel) SetSubscribers

func (c *BotChannel) SetSubscribers(state bool) error

func (*BotChannel) SetUniqueChat

func (c *BotChannel) SetUniqueChat(state bool) error

func (*BotChannel) Stream

func (c *BotChannel) Stream() pkg.Stream

func (*BotChannel) Timeout

func (c *BotChannel) Timeout(user pkg.User, duration int, reason string)

func (*BotChannel) Unban

func (c *BotChannel) Unban(user pkg.User)

func (*BotChannel) Untimeout

func (c *BotChannel) Untimeout(user pkg.User)

type BotCredentials

type BotCredentials struct {
	AccessToken  string
	RefreshToken string
	Expiry       sql.NullTime
}

type ModeState

type ModeState int

type PointServer

type PointServer struct {
	ReconnectChannel chan (bool)
	// contains filtered or unexported fields
}

func (*PointServer) Read

func (p *PointServer) Read(size int) []byte

func (*PointServer) Send

func (p *PointServer) Send(command uint8, body []byte) bool

func (*PointServer) Write

func (p *PointServer) Write(payload []byte) bool

type SimpleAccount

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

func (*SimpleAccount) ID

func (a *SimpleAccount) ID() string

func (*SimpleAccount) Name

func (a *SimpleAccount) Name() string

type Stream

type Stream struct {
	ID string
	// contains filtered or unexported fields
}

func NewTwitchStream

func NewTwitchStream(account pkg.Account) *Stream

func (*Stream) NeedsInitialPoll

func (s *Stream) NeedsInitialPoll() bool

func (*Stream) Status

func (s *Stream) Status() pkg.StreamStatus

func (*Stream) Update

func (s *Stream) Update(stream *helix.Stream)

type StreamStatus

type StreamStatus struct {
	*helix.Stream
	// contains filtered or unexported fields
}

func (*StreamStatus) Live

func (s *StreamStatus) Live() bool

func (*StreamStatus) StartedAt

func (s *StreamStatus) StartedAt() (r time.Time)

func (*StreamStatus) Update

func (s *StreamStatus) Update(streamData *helix.Stream)

type TwitchAccount

type TwitchAccount struct {
	UserID   string
	UserName string
}

func (*TwitchAccount) ID

func (a *TwitchAccount) ID() string

func (*TwitchAccount) Name

func (a *TwitchAccount) Name() string

type TwitchMessage

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

TwitchMessage is a wrapper for twitch.Message with some extra stuff

func NewTwitchMessage

func NewTwitchMessage(message twitch.Message) *TwitchMessage

func (*TwitchMessage) AddBTTVEmote

func (m *TwitchMessage) AddBTTVEmote(emote pkg.Emote)

func (*TwitchMessage) GetBTTVReader

func (m *TwitchMessage) GetBTTVReader() pkg.EmoteReader

func (TwitchMessage) GetText

func (m TwitchMessage) GetText() string

func (*TwitchMessage) GetTwitchReader

func (m *TwitchMessage) GetTwitchReader() pkg.EmoteReader

func (*TwitchMessage) SetText

func (m *TwitchMessage) SetText(newText string)

type User

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

func NewUser

func NewUser(id, name string) *User

func (*User) GetID

func (u *User) GetID() string

func (*User) GetName

func (u *User) GetName() string

func (*User) ID

func (u *User) ID() string

func (*User) Name

func (u *User) Name() string

func (*User) SetName

func (u *User) SetName(v string)

func (*User) Valid

func (u *User) Valid() bool

Jump to

Keyboard shortcuts

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