service

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

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

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

https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md

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

Jump to

Keyboard shortcuts

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