Documentation
¶
Index ¶
- Constants
- func ReconOpt() func(*Bot)
- func SaslAuth(pass string) func(*Bot)
- type Bot
- func (bot *Bot) Action(who, text string)
- func (bot *Bot) AddTrigger(h Handler)
- func (bot *Bot) ChMode(user, channel, mode string)
- func (bot *Bot) Close() error
- func (bot *Bot) Join(ch string)
- func (bot *Bot) Msg(who, text string)
- func (bot *Bot) Notice(who, text string)
- func (bot *Bot) Part(ch string)
- func (bot *Bot) Reply(m *Message, text string)
- func (bot *Bot) Run()
- func (bot *Bot) SASLAuthenticate(user, pass string)
- func (bot *Bot) Send(command string)
- func (bot *Bot) SetNick(nick string)
- func (bot *Bot) StandardRegistration()
- func (bot *Bot) StartUnixListener()
- func (bot *Bot) String() string
- func (bot *Bot) Topic(c, topic string)
- func (bot *Bot) Uptime() string
- func (bot *Bot) WaitFor(filter func(*Message) bool)
- type Emote
- type Handler
- type Message
- type Trigger
Constants ¶
const ( WelcomeSignature string = ":tmi\\.twitch\\.tv 001 .+ :Welcome, GLHF!" JoinSignature string = ":(.+)!.+@.+\\.tmi\\.twitch\\.tv JOIN (#.+)" LoggedInSignature string = ":tmi\\.twitch\\.tv 376 .+ :>" CapabilityAcknowledgedSignature string = ":tmi\\.twitch\\.tv CAP \\* ACK :twitch\\.tv/.+" UNKNOWNSignature string = ":.+\\.tmi\\.twitch\\.tv (353|366) .+" IgnoreSignature string = ":tmi\\.twitch\\.tv (002|003|004|375|372|376) .+" EndOfNameListSignature string = ":.+\\.tmi\\.twitch\\.tv 366 .+ #.+ :End of /NAMES list" UserStateSignature string = "@badge-info=.+ :tmi\\.twitch\\.tv USERSTATE .+" RoomStateSignature string = "@emote-only=.+ :tmi\\.twitch\\.tv ROOMSTATE .+" PrivateMessageUserSignature string = ":(.+)!.+@.+\\.tmi\\.twitch\\.tv" PingSignature string = "PING :tmi\\.twitch\\.tv" NoticeSignature string = "@msg-id=(.+):tmi\\.twitch\\.tv (NOTICE) (#.+) :(.+)" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bot ¶
type Bot struct {
// Channel for user to read incoming messages
Incoming chan *Message
// Log15 loggger
log.Logger
// Exported fields
Host string
Password string
Channels []string
SSL bool
SASL bool
HijackSession bool
// An optional function that connects to an IRC server over plaintext:
Dial func(network, addr string) (net.Conn, error)
// An optional function that connects to an IRC server over a secured connection:
DialTLS func(network, addr string, tlsConf *tls.Config) (*tls.Conn, error)
// This bots nick
Nick string
// Duration to wait between sending of messages to avoid being
// kicked by the server for flooding (default 200ms)
ThrottleDelay time.Duration
// Maxmimum time between incoming data
PingTimeout time.Duration
TLSConfig tls.Config
// contains filtered or unexported fields
}
Bot implements an irc bot to be connected to a given server
func (*Bot) AddTrigger ¶
AddTrigger adds a trigger to the bot's handlers
func (*Bot) ChMode ¶
ChMode is used to change users modes in a channel operator = "+o" deop = "-o" ban = "+b"
func (*Bot) Part ¶
Part a channel. Notice that Twitch does not expect a leave message, like default IRC.
func (*Bot) Run ¶
func (bot *Bot) Run()
Run starts the bot and connects to the server. Blocks until we disconnect from the server.
func (*Bot) SASLAuthenticate ¶
SASLAuthenticate performs SASL authentication ref: https://github.com/atheme/charybdis/blob/master/doc/sasl.txt
func (*Bot) StandardRegistration ¶
func (bot *Bot) StandardRegistration()
StandardRegistration performsa a basic set of registration commands
func (*Bot) StartUnixListener ¶
func (bot *Bot) StartUnixListener()
StartUnixListener starts up a unix domain socket listener for reconnects to be sent through
type Message ¶
type Message struct {
BadgeInfo map[string]int // Used only for subscribers. Value "subscriber/8" means user has been a subscriber for 8 months.
Badges map[string]int // Badges displayed next to display name. Value "admin/1" means user has the version 1 of admin badge.
ClientNonce string // Random identifier to link a response to a request.
Color string // User's defined color for their display name, if set.
DisplayName string // User's defined name to be displayed in the chat.
Emotes map[string]Emote // If the message contains emotes, they are detailed here. Check Emote type for more details.
Flags string //
Id string
Mod int
RoomId int64
Subscriber int
TmiSentTs int64
// Turbo int // This is deprecated. Use badges instead.
UserId int64
Content string // This is the original message sent by the user or system.
ContentNoEmotes string // This is the message sent by the user, but all emotes have been removed.
Unparsed map[string]string // Anything that was not parsed.
//Time at which this message was recieved
TimeStamp time.Time
// Entity that this message was addressed to (channel or user)
To string
// Nick of the messages sender (equivalent to Prefix.Name)
// Outdated, please use .Name
From string
Command string
Params []string
}
func GenerateMessageObject ¶
func ParseMessage ¶
func ParseTwitchMessage ¶
type Trigger ¶
type Trigger struct {
// Returns true if this trigger applies to the passed in message
Condition func(*Bot, *Message) bool
// The action to perform if Condition is true
// return true if the message was 'consumed'
Action func(*Bot, *Message) bool
}
Trigger is a Handler which is guarded by a condition
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
main
command
This is an example program showing the usage of hellivabot
|
This is an example program showing the usage of hellivabot |
|
sample-triggers
command
|
|
|
sasl
command
This is an example program showing the usage of hellivabot
|
This is an example program showing the usage of hellivabot |
|
commands
module
|
