Documentation ¶
Overview ¶
Package shige implements Shigebot, a twitch irc bot.
Index ¶
- Constants
- type Bot
- func (b Bot) AddCommand(name string, handler func(*CommandData))
- func (b Bot) Channel(channel string) *Channel
- func (b Bot) CommandExists(name string) bool
- func (b Bot) Ignore(nicknames ...string)
- func (b Bot) Ignored(nick string) bool
- func (b Bot) Irc() *irc.Connection
- func (b *Bot) Join(channel string)
- func (b Bot) Part(channel string)
- func (b Bot) Privmsgf(channel, format string, args ...interface{})
- func (b Bot) RemoveCommand(name string)
- func (b Bot) Run()
- func (b Bot) Unignore(nicknames ...string)
- type Channel
- func (c Channel) AddCommand(name, text string) error
- func (c *Channel) AddMod(nick string)
- func (c Channel) Command(name string) *TextCommand
- func (c Channel) CommandExists(name string) bool
- func (c Channel) CommandList() string
- func (c Channel) EditCommand(name, text string) error
- func (c Channel) FullCommandList(separator, modPrefix string, noDescription bool) (res string)
- func (c Channel) IsMod(nick string) bool
- func (c Channel) Printf(format string, args ...interface{})
- func (c Channel) Println(args ...interface{})
- func (c Channel) Privmsgf(format string, args ...interface{})
- func (c Channel) RemoveCommand(name string) error
- func (c *Channel) RemoveMod(nick string)
- func (c Channel) SetCommandMod(name string, modOnly bool) error
- type CommandData
- type TextCommand
Constants ¶
const BotName = "Shigebot 1.1.6"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { // If not nil, this function will be called when a PRIVMSG is received. // The function must return true if the handling of this message should // continue (the message will be forwarded to all the internal command // handlers) or false otherwise. OnPrivmsg func(*irc.Event) bool // The documentation for all the built-in commands. This is already set // by default, but it can be modified when there is a need to customize the // built-in commands or how they show up in the gist. BuiltinCommandsInfo string // contains filtered or unexported fields }
A Bot is an instance of Shigebot connected to multiple channels on twitch on a single twitch account.
func Init ¶
func Init(twitchUser, twitchOauth, gistOAuth string, channelList []string, isMod, caseSensitive bool) (b *Bot, err error)
Init initializes a new instance of Bot and connects to twitch irc servers using twitchUser and twitchOauth as credentials. Each channel in channelList is joined (channel names must include the # prefix). The isMod flag specifies whether the bot's account is a moderator in the channels it will join. Running in non-moderator mode will result in a lower message rate limit as well as randomization of each message by appending a random number to bypass twitch spam prevention. caseSensitive makes text commands case sensitive if true. gistOAuth is the github oauth token that will be used to upload the command list. Returns a pointer to the Bot instance and an error if anything goes wrong.
func (Bot) AddCommand ¶
func (b Bot) AddCommand(name string, handler func(*CommandData))
AddCommand adds a command and binds it to handler.
func (Bot) CommandExists ¶
CommandExists returns whether the command exists.
func (Bot) Ignore ¶
Ignore ignores text commands for a list of nicks. Note: the bot ignores itself by default.
func (Bot) Irc ¶
func (b Bot) Irc() *irc.Connection
Irc returns a pointer to the irc connection object used by the bot.
func (*Bot) Join ¶
Join makes the bot join channel and load any commands that might have been previously saved for that channel.
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
A Channel is a single irc channel to which the bot is connected.
func (Channel) AddCommand ¶
AddCommand adds a simple text command.
func (Channel) Command ¶
func (c Channel) Command(name string) *TextCommand
Command returns a pointer to a command.
func (Channel) CommandExists ¶
CommandExists returns whether a command exists.
func (Channel) CommandList ¶
CommandList returns a comma-separated list of the commands, prefixing moderator commands with a +. The list is alphabetically sorted.
func (Channel) EditCommand ¶
EditCommand replaces the text of an existing simple text command.
func (Channel) FullCommandList ¶
FullCommandList retrieves a list of the commands and their description (or text if they are simple text commands) separated by the string separator. Mod commands will be prefixed by the modPrefix string. If noDescription is true, description or text will be omitted. The list is alphabetically sorted.
func (Channel) Println ¶
func (c Channel) Println(args ...interface{})
Println calls fmt.Println with the channel name as a prefix to the text.
func (Channel) RemoveCommand ¶
RemoveCommand removes a simple text command.
type CommandData ¶
type CommandData struct { // Channel is a pointer to the channel where this message originated. Channel *Channel // Args contains every parameter after the command name. It is built using // strings.Fields, so repeated whitespace is ignored. Args []string // Nick is the nickname of the user that sent the command. Nick string }
CommandData holds information about a chat message that contains a recognized command.
type TextCommand ¶
type TextCommand struct { // Text is the reply that the command will trigger. Text string // ModOnly is true when the command is reserved for mods. ModOnly bool // LastUsage is the time the command was last used LastUsage time.Time }
A TextCommand is a simple text command in a irc channel.