Documentation ¶
Index ¶
- Constants
- Variables
- func TimeStamp() string
- func TimeStampFmt(format string) string
- type AppOAuthCred
- type ChannelData
- type ConfigStruct
- type IRCOAuthCred
- type KardBot
- func (bb *KardBot) ActiveChannels() int
- func (bb *KardBot) Connect()
- func (bb *KardBot) Disconnect()
- func (bb *KardBot) HandleChat() error
- func (bb *KardBot) JoinChannel(channels ...string)
- func (bb *KardBot) LeaveChannel(channels ...string)
- func (bb *KardBot) Login()
- func (bb *KardBot) Msg(msg string, users ...string) error
- func (bb *KardBot) ReadCredentials(credType string) error
- func (bb *KardBot) ReadOrCreateChannelKey(channel string) string
- func (bb *KardBot) Say(msg string, channels ...string) error
- func (bb *KardBot) Start()
- func (bb *KardBot) UpdateBearerToken(user string, token string)
- func (bb *KardBot) UpdateTwitchUserID(user string, userid string)
- func (bb *KardBot) UpdateVideoCache(user string, videos []SingsVideoStruct)
- type SingsVideoStruct
Constants ¶
const UTCFormat = "Jan 2 15:04:05 UTC"
Variables ¶
var CmdRegex *regexp.Regexp = regexp.MustCompile(`^!(\w+)\s?(\w+)?`)
Regex for parsing user commands, from already parsed PRIVMSG strings.
First matched group is the command name and the second matched group is the argument for the command.
var ConnectRegex *regexp.Regexp = regexp.MustCompile(`^:tmi.twitch.tv 001 ([^ ]+) .*`)
Regex for parsing connection messages
First matched group is our real username - twitch doesn't complain at using NICK command but doesn't honor it.
var DirectMsgRegex *regexp.Regexp = regexp.MustCompile(`^:(\w+)!\w+@\w+\.tmi\.twitch\.tv (PRIVMSG) (\w+)(?: :(.*))?$`)
var MsgRegex *regexp.Regexp = regexp.MustCompile(`^:(\w+)!\w+@\w+\.tmi\.twitch\.tv (PRIVMSG) #(\w+)(?: :(.*))?$`)
Regex for parsing PRIVMSG strings.
First matched group is the user's name, second is the channel? and the third matched group is the content of the user's message.
Functions ¶
func TimeStampFmt ¶
Types ¶
type AppOAuthCred ¶
type ChannelData ¶
type ChannelData struct { Name string `json:"name"` AdminKey string `json:"value,omitempty"` Command string `json:"customcommand,omitempty"` ExtraStrings string `json:"extrastrings,omitempty"` JoinTime time.Time `json:"jointime"` ControlChannel bool HasLeft bool `json:"hasleft"` VideoCache []SingsVideoStruct `json:"videoCache"` VideoCacheUpdated time.Time `json:"videoCacheUpdated"` Bearer string `json:"bearer"` TwitchUserID string `json:"twitchUserID"` }
type ConfigStruct ¶
type ConfigStruct struct { InitialChannels []string `json:"channels"` IrcOAuthPath string `json:"ircoauthpath,omitempty"` StringPath string `json:"authpath,omitempty"` DataPath string `json:"datapath,omitempty"` ExternalUrl string `json:"externalurl,omitempty"` AppOAuthPath string `json:"appoauthpath,omitempty"` }
type IRCOAuthCred ¶
type KardBot ¶
type KardBot struct { Channel string IrcCredentials *IRCOAuthCred AppCredentials *AppOAuthCred MsgRate time.Duration Name string Port string IrcPrivatePath string AppPrivatePath string Server string Prompts []string Database scribble.Driver ChannelData map[string]ChannelData Config ConfigStruct // contains filtered or unexported fields }
func (*KardBot) ActiveChannels ¶
Look at the channels I'm actually in
func (*KardBot) Connect ¶
func (bb *KardBot) Connect()
Connects the bot to the Twitch IRC server. The bot will continue to try to connect until it succeeds or is forcefully shutdown.
func (*KardBot) Disconnect ¶
func (bb *KardBot) Disconnect()
Officially disconnects the bot from the Twitch IRC server.
func (*KardBot) HandleChat ¶
Listens for and logs messages from chat. Responds to commands from the channel owner. The bot continues until it gets disconnected, told to shutdown, or forcefully shutdown.
func (*KardBot) JoinChannel ¶
Makes the bot join its pre-specified channel.
func (*KardBot) LeaveChannel ¶
func (*KardBot) ReadCredentials ¶
Reads from the private credentials file and stores the data in the bot's appropriate Credentials field.
func (*KardBot) ReadOrCreateChannelKey ¶
func (*KardBot) Start ¶
func (bb *KardBot) Start()
Starts a loop where the bot will attempt to connect to the Twitch IRC server, then connect to the pre-specified channel, and then handle the chat. It will attempt to reconnect until it is told to shut down, or is forcefully shutdown.
func (*KardBot) UpdateBearerToken ¶ added in v0.0.3
func (*KardBot) UpdateTwitchUserID ¶ added in v0.0.3
func (*KardBot) UpdateVideoCache ¶ added in v0.0.3
func (bb *KardBot) UpdateVideoCache(user string, videos []SingsVideoStruct)
type SingsVideoStruct ¶ added in v0.0.3
type SingsVideoStruct struct { Date time.Time `json:"date"` // Golang date of creation FullTitle string `json:"fullTitle"` // Full Title Duet bool `json:"duet"` // Is it a duet? OtherSinger string `json:"otherSinger"` // Twitch NAME of the other singer, extracted from the title SongTitle string `json:"songTitle"` // extracted from title LastSungSong time.Time `json:"LastSungSong"` // Last time this SONG was sung LastSungSinger time.Time `json:"LastSungSinger"` // Last time a duet was sung with this SINGER, regardless of song, only Duets have this date initialised }