Documentation ¶
Index ¶
- type SlackService
- func (s *SlackService) CacheFetch(messageID string) (id string, err error)
- func (s *SlackService) CreateMessage(message slack.Message, channelID string) components.Message
- func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []components.Message
- func (s *SlackService) CreateMessageFromFiles(files []slack.File) []components.Message
- func (s *SlackService) CreateMessageFromMessageEvent(message *slack.MessageEvent, channelID string) (components.Message, error)
- func (s *SlackService) CreateMessageFromReplies(messageID string, channelID string) []components.Message
- func (s *SlackService) DeleteMessage(channelID, msgID string) (err error)
- func (s *SlackService) GetChannels() ([]*components.ChannelItem, error)
- func (s *SlackService) GetMessageByID(messageID string, channelID string) ([]components.Message, error)
- func (s *SlackService) GetMessages(channelID string, count int) ([]components.Message, []*components.ChannelItem, error)
- func (s *SlackService) GetUserPresence(userID string) (string, error)
- func (s *SlackService) IsNewThread(threadID string) bool
- func (s *SlackService) MarkAsRead(channelItem *components.ChannelItem)
- func (s *SlackService) SendMessage(channelID string, message string) error
- func (s *SlackService) SendReply(channelID string, threadID string, message string) error
- func (s *SlackService) SetUserAsActive()
- func (s *SlackService) UpdateChat(channelID, messageID, message string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SlackService ¶
type SlackService struct { Config *config.Config Client *slack.Client RTM *slack.RTM Conversations []slack.Channel UserCache map[string]string CurrentUserID string CurrentUsername string // contains filtered or unexported fields }
func NewSlackService ¶
func NewSlackService(config *config.Config) (*SlackService, error)
NewSlackService is the constructor for the SlackService and will initialize the RTM and a Client
func (*SlackService) CacheFetch ¶ added in v0.5.0
func (s *SlackService) CacheFetch(messageID string) (id string, err error)
CacheFetch fetches the ID (timestamp) of messages that have previously been cached. messageID is the hash id (as produced by hashID())
func (*SlackService) CreateMessage ¶
func (s *SlackService) CreateMessage(message slack.Message, channelID string) components.Message
CreateMessage will create a string formatted message that can be rendered in the Chat pane.
[23:59] <erroneousboat> Hello world!
func (*SlackService) CreateMessageFromAttachments ¶ added in v0.3.0
func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []components.Message
CreateMessageFromAttachments will construct an array of strings from the Field values of Attachments of a Message.
func (*SlackService) CreateMessageFromFiles ¶ added in v0.5.0
func (s *SlackService) CreateMessageFromFiles(files []slack.File) []components.Message
CreateMessageFromFiles will create components.Message struct from conversation attached files
func (*SlackService) CreateMessageFromMessageEvent ¶
func (s *SlackService) CreateMessageFromMessageEvent(message *slack.MessageEvent, channelID string) (components.Message, error)
func (*SlackService) CreateMessageFromReplies ¶ added in v0.5.0
func (s *SlackService) CreateMessageFromReplies(messageID string, channelID string) []components.Message
CreateMessageFromReplies will create components.Message struct from the conversation replies from slack.
Useful documentation:
https://api.slack.com/docs/message-threading https://api.slack.com/methods/conversations.replies https://godoc.org/github.com/nlopes/slack#Client.GetConversationReplies https://godoc.org/github.com/nlopes/slack#GetConversationRepliesParameters
func (*SlackService) DeleteMessage ¶ added in v0.5.0
func (s *SlackService) DeleteMessage(channelID, msgID string) (err error)
DeleteMessage deletes a message given a messageID
func (*SlackService) GetChannels ¶
func (s *SlackService) GetChannels() ([]*components.ChannelItem, error)
func (*SlackService) GetMessageByID ¶ added in v0.5.0
func (s *SlackService) GetMessageByID(messageID string, channelID string) ([]components.Message, error)
CreateMessageByID will construct an array of components.Message with only 1 message, using the message ID (Timestamp).
For the choice of history parameters see: https://api.slack.com/messaging/retrieving
func (*SlackService) GetMessages ¶
func (s *SlackService) GetMessages(channelID string, count int) ([]components.Message, []*components.ChannelItem, error)
GetMessages will get messages for a channel, group or im channel delimited by a count. It will return the messages, the thread identifiers (as ChannelItem), and and error.
func (*SlackService) GetUserPresence ¶ added in v0.2.2
func (s *SlackService) GetUserPresence(userID string) (string, error)
GetUserPresence will get the presence of a specific user
func (*SlackService) IsNewThread ¶ added in v0.5.0
func (s *SlackService) IsNewThread(threadID string) bool
IsNewThread checks if a thread has been previously observed by checking for its presence in the thread cache
func (*SlackService) MarkAsRead ¶ added in v0.3.0
func (s *SlackService) MarkAsRead(channelItem *components.ChannelItem)
MarkAsRead will set the channel as read
func (*SlackService) SendMessage ¶
func (s *SlackService) SendMessage(channelID string, message string) error
SendMessage will send a message to a particular channel
func (*SlackService) SendReply ¶ added in v0.5.0
func (s *SlackService) SendReply(channelID string, threadID string, message string) error
SendReply will send a message to a particular thread, specifying the ThreadTimestamp will make it reply to that specific thread. (see: https://api.slack.com/docs/message-threading, 'Posting replies')
func (*SlackService) SetUserAsActive ¶ added in v0.5.0
func (s *SlackService) SetUserAsActive()
Set current user presence to active
func (*SlackService) UpdateChat ¶ added in v0.5.0
func (s *SlackService) UpdateChat(channelID, messageID, message string) error