Documentation
¶
Index ¶
- type Bot
- func (b *Bot) BuildHelpText() string
- func (b *Bot) Channel(id string) Channel
- func (b *Bot) Command(cmd string, handler Handler)
- func (b *Bot) Listen(ctx context.Context)
- func (b *Bot) Register(cmd CommandInterface)
- func (b *Bot) Say(channel, msg string, a ...interface{})
- func (b *Bot) SetCommandPrefix(pfx string) *Bot
- func (b *Bot) SetReplyOnly(ro bool) *Bot
- func (b *Bot) UnknownCommand(h Handler)
- type Channel
- type Command
- type CommandInterface
- type Conversation
- type ConversationInterface
- type Convo
- type Handler
- type Message
- func (m Message) Channel() string
- 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() string
- func (m *Message) StripMention(user string) string
- func (m Message) Text() string
- func (m Message) User() string
- type MessageInterface
- type Sayer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
RTM *slack.RTM
ID string
Commands []CommandInterface
ReplyOnly bool
CmdPrefix string
// contains filtered or unexported fields
}
Bot is the main object
func (*Bot) BuildHelpText ¶ added in v0.1.1
BuildHelpText will build the help text
func (*Bot) SetCommandPrefix ¶ added in v0.1.1
SetCommandPrefix will set thing that must be prefixed to the command, there is no prefix by default but one could set it to "!" for instance
func (*Bot) SetReplyOnly ¶ added in v0.1.1
SetReplyOnly will make the bot only respond to messages it is mentioned in
func (*Bot) UnknownCommand ¶ added in v0.1.1
UnknownCommand will be called when the user calls a command that is unknown, but it will only work when the bot is in reply only mode
type Channel ¶ added in v0.1.1
type Channel struct {
ID string
// contains filtered or unexported fields
}
Channel is an object that allows a bot to say things without specifying the channel in every function call
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) Handle ¶
func (c Command) Handle(conv ConversationInterface)
Handle calls the command's handler
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 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
Message returns the convos message
func (*Conversation) Reply ¶
func (c *Conversation) Reply(text string, a ...interface{})
Reply sends message using the socket to Slack
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
}
ConversationInterface is the interface for a conversation
func NewConversation ¶
func NewConversation(match allot.MatchInterface, msg Message, bot Sayer) ConversationInterface
NewConversation returns a Conversation struct
type Convo ¶ added in v0.1.1
type Convo ConversationInterface
Convo is a shorthand for ConversationInterface
type Message ¶
type Message struct {
ID uint64
Type string
ChannelID string
UserID string
Message string
OriginalMessage string
}
Message is the Message structure for received and sent messages using Slack
func NewMessage ¶ added in v0.1.1
func NewMessage(ev *slack.MessageEvent) Message
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 ¶
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
type MessageInterface ¶
type MessageInterface interface {
IsMessage() bool
IsFrom(user string) bool
IsHelpRequest() bool
IsDirectMessage() bool
IsMentionFor(user string) bool
IsRelevantFor(user string) bool
Text() string
User() string
Channel() string
}
MessageInterface defines the message interface