service

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelTypeChannel = "channel"
	ChannelTypeGroup   = "group"
	ChannelTypeIM      = "im"
)

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
	SlackChannels   []interface{}
	Channels        []components.ChannelItem
	UserCache       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) ChannelsToString added in v0.3.0

func (s *SlackService) ChannelsToString() []string

ChannelsToString will relay the string representation for a channel

func (*SlackService) CheckNotifyMention added in v0.4.0

func (s *SlackService) CheckNotifyMention(ev *slack.MessageEvent) bool

CheckNotifyMention check if the message event is either contains a mention or is posted on an IM channel

func (*SlackService) CreateMessage

func (s *SlackService) CreateMessage(message slack.Message) []components.Message

CreateMessage will create a string formatted message that can be rendered in the Chat pane.

[23:59] <erroneousboat> Hello world!

This returns an array of string because we will try to uncover attachments associated with messages.

func (*SlackService) CreateMessageFromAttachments added in v0.3.0

func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []components.Message

CreateMessageFromAttachments will construct a array of string of the Field values of Attachments from a Message.

func (*SlackService) CreateMessageFromMessageEvent

func (s *SlackService) CreateMessageFromMessageEvent(message *slack.MessageEvent) ([]components.Message, error)

func (*SlackService) CreateNotifyMessage added in v0.4.0

func (s *SlackService) CreateNotifyMessage(channelID string) string

func (*SlackService) FindChannel added in v0.4.0

func (s *SlackService) FindChannel(channelID string) int

FindChannel will loop over s.Channels to find the index where the channelID equals the ID

func (*SlackService) GetChannelName added in v0.4.0

func (s *SlackService) GetChannelName(channelID string) string

GetChannelName will return the name for a specific channelID

func (*SlackService) GetChannels

func (s *SlackService) GetChannels() []string

GetChannels will retrieve all available channels, groups, and im channels. Because the channels are of different types, we will append them to an []interface as well as to a []Channel which will give us easy access to the id and name of the Channel.

func (*SlackService) GetMessages

func (s *SlackService) GetMessages(channel interface{}, count int) []components.Message

GetMessages will get messages for a channel, group or im channel delimited by a count.

func (*SlackService) GetSlackChannel added in v0.3.0

func (s *SlackService) GetSlackChannel(selectedChannel int) interface{}

GetSlackChannel returns the representation of a slack channel

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(channelID int)

MarkAsRead will set the channel as read

func (*SlackService) MarkAsUnread added in v0.3.0

func (s *SlackService) MarkAsUnread(channelID string)

MarkAsUnread will set the channel as unread

func (*SlackService) SendMessage

func (s *SlackService) SendMessage(channelID int, message string)

SendMessage will send a message to a particular channel

func (*SlackService) SetChannelReadMark added in v0.2.0

func (s *SlackService) SetChannelReadMark(channel interface{})

SetChannelReadMark will set the read mark for a channel, group, and im channel based on the current time.

func (*SlackService) SetPresenceChannelEvent added in v0.3.0

func (s *SlackService) SetPresenceChannelEvent(userID string, presence string)

SetPresenceChannelEvent will set the presence of a IM channel

func (*SlackService) SetPresenceChannels added in v0.4.0

func (s *SlackService) SetPresenceChannels()

SetPresence will set presence for all IM channels

Jump to

Keyboard shortcuts

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