Documentation
¶
Index ¶
- Constants
- type Entity
- type EntityType
- type ListItem
- type ListItemStatus
- type ListItems
- type Output
- type Slk
- func (s *Slk) Active() (Entity, error)
- func (s *Slk) Fuzzy(entityType EntityType, query string) []Entity
- func (s *Slk) History(e Entity, amount int) error
- func (s *Slk) IMs() []Entity
- func (s *Slk) Init() error
- func (s *Slk) Invite(channel, user Entity) error
- func (s *Slk) Join(e Entity) error
- func (s *Slk) Joined() []Entity
- func (s *Slk) Leave(e Entity) error
- func (s *Slk) List(entityType EntityType, relevantOnly bool) error
- func (s *Slk) ListUnread() error
- func (s *Slk) Members(e Entity, relevantOnly bool) error
- func (s *Slk) NextUnread() (Entity, error)
- func (s *Slk) Pins(e Entity) error
- func (s *Slk) Post(e Entity, msg string) error
- func (s *Slk) Quit()
- func (s *Slk) Run() error
- func (s *Slk) SetPresence(presence UserPresence) error
- func (s *Slk) Switch(e Entity) error
- func (s *Slk) Unread(e Entity) error
- func (s *Slk) Upload(e Entity, filepath, title, comment string) chan error
- func (s *Slk) Uploads(e Entity) error
- func (s *Slk) Username() string
- type UserPresence
Constants ¶
const ( // UserPresenceActive represents the active presence. UserPresenceActive UserPresence = "active" // UserPresenceAway represents the away presence. UserPresenceAway UserPresence = "away" // TypeChannel identifies the channel-type TypeChannel EntityType = "channel" // TypeUser identifies the user-type TypeUser EntityType = "user" )
const ( // ListItemStatusNone should not receive special treatment ListItemStatusNone = iota // ListItemStatusGood should indicate a positive status // (e.g.: user online, ...) ListItemStatusGood // ListItemStatusBad should indicate a negative status // (e.g.: user set to DND) ListItemStatusBad // ListItemStatusNormal should indicate a neutral status // (e.g.: channel exists but user is not a member) ListItemStatusNormal // ListItemStatusTitle can be used to section a list with titles. ListItemStatusTitle )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity interface { ID() string Name() string QualifiedName() string Type() EntityType UnreadCount() int IsActive() bool IsAway() bool IsNil() bool Is(Entity) bool // contains filtered or unexported methods }
Entity abstracts users, groups and channels
type EntityType ¶
type EntityType string
EntityType represents a slack entity-type (i.e.: channel, user, ...)
type ListItemStatus ¶
type ListItemStatus string
ListItemStatus allows Output implementations to differentiate between diffent types of ListItems.
type ListItems ¶
type ListItems []*ListItem
ListItems is a collection items that should be rendered as a list by the implementation of the output interface.
type Output ¶
type Output interface { // Notify should do something that stands out relative to the rest of // the methods and represens a message event. Notify(channel, from, text string, force bool) // Info will be called when a 'positive' event occurs. Info(msg string) // Notice will be called when a 'neutral' event occurs. Notice(msg string) // Warn will be called when an errors occurs. Warn(msg string) // Msg should render a slack message. Msg(channel, from, msg string, ts time.Time, newSection bool) // Debug will be called with dev info. Debug(msg ...string) // Typing should notify the user of another user's typing status. Typing(channel, user string, timeout time.Duration) // File should render a file. File(channel, from, title, url string) // List should render the given list. List(items ListItems, reverse bool) }
Output allows for different implementations of the slk ui.
type Slk ¶
type Slk struct {
// contains filtered or unexported fields
}
Slk abstracts a bunch of nlopes/slack calls and writes all output to the given Output interface.
Handling of errors returned by Slk exposed methods is optional. Except for Init and Run.
func (*Slk) Fuzzy ¶
func (s *Slk) Fuzzy(entityType EntityType, query string) []Entity
Fuzzy returns a list of entities of type entityType whose names fuzzy match the given query.
func (*Slk) History ¶
History like Unread writes a set of messages to the Output interface but takes an amount of messages argument instead of looking up unread messages.
func (*Slk) Init ¶
Init establishes the rtm connection and returns once we have all channel / group / im / user information. Should be called before Run().
func (*Slk) List ¶
func (s *Slk) List(entityType EntityType, relevantOnly bool) error
List writes a list of entities of type entityType to the Output interface.
func (*Slk) ListUnread ¶
ListUnread writes a list of entities with unread messages to the Output.
func (*Slk) Members ¶
Members writes a list of members of the given channel or group to the Output interface.
func (*Slk) NextUnread ¶
NextUnread returns a random entity (ims first) with unread messages.
func (*Slk) SetPresence ¶
func (s *Slk) SetPresence(presence UserPresence) error
SetPresence updates your presence.
func (*Slk) Unread ¶
Unread writes all unread mesages of the given user, channel or group to the Output interface and marks the last message as read.