Documentation ¶
Index ¶
- Constants
- func GetReportActionByName(actionName string) uint8
- func GetReportActionName(action uint8) string
- type Account
- type Actions
- type Application
- type Banphrase
- type BaseEvent
- type BaseModule
- type BotChannel
- type BotStore
- type BotStoreIterator
- type Channel
- type ChannelStore
- type ChannelWithStream
- type CommandInfo
- type CommandMatcher
- type CommandsManager
- type CustomCommand2
- type DeleteAction
- type Emote
- type EmoteReader
- type EventSubNotificationEvent
- type MIMO
- type Message
- type MessageAction
- type MessageEvent
- type MessageSender
- type Module
- type ModuleFactory
- type ModuleParameter
- type ModuleParameterSpec
- type ModuleSpec
- type ModuleType
- type MuteAction
- type MuteType
- type Permission
- type PubSub
- type PubSubBan
- type PubSubBanEvent
- type PubSubConnection
- type PubSubSource
- type PubSubSubscriptionHandler
- type PubSubTimeout
- type PubSubTimeoutEvent
- type PubSubUntimeout
- type PubSubUser
- type Sender
- type SimpleCommand
- type Stream
- type StreamStatus
- type StreamStore
- type TwitchAccount
- type TwitchAuths
- type TwitchEventSubNotification
- type UnmuteAction
- type User
- type UserContext
- type UserStore
- type UserStoreRequest
- type WhisperAction
Constants ¶
const ( ReportActionUnknown = 0 ReportActionBan = 1 ReportActionTimeout = 2 ReportActionDismiss = 3 ReportActionUndo = 4 )
const VerboseBenchmark = false
const VerboseMessages = false
Variables ¶
This section is empty.
Functions ¶
func GetReportActionByName ¶
func GetReportActionName ¶
Types ¶
type Actions ¶
type Actions interface { Timeout(user User, duration time.Duration) MuteAction Ban(user User) MuteAction Unban(user User) UnmuteAction Say(content string) MessageAction Delete(message string) DeleteAction Mention(user User, content string) MessageAction Whisper(user User, content string) WhisperAction Mutes() []MuteAction Unmutes() []UnmuteAction Deletes() []DeleteAction Messages() []MessageAction Whispers() []WhisperAction StopPropagation() bool }
Actions is a list of actions that wants to be run An implementation of this can decide to filter out all mutes except for the "most grave one"
type Application ¶
type Application interface { UserStore() UserStore ChannelStore() ChannelStore UserContext() UserContext StreamStore() StreamStore SQL() *sql.DB PubSub() PubSub TwitchBots() BotStore QuitChannel() chan string TwitchAuths() TwitchAuths MIMO() MIMO }
Application is an instance of pajbot2 It's responsible for initializing all bot accounts (`Bot` class)
type BaseModule ¶
type BaseModule interface { LoadSettings([]byte) error Parameters() map[string]ModuleParameter ID() string Type() ModuleType Priority() int }
A BaseModule is local to a bots channel i.e. bot "pajbot" joins channels "pajlada" and "forsen" Module list looks like this: "pajbot":
- "pajlada":
- "MyTestModule"
- "MyTestModule2"
- "forsen":
- "MyTestModule"
type BotChannel ¶
type BotChannel interface { // Implement Channel interface GetName() string GetID() string MessageSender DatabaseID() int64 Channel() Channel ChannelID() string ChannelName() string EnableModule(string) error DisableModule(string) error GetModule(string) (Module, error) // Implement ChannelWithStream interface Stream() Stream Events() *eventemitter.EventEmitter HandleMessage(user User, message Message) error HandleEventSubNotification(notification TwitchEventSubNotification) error OnModules(cb func(module Module) Actions, stop bool) []Actions SetSubscribers(state bool) error SetUniqueChat(state bool) error SetEmoteOnly(state bool) error SetSlowMode(state bool, durationS int) error SetFollowerMode(state bool, durationM int) error SetNonModChatDelay(state bool, durationS int) error Bot() Sender }
type BotStoreIterator ¶
type Channel ¶
Channel is the most barebones way of accessing a Twitch channel For a Channel to 'live' we must be able to access its Name (Twitch User Login) and ID (Twitch User ID)
type ChannelStore ¶
type ChannelWithStream ¶
type CommandInfo ¶
type CommandInfo struct { Name string Description string Maker func() CustomCommand2 `json:"-"` }
type CommandMatcher ¶
type CommandsManager ¶
type CommandsManager interface { CommandMatcher OnMessage(event MessageEvent) Actions FindByCommandID(id int64) interface{} Register2(id int64, aliases []string, command interface{}) }
type CustomCommand2 ¶
type CustomCommand2 interface { SimpleCommand HasCooldown(User) bool AddCooldown(User) }
type DeleteAction ¶
type DeleteAction interface {
Message() string
}
DeleteAction defines an action that will delete a message
type EmoteReader ¶
type EventSubNotificationEvent ¶
type EventSubNotificationEvent struct { BaseEvent Notification TwitchEventSubNotification }
type MIMO ¶
type MIMO interface { Subscriber(channelNames ...string) chan interface{} Publisher(channelName string) chan interface{} }
MIMO is a Many In Many Out interface Implementation for this exists in pkg/mimo/
type Message ¶
type Message interface { GetText() string SetText(string) GetTwitchReader() EmoteReader GetBTTVReader() EmoteReader AddBTTVEmote(Emote) }
type MessageAction ¶
type MessageAction interface { // TODO: Add reply message action SetAction(v bool) Evaluate() string }
MessageAction defines a message that will be publicly displayed
type MessageEvent ¶
type MessageEvent struct { BaseEvent User User Message Message Channel ChannelWithStream }
type MessageSender ¶
type Module ¶
type Module interface { BaseModule // Called when the module is disabled. The module can do any cleanup it needs to do here Disable() error // Returns the bot channel that the module has saved BotChannel() BotChannel OnWhisper(event MessageEvent) Actions OnMessage(event MessageEvent) Actions OnEventSubNotification(event EventSubNotificationEvent) Actions }
type ModuleFactory ¶
type ModuleFactory func() ModuleSpec
type ModuleParameter ¶
type ModuleParameterSpec ¶
type ModuleParameterSpec func() ModuleParameter
type ModuleSpec ¶
type ModuleSpec interface { ID() string Name() string Type() ModuleType EnabledByDefault() bool Parameters() map[string]ModuleParameterSpec Create(bot BotChannel) Module Priority() int }
type ModuleType ¶
type ModuleType uint
const ( ModuleTypeUnsorted ModuleType = iota ModuleTypeFilter )
The order of these values matter. Higher value means higher priority in the "OnModules" function
type MuteAction ¶
type MuteAction interface { User() User SetReason(reason string) Reason() string Type() MuteType Duration() time.Duration }
MuteAction defines an action that will mute/timeout/ban or otherwise stop a user from participating in chat, either temporarily or permanently
type Permission ¶
type Permission uint64
const ( PermissionNone Permission = 0 PermissionReport Permission = 1 << 0 PermissionRaffle Permission = 1 << 1 PermissionAdmin Permission = 1 << 2 PermissionModeration Permission = 1 << 3 PermissionReportAPI Permission = 1 << 4 PermissionImmuneToMessageLimits = 1 << 5 )
func GetPermissionBit ¶
func GetPermissionBit(s string) Permission
GetPermissionBit converts a string (i.e. "admin") to the binary value it represents. 0b100 in this example
func GetPermissionBits ¶
func GetPermissionBits(permissionNames []string) (permissions Permission)
GetPermissionBits converts a list of strings (i.e. ["admin", "raffle"]) to the binary value they represent. 0b110 in this example
type PubSub ¶
type PubSub interface { Subscribe(source PubSubSource, topic string, parameters json.RawMessage) Publish(source PubSubSource, topic string, data interface{}) HandleSubscribe(connection PubSubSubscriptionHandler, topic string) HandleJSON(source PubSubSource, bytes []byte) error }
type PubSubBanEvent ¶
type PubSubBanEvent struct { Channel PubSubUser Target PubSubUser Source PubSubUser Reason string }
type PubSubConnection ¶
type PubSubConnection interface {
MessageReceived(source PubSubSource, topic string, bytes []byte) error
}
PubSubConnection is an interface where a JSON message can be written to
type PubSubSource ¶
type PubSubSource interface { IsApplication() bool Connection() PubSubConnection AuthenticatedUser() User }
PubSubSource is an interface that is responsible for a message being written into pubsub This will be responsible for checking authorization
type PubSubSubscriptionHandler ¶
type PubSubSubscriptionHandler interface {
ConnectionSubscribed(source PubSubSource, topic string, parameters json.RawMessage) (bool, error)
}
type PubSubTimeout ¶
type PubSubTimeoutEvent ¶
type PubSubTimeoutEvent struct { Channel PubSubUser Target PubSubUser Source PubSubUser Duration int Reason string }
type PubSubUntimeout ¶
type PubSubUser ¶
type Sender ¶
type Sender interface { TwitchAccount() TwitchAccount GetTokenSource() oauth2.TokenSource Connected() bool Say(Channel, string) Mention(Channel, User, string) Whisper(User, string) Whisperf(User, string, ...interface{}) // Timeout times the user out a single time immediately Timeout(Channel, User, int, string) Ban(Channel, User, string) GetPoints(Channel, string) uint64 // give or remove points from user in channel BulkEdit(string, []string, int32) AddPoints(Channel, string, uint64) (bool, uint64) RemovePoints(Channel, string, uint64) (bool, uint64) ForceRemovePoints(Channel, string, uint64) uint64 PointRank(Channel, string) uint64 // ChannelIDs returns a slice of the channels this bot is connected to ChannelIDs() []string InChannel(string) bool InChannelName(string) bool GetUserStore() UserStore GetUserContext() UserContext GetBotChannel(channelName string) BotChannel GetBotChannelByID(channelID string) BotChannel MakeUser(string) User MakeChannel(string) Channel // Permanently join channel with the given channel ID JoinChannel(channelID string) error // Permanently leave channel with the given channel ID LeaveChannel(channelID string) error // Connect to the OnNewChannelJoined callback OnNewChannelJoined(cb func(channel Channel)) Quit(message string) Application() Application // DEV Disconnect() }
type SimpleCommand ¶
type SimpleCommand interface {
Trigger([]string, MessageEvent) Actions
}
type Stream ¶
type Stream interface { Status() StreamStatus // Update forwards the given helix data to its internal status Update(*helix.Stream) }
type StreamStatus ¶
type StreamStore ¶
type TwitchAccount ¶
type TwitchAuths ¶
type TwitchEventSubNotification ¶
type TwitchEventSubNotification struct { Subscription helix.EventSubSubscription `json:"subscription"` Challenge string `json:"challenge"` Event json.RawMessage `json:"event"` }
type UnmuteAction ¶
UnmuteAction defines an action that will unmute/untimeout or unban a user
type User ¶
type User interface { // Has channel or global permission HasPermission(Channel, Permission) bool // Has global permission HasGlobalPermission(Permission) bool // Has channel permission HasChannelPermission(Channel, Permission) bool GetName() string GetDisplayName() string GetID() string IsModerator() bool IsBroadcaster() bool IsVIP() bool IsSubscriber() bool GetBadges() map[string]int // Set the ID of this user // Will return an error if the ID of this user was already set SetID(string) error // Set the Name of this user // Will return an error if the Name of this user was already set SetName(string) error }
type UserContext ¶
type UserStore ¶
type UserStore interface { // Input: Lowercased twitch usernames // Returns: user IDs as strings in no specific order, and a bool indicating whether the user needs to exhaust the list first and wait GetIDs([]string) map[string]string GetID(string) string GetUserByLogin(string) (User, error) GetUserByID(string) (User, error) GetName(string) string // Input: list of twitch IDs // Returns: map of twitch IDs pointing at twitch usernames GetNames([]string) map[string]string Hydrate([]User) error }
type UserStoreRequest ¶
type UserStoreRequest struct {
// contains filtered or unexported fields
}
func NewUserStoreRequest ¶
func NewUserStoreRequest() *UserStoreRequest
func (*UserStoreRequest) AddID ¶
func (r *UserStoreRequest) AddID(id string)
func (*UserStoreRequest) AddName ¶
func (r *UserStoreRequest) AddName(name string)
type WhisperAction ¶
WhisperAction defines a message that will be privately sent to a user
Source Files ¶
- account.go
- action.go
- application.go
- auth.go
- banphrase.go
- bot.go
- botchannel.go
- botstore.go
- channel.go
- commands.go
- const.go
- emote.go
- emotes.go
- events.go
- eventsub.go
- message.go
- mimo.go
- module.go
- permissions.go
- pubsub.go
- reportaction.go
- stream.go
- streamstore.go
- twitchaccount.go
- user.go
- usercontext.go
- userstore.go