Version: v0.5.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 14 Imported by: 18




This section is empty.


This section is empty.


This section is empty.


type SlackService

type SlackService struct {
	Config          *config.Config
	Client          *slack.Client
	RTM             *slack.RTM
	Conversations   []slack.Channel
	UserCache       map[string]string
	ThreadCache     map[string]string
	CurrentUserID   string
	CurrentUsername string

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) 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:

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:

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) MarkAsRead added in v0.3.0

func (s *SlackService) MarkAsRead(channelItem components.ChannelItem)

MarkAsRead will set the channel as read

func (*SlackService) SendCommand added in v0.5.0

func (s *SlackService) SendCommand(channelID string, message string) (bool, error)

SendCommand will send a specific command to slack. First we check wether we are dealing with a command, and if it is one of the supported ones.

NOTE: slack slash commands that are sent to the slack api are undocumented, and as such we need to update the message option that direct it to the correct api endpoint.

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:, 'Posting replies')

func (*SlackService) SetUserAsActive added in v0.5.0

func (s *SlackService) SetUserAsActive()

Set current user presence to active

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL