Documentation
¶
Overview ¶
Package actions contains the actions that the bot can perform. Actions will be passed the current chat details and can return a response. More than one action can generate a response. Errors will result in no response from the action.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotHandled = errors.New("message not handled")
ErrNotHandled is returned if a handler can't handle the message.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { // Handle the message. Handle(channel, user, message string) (string, error) // ID returns the name of the action in order to identify it in logs and // errors. ID() string }
Handler defines a type that can handle incoming chat messages.
type Ping ¶
type Ping struct{}
Ping action is a simple "status check" that will response with "Pong" to indicate the bot is up and listening. Ping also understands pong and responds with an appropriate message.
func (Ping) Handle ¶
Handle the chat message by replying Ping to Pong and Pong to ping.
Example ¶
package main import ( "fmt" "bitbucket.org/idomdavis/gobot/actions" ) func main() { a := actions.Ping{} if m, err := a.Handle("chan", "user", "ping"); err != nil { fmt.Println(err) } else { fmt.Println(m) } }
Output: Pong!
Click to show internal directories.
Click to hide internal directories.