service

package
v0.0.0-...-2b0391e Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 16 Imported by: 0

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

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

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

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

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

func (s *SlackService) GetUserPresence(userID string) (string, error)

GetUserPresence will get the presence of a specific user

func (*SlackService) MarkAsRead

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

MarkAsRead will set the channel as read

func (*SlackService) SendCommand

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

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

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