Documentation ¶
Index ¶
- type Bot
- type Command
- type CommandInterface
- type Connection
- type Conversation
- func (c Conversation) Integer(name string) (int, error)
- func (c Conversation) Match(position int) (string, error)
- func (c *Conversation) Message() MessageInterface
- func (c *Conversation) Reply(text string, a ...interface{})
- func (c *Conversation) SetConnection(connection Connection)
- func (c Conversation) String(name string) (string, error)
- type ConversationInterface
- type Handler
- type Message
- func (m Message) IsDirectMessage() bool
- func (m Message) IsFrom(user string) bool
- func (m Message) IsHelpRequest() bool
- func (m Message) IsMentionFor(user string) bool
- func (m Message) IsMessage() bool
- func (m Message) IsRelevantFor(user string) bool
- func (m *Message) SetText(text string)
- func (m *Message) StripLinkMarkup()
- func (m *Message) StripMention(user string)
- func (m Message) Text() string
- func (m Message) User() string
- type MessageInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { Socket *websocket.Conn Token string ID string Commands []CommandInterface }
Bot is the main object
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command a command
func NewCommand ¶
NewCommand creates a new command
func (Command) Description ¶
Description returns the description
func (Command) Get ¶
func (c Command) Get() allot.CommandInterface
Get returns the platzhalter command
func (Command) Handle ¶
func (c Command) Handle(conv ConversationInterface)
Handle calls the command's handler
func (*Command) Set ¶
func (c *Command) Set(cmd allot.CommandInterface)
Set defines the platzhalter command
func (*Command) SetDescription ¶
SetDescription sets the description
func (*Command) SetHandler ¶
SetHandler sets the handler
type CommandInterface ¶
type CommandInterface interface { Get() allot.CommandInterface Description() string Handle(conv ConversationInterface) }
CommandInterface defines a command interface
type Connection ¶
Connection is the needed interface for a connection
type Conversation ¶
type Conversation struct {
// contains filtered or unexported fields
}
Conversation stores message, command and socket information and is passed to the handler function
func (Conversation) Integer ¶
func (c Conversation) Integer(name string) (int, error)
Integer returns integer parameter
func (Conversation) Match ¶
func (c Conversation) Match(position int) (string, error)
Match returns the parameter at the position
func (*Conversation) Message ¶
func (c *Conversation) Message() MessageInterface
func (*Conversation) Reply ¶
func (c *Conversation) Reply(text string, a ...interface{})
Reply sends message using the socket to Slack
func (*Conversation) SetConnection ¶
func (c *Conversation) SetConnection(connection Connection)
SetConnection sets the conversation connection
type ConversationInterface ¶
type ConversationInterface interface { Integer(name string) (int, error) String(name string) (string, error) Reply(text string, a ...interface{}) Match(position int) (string, error) Message() MessageInterface SetConnection(connection Connection) // contains filtered or unexported methods }
ConversationInterface is the interface for a conversation
func NewConversation ¶
func NewConversation(match allot.MatchInterface, msg Message, socket *websocket.Conn) ConversationInterface
NewConversation returns a Conversation struct
type Handler ¶
type Handler func(ConversationInterface)
Handler is the interface for the handler function
type Message ¶
type Message struct { ID uint64 `json:"id"` Type string `json:"type"` Channel string `json:"channel"` UserID string `json:"user"` Message string `json:"text"` }
Message is the Message structure for received and sent messages using Slack
func (Message) IsDirectMessage ¶
IsDirectMessage checks if the message is received using a direct messaging channel
func (Message) IsHelpRequest ¶
IsHelpRequest checks if the user requests the help command
func (Message) IsMentionFor ¶
IsMentionFor checks if the given user was mentioned with the message
func (Message) IsMessage ¶
IsMessage checks if it is a Message or some other kind of processing information
func (Message) IsRelevantFor ¶
IsRelevantFor checks if the message is relevant for a user
func (*Message) StripLinkMarkup ¶
func (m *Message) StripLinkMarkup()
StripLinkMarkup converts <http://google.com|google.com> into google.com etc. https://api.slack.com/docs/message-formatting#how_to_display_formatted_messages
func (*Message) StripMention ¶
StripMention removes the mention from the message beginning