Documentation ¶
Index ¶
- func Contains(processor func(synthetic.Message), catch string) func(synthetic.Message)
- func Exactly(processor func(synthetic.Message), catch string) func(synthetic.Message)
- func LogMessage(msg synthetic.Message)
- func Mentioned(processor func(synthetic.Message)) func(synthetic.Message)
- func NotMentioned(processor func(synthetic.Message)) func(synthetic.Message)
- func RemoveWord(text string, word string) string
- func ReplaceSpace(s string) string
- type Chat
- type Conversation
- type IClient
- type IMessageProcessor
- type IRTM
- type Message
- func (m *Message) ClearMention() string
- func (m *Message) Conversation() synthetic.Conversation
- func (m *Message) Mention() bool
- func (m *Message) React(reaction string)
- func (m *Message) Reply(msg string, inThread bool)
- func (m *Message) Text() string
- func (m *Message) Thread() bool
- func (m *Message) Unreact(reaction string)
- func (m *Message) User() synthetic.User
- type MessageProcessor
- type MockClient
- func (c *MockClient) AddReaction(reaction string, item slack.ItemRef) error
- func (c *MockClient) GetConversationInfo(id string, includeLocale bool) (channel *slack.Channel, err error)
- func (c *MockClient) GetUserInfo(id string) (*slack.User, error)
- func (c *MockClient) NewRTM(options ...slack.RTMOption) *slack.RTM
- func (c *MockClient) RemoveReaction(reaction string, item slack.ItemRef) error
- type MockRTM
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains returns a processor that runs the `processor` if the message contains the `catch` string.
func Exactly ¶
Exactly returns a processot that runs the `processor` if the message is exactly like the `catch` string.
func LogMessage ¶
LogMessage is a message processor to log the message received.
func Mentioned ¶
Mentioned returns a processor that runs the `processor` if the message is mentioning the bot.
func NotMentioned ¶
NotMentioned returns a processor that runs the `processor` if the message is not mentioning the bot.
func RemoveWord ¶
RemoveWord removes `word` from `text` and returns the result. Note this uses a single space to split the words in `text`.
Types ¶
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat represents the whole chat connection providing methods to interact with the chat system.
func (*Chat) IncomingEvents ¶
IncomingEvents returns the channel to the chat system events.
func (*Chat) RegisterMessageProcessor ¶
func (c *Chat) RegisterMessageProcessor(processor IMessageProcessor)
RegisterMessageProcessor allows to add more message processors.
type Conversation ¶
type Conversation struct {
// contains filtered or unexported fields
}
Conversation is a wrapper over slack-go's Channel object. It provides an abstraction layer over channels, group conversations and direct chats.
func NewConversationFromID ¶
func NewConversationFromID(id string, api IClient) (conversation *Conversation, err error)
NewConversationFromID returns a Conversation object wrapping the channel, group conversation, or direct chat identified by `id`.
func (*Conversation) Name ¶
func (c *Conversation) Name() string
Name returns the name of the conversation.
type IClient ¶
type IClient interface { GetConversationInfo(string, bool) (*slack.Channel, error) GetUserInfo(string) (*slack.User, error) NewRTM(...slack.RTMOption) *slack.RTM AddReaction(string, slack.ItemRef) error RemoveReaction(string, slack.ItemRef) error }
IClient is an interface for the chat system's client.
type IMessageProcessor ¶
IMessageProcessor is an interface to represent message processor functions.
type IRTM ¶
type IRTM interface { ManageConnection() NewOutgoingMessage(string, string, ...slack.RTMsgOption) *slack.OutgoingMessage SendMessage(*slack.OutgoingMessage) }
IRTM is an interface for the chat system RTM interface.
type Message ¶
type Message struct { Completed bool // contains filtered or unexported fields }
Message contains all the information about a message the bot was notified about.
func ReadMessage ¶
func ReadMessage(event *slack.MessageEvent, chat *Chat) (msg *Message, err error)
ReadMessage generates the `Message` from a message event.
func (*Message) ClearMention ¶
ClearMention returns the message text without the bot's username.
func (*Message) Conversation ¶
func (m *Message) Conversation() synthetic.Conversation
Conversation is an accessor for Conversation.
func (*Message) Reply ¶
Reply send the `msg` string as a reply to the message, in a thread if `inThread` is true.
type MessageProcessor ¶
type MessageProcessor struct {
// contains filtered or unexported fields
}
MessageProcessor is an implementation of IMessageProcessor.
func NewMessageProcessor ¶
func NewMessageProcessor(name string, processorFunc func(synthetic.Message)) *MessageProcessor
NewMessageProcessor is the constructor for MessageProcessor.
func (*MessageProcessor) Name ¶
func (mp *MessageProcessor) Name() string
Name returns the name of the MessageProcessor.
func (*MessageProcessor) Run ¶
func (mp *MessageProcessor) Run(msg synthetic.Message)
Run executes the MessageProcessor function.
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mocking client for testing.
func (*MockClient) AddReaction ¶
func (c *MockClient) AddReaction(reaction string, item slack.ItemRef) error
AddReaction registers `reaction` on `item` for validation.
func (*MockClient) GetConversationInfo ¶
func (c *MockClient) GetConversationInfo(id string, includeLocale bool) (channel *slack.Channel, err error)
GetConversationInfo returns the channel information for `id`.
func (*MockClient) GetUserInfo ¶
func (c *MockClient) GetUserInfo(id string) (*slack.User, error)
GetUserInfo returns the user information for `id`.
func (*MockClient) NewRTM ¶
func (c *MockClient) NewRTM(options ...slack.RTMOption) *slack.RTM
NewRTM returns a null Slack RTM.
func (*MockClient) RemoveReaction ¶
func (c *MockClient) RemoveReaction(reaction string, item slack.ItemRef) error
RemoveReaction registers `reaction` removal on `item` for validation.
type MockRTM ¶
type MockRTM struct {
// contains filtered or unexported fields
}
MockRTM is a mocking RTM.
func (*MockRTM) ManageConnection ¶
func (rtm *MockRTM) ManageConnection()
ManageConnection fakes the real Slack RTM connection manager.
func (*MockRTM) NewOutgoingMessage ¶
func (rtm *MockRTM) NewOutgoingMessage(text string, channelID string, options ...slack.RTMsgOption) *slack.OutgoingMessage
NewOutgoingMessage creates a fake message object to send.
func (*MockRTM) SendMessage ¶
func (rtm *MockRTM) SendMessage(msg *slack.OutgoingMessage)
SendMessage fakes sending a message.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is a weapper over slack-go's User object. It provides some utility methods over the User information.
func NewUserFromID ¶
NewUserFromID returns a User object wrapping the user identified by `id`.