slack

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

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

Go to latest
Published: Jun 19, 2017 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LooksLikeIdRE *regexp.Regexp

Functions

func SlackTime

func SlackTime(t string) time.Time

SlackTime converts the timestamp string to time.Time

Types

type Broker

type Broker struct {
	Client *slack.Client // slack API object
	RTM    *slack.RTM    // slack RTM object
	UserId string        // slack Bot user ID (for preventing loops)
	// contains filtered or unexported fields
}

Broker interacts with the slack service. TODO: add a miss cache to avoid hammering the room/user info apis

func (*Broker) FillRoomCache

func (sb *Broker) FillRoomCache()

func (*Broker) FillUserCache

func (sb *Broker) FillUserCache()

func (Broker) GetTopic

func (sb Broker) GetTopic(roomId string) (string, error)

func (Broker) HasRoom

func (sb Broker) HasRoom(room string) bool

checks the cache to see if the room is known to this broker

func (Broker) Leave

func (sb Broker) Leave(roomId string) error

func (Broker) LooksLikeRoomId

func (sb Broker) LooksLikeRoomId(room string) bool

func (Broker) LooksLikeUserId

func (sb Broker) LooksLikeUserId(user string) bool

func (Broker) Name

func (sb Broker) Name() string

Name returns the name of the broker as set in NewBroker.

func (Broker) RoomIdToName

func (sb Broker) RoomIdToName(id string) string

RoomIdToName gets the human-readable room name for a user ID using an in-memory cache that falls through to the Slack API

func (Broker) RoomNameToId

func (sb Broker) RoomNameToId(name string) string

RoomNameToId gets the id for a room name using an in-memory cache that falls through to the Slack API

func (Broker) Send

func (sb Broker) Send(evt hal.Evt)

func (Broker) SendAsImage

func (sb Broker) SendAsImage(evt hal.Evt)

SendAsImage sends the body of the event as a png file. The png is rendered using hal's FixedFont facility. This is useful for making sure pre-formatted text stays legible in Slack while we wait for them to figure out a way to render things like tables of data consistently.

func (Broker) SendAsIs

func (sb Broker) SendAsIs(evt hal.Evt)

SendAsIs directly sends a message without considering it for posting as a snippet.

func (Broker) SendAsSnippet

func (sb Broker) SendAsSnippet(evt hal.Evt)

func (Broker) SendDM

func (sb Broker) SendDM(evt hal.Evt)

func (Broker) SendTable

func (sb Broker) SendTable(evt hal.Evt, hdr []string, rows [][]string)

func (Broker) SetTopic

func (sb Broker) SetTopic(roomId, topic string) error

func (Broker) Stream

func (sb Broker) Stream(out chan *hal.Evt)

Stream is an event loop for Slack events & messages from the RTM API. Events are copied to a hal.Evt and forwarded to the exchange where they can be processed by registered handlers.

func (Broker) UserIdToName

func (sb Broker) UserIdToName(id string) string

UserIdToName gets the human-readable username for a user ID using an in-memory cache that falls through to the Slack API

func (Broker) UserNameToId

func (sb Broker) UserNameToId(name string) string

UserNameToId gets the human-readable username for a user ID using an in-memory cache that falls through to the Slack API

type Config

type Config struct {
	Token string
}

func (Config) NewBroker

func (c Config) NewBroker(name string) Broker

Jump to

Keyboard shortcuts

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