Documentation ¶
Index ¶
- Variables
- func SlackTime(t string) time.Time
- type Broker
- func (sb *Broker) FillRoomCache()
- func (sb *Broker) FillUserCache()
- func (sb Broker) GetTopic(roomId string) (string, error)
- func (sb Broker) HasRoom(room string) bool
- func (sb Broker) Leave(roomId string) error
- func (sb Broker) LooksLikeRoomId(room string) bool
- func (sb Broker) LooksLikeUserId(user string) bool
- func (sb Broker) Name() string
- func (sb Broker) RoomIdToName(id string) string
- func (sb Broker) RoomNameToId(name string) string
- func (sb Broker) Send(evt hal.Evt)
- func (sb Broker) SendAsImage(evt hal.Evt)
- func (sb Broker) SendAsIs(evt hal.Evt)
- func (sb Broker) SendAsSnippet(evt hal.Evt)
- func (sb Broker) SendDM(evt hal.Evt)
- func (sb Broker) SendTable(evt hal.Evt, hdr []string, rows [][]string)
- func (sb Broker) SetTopic(roomId, topic string) error
- func (sb Broker) Stream(out chan *hal.Evt)
- func (sb Broker) UserIdToName(id string) string
- func (sb Broker) UserNameToId(name string) string
- type Config
Constants ¶
This section is empty.
Variables ¶
var LooksLikeIdRE *regexp.Regexp
Functions ¶
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) LooksLikeRoomId ¶
func (Broker) LooksLikeUserId ¶
func (Broker) RoomIdToName ¶
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 ¶
RoomNameToId gets the id for a room name using an in-memory cache that falls through to the Slack API
func (Broker) SendAsImage ¶
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 ¶
SendAsIs directly sends a message without considering it for posting as a snippet.
func (Broker) SendAsSnippet ¶
func (Broker) Stream ¶
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 ¶
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 ¶
UserNameToId gets the human-readable username for a user ID using an in-memory cache that falls through to the Slack API