tension

package module
v0.0.0-...-3ddedc5 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2016 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResult

type APIResult struct {
	Ok       bool   `json:"ok"`
	ErrorMsg string `json:"error"`
}

APIResult is the common field set for all API result types.

type APITestResult

type APITestResult struct {
	APIResult
}

APITestResult contains a delightful affirmation of your competence.

type AuthRevokeResult

type AuthRevokeResult struct {
	APIResult
	Revoked bool
}

AuthRevokeResult includes the response to an AuthRevoke API call. Note that `Revoked` is useful to distinguish whether the API was called in "test mode"

type AuthTestResult

type AuthTestResult struct {
	APIResult
	URL     string
	Team    string
	Name    string `json:"user"`
	Team_Id string
	User_Id UserId
}

AuthTestResult includes the response to an AuthTest API call.

type BotInfo

type BotInfo struct {
	Id      UserId
	Deleted bool
	Name    string
	Icons   map[string]string
}

BotInfo contains the details for a particular bot.

type BotsInfoResult

type BotsInfoResult struct {
	APIResult
	Bot BotInfo
}

BotsInfoResult contains the response to a BotsInfo request.

type ChannelArchiveResult

type ChannelArchiveResult struct {
	APIResult
}

ChannelArchiveResult contains the response to a ChannelArchive request.

type ChannelBrief

type ChannelBrief struct {
	ChannelMinimal
	Creator     UserId
	Is_Archived bool
	Is_General  bool
}

ChannelBrief is returned in a ChannelJoinResult if already in a channel.

type ChannelCreateResult

type ChannelCreateResult struct {
	APIResult
	Channel ChannelFull
}

ChannelCreateResult contains the response to a ChannelCreate request.

type ChannelFull

type ChannelFull struct {
	ChannelSummary
	Is_Starred           bool
	Members              []UserId
	Last_Read            SlackTime
	Latest               Message
	Unread_Count         uint
	Unread_Count_Display uint
}

ChannelFull expands on ChannelSummary to include fields used by eg ChannelInfoResult.

type ChannelHistoryResult

type ChannelHistoryResult struct {
	APIResult
	Latest     SlackTime
	Messages   []Message
	Has_More   bool
	Is_Limited bool
}

ChannelHistoryResult contains the response to a ChannelHistory request.

type ChannelId

type ChannelId string

A ChannelId is an opaque string that represents a "public" Slack channel, survivng channel renames unchanged.

type ChannelInfoResult

type ChannelInfoResult struct {
	APIResult
	Channel ChannelFull
}

ChannelInfoResult contains the response to a ChannelInfo request.

type ChannelInviteResult

type ChannelInviteResult struct {
	APIResult
	Channel ChannelFull
}

ChannelInviteResult contains the response to a ChannelInvite request.

type ChannelJoinResult

type ChannelJoinResult struct {
	APIResult
	Already_In_Channel bool
	Channel            ChannelFull
}

ChannelJoinResult contains the response to a ChannelJoin request.

type ChannelKickResult

type ChannelKickResult struct {
	APIResult
}

ChannelKickResult contains the response to a ChannelKick request.

type ChannelLeaveResult

type ChannelLeaveResult struct {
	APIResult
	Not_In_Channel bool
}

ChannelLeaveResult contains the response to a ChannelLeave request.

type ChannelListResult

type ChannelListResult struct {
	APIResult
	Channels []ChannelSummary
}

ChannelListResult contains the response to a ChannelList request.

type ChannelMarkResult

type ChannelMarkResult struct {
	APIResult
}

ChannelMarkResult contains the response to a ChannelMark request.

type ChannelMinimal

type ChannelMinimal struct {
	Id         ChannelId
	Name       string
	Created    UnixTime
	Is_Channel bool
}

ChannelMinimal is returned in a ChannelRenameResult.

type ChannelPurpose

type ChannelPurpose struct {
	Value    string
	Creator  UserId
	Last_Set UnixTime
}

ChannelPurpose contains the "purpose" text, as well as the user who set the purpose and when

type ChannelRenameResult

type ChannelRenameResult struct {
	APIResult
	Channel ChannelMinimal
}

ChannelRenameResult contains the response to a ChannelRename request.

type ChannelSetPurposeResult

type ChannelSetPurposeResult struct {
	APIResult
	Purpose string
}

ChannelSetPurposeResult contains the response to a ChannelSetPurpose request.

type ChannelSetTopicResult

type ChannelSetTopicResult struct {
	APIResult
	Topic string
}

ChannelSetTopicResult contains the response to a ChannelSetTopic request.

type ChannelSummary

type ChannelSummary struct {
	ChannelBrief
	Is_Member   bool
	Num_Members uint
	Topic       ChannelTopic
	Purpose     ChannelPurpose
}

ChannelSummary expands on ChannelBrief to include fields used by eg ChannelListResult.

type ChannelTopic

type ChannelTopic struct {
	Value    string
	Creator  UserId
	Last_Set UnixTime
}

ChannelTopic contains the "topic" text, as well as the user who set the topic and when

type ChannelUnarchiveResult

type ChannelUnarchiveResult struct {
	APIResult
}

ChannelUnarchiveResult contains the response to a ChannelUnarchive request.

type GroupCreateResult

type GroupCreateResult struct {
	APIResult
	Group ChannelFull
}

type GroupFull

type GroupFull struct {
	Id          ChannelId
	Name        string
	Is_Group    bool
	Created     UnixTime
	Creator     UserId
	Is_Archived bool

	// Is_MPIM indicates this is a simulated private channel for an IM among 3+ users
	// This should never be true, because this only happens when API requests are made that
	// don't signal MPIM awareness, and this code is MPIM aware.
	Is_MPIM              bool
	Members              []UserId
	Topic                ChannelTopic
	Purpose              ChannelPurpose
	Last_Read            SlackTime
	Latest               Message
	Unread_Count         uint
	Unread_Count_Display uint
}

type HandyReactionsInfo

type HandyReactionsInfo struct {
	Restrict bool
	List     []ReactionListItem
}

type IMFull

type IMFull struct {
	Id              ChannelId
	Is_IM           bool
	Created         UnixTime
	OtherUser       UserId `json:"user"`
	Has_Pins        bool
	Is_User_Deleted bool
	Is_Open         bool
	Last_Read       SlackTime
	Latest          SlackTime // ?!
	Unread_Count    uint
}

type IconInfo

type IconInfo struct {
	Image_Default bool
	Image_34      string
	Image_44      string
	Image_68      string
	Image_88      string
	Image_102     string
	Image_132     string
	Image_230     string
}

type MPIMFull

type MPIMFull struct {
	Id                   ChannelId
	Name                 string
	Is_MPIM              bool
	Is_Group             bool
	Created              UnixTime
	Creator              UserId
	Members              []UserId
	Last_Read            SlackTime
	Latest               Message
	Unread_Count         uint
	Unread_Count_Display uint
}

type Message

type Message struct {
	Type       string
	Timestamp  SlackTime `json:"ts"`
	User       UserId
	Text       string
	Is_Starred bool
	Reactions  []Reaction
}

Message describes an event in a channel or private message.

type RTMMessage

type RTMMessage struct {
	Type     string
	Ts       SlackTime
	Channel  ChannelId `json:",omitempty"`
	User     UserId    `json:",omitempty"`
	Text     string    `json:",omitempty"`
	Presence string    `json:",omitempty"`
}

type RTMMessageChan

type RTMMessageChan chan *RTMMessage

type RTMSendMessageRequest

type RTMSendMessageRequest struct {
	Id      uint64 `json:"id"`
	Type    string `json:"type"`
	Channel string `json:"channel"`
	Text    string `json:"text"`
}

type RTMStartResult

type RTMStartResult struct {
	APIResult
	URL      string
	Self     UserBrief
	Team     TeamSummary
	Users    []UserSummary
	Channels []ChannelSummary
	Groups   []GroupFull
	MPIMs    []MPIMFull
	IMs      []IMFull
}

RTMStartResult contains the response to a RTMStart request, and a bunch of details about the Slack you're about to start receiving streaming events for.

func (*RTMStartResult) Dial

func (rsr *RTMStartResult) Dial() (rtm *SlackRTM, err error)

type Reaction

type Reaction struct {
	Name  string
	Count uint
	Users []UserId
}

Reaction describes an emoji attachment to a message.

type ReactionListItem

type ReactionListItem struct {
	Name  string
	Title string
}

type Slack

type Slack struct {
	// contains filtered or unexported fields
}

func New

func New(token string) (s *Slack)

func (*Slack) APITest

func (s *Slack) APITest(fail bool) (res *APITestResult, err error)

APITest issues a call against the Slack API, which you can optionally force to return unsuccessfully.

func (*Slack) AuthRevoke

func (s *Slack) AuthRevoke(test bool) (res *AuthRevokeResult, err error)

AuthRevoke will cause the current authentication token associated with `s` to be revoked, for instance if the user is logging out. Don't use this with bot tokens. Set `test` to exercise the API without really revoking anything.

func (*Slack) AuthTest

func (s *Slack) AuthTest() (res *AuthTestResult, err error)

AuthTest will ask the API whether our authentication token is valid, and if so, give us some boilerplate information about the token

func (*Slack) BotsInfo

func (s *Slack) BotsInfo(botid string) (res *BotsInfoResult, err error)

BotsInfo requests information from Slack about bot named by `botid`. Use an empty string (ie "") to elide this optional parameter.

func (*Slack) ChannelArchive

func (s *Slack) ChannelArchive(channel ChannelId) (res *ChannelArchiveResult, err error)

ChannelArchive causes the public channel named by `channel` to be archived.

func (*Slack) ChannelCreate

func (s *Slack) ChannelCreate(name string) (res *ChannelCreateResult, err error)

ChannelCreate creates a new "public" channel named `name`.

func (*Slack) ChannelHistory

func (s *Slack) ChannelHistory(channel ChannelId, count uint, oldest, latest SlackTime) (res *ChannelHistoryResult, err error)

ChannelHistory requests that the server send us events from a "public" channel identified by `channel`, requesting up to `count` events, optionally bounded by `oldest` and/or `latest` (which can be "" to exclude). Regarding the API, note that the range of timestamps requested will always be inclusive (we always set inclusive=1) and the optional unread_count_display field will always be included (we always set unreads=1). `count` may range from 1 to 1000; the API specifies a default of 100.

func (*Slack) ChannelInfo

func (s *Slack) ChannelInfo(channel ChannelId) (res *ChannelInfoResult, err error)

ChannelInfo requests more detailed info about the channel named by `channel`.

func (*Slack) ChannelInvite

func (s *Slack) ChannelInvite(channel ChannelId, user UserId) (res *ChannelInviteResult, err error)

ChannelInvite invites a user into a "public" channel we currently occupy.

func (*Slack) ChannelJoin

func (s *Slack) ChannelJoin(name string) (res *ChannelJoinResult, err error)

ChannelJoin joins a new "public" channel named `name`, or creates it.

func (*Slack) ChannelKick

func (s *Slack) ChannelKick(channel ChannelId, user UserId) (res *ChannelKickResult, err error)

ChannelKick removes a user from a "public" channel.

func (*Slack) ChannelLeave

func (s *Slack) ChannelLeave(channel ChannelId) (res *ChannelLeaveResult, err error)

ChannelLeave departs the channel named by `channel`.

func (*Slack) ChannelList

func (s *Slack) ChannelList(excludeArchived bool) (res *ChannelListResult, err error)

ChannelList requests the list of "public" channels available on the server.

func (*Slack) ChannelMark

func (s *Slack) ChannelMark(channel ChannelId, ts SlackTime) (res *ChannelMarkResult, err error)

ChannelMark updates server as to the latest message received in the channel named by `channel`.

func (*Slack) ChannelRename

func (s *Slack) ChannelRename(channel ChannelId, name string) (res *ChannelRenameResult, err error)

ChannelRename changes the name of the channel named by `channel`.

func (*Slack) ChannelSetPurpose

func (s *Slack) ChannelSetPurpose(channel ChannelId, purpose string) (res *ChannelSetPurposeResult, err error)

ChannelSetPurpose changes the "purpose" of the channel named by `channel`. The purpose may be up to 250 characters.

func (*Slack) ChannelSetTopic

func (s *Slack) ChannelSetTopic(channel ChannelId, topic string) (res *ChannelSetTopicResult, err error)

ChannelSetTopic changes the "topic" of the channel named by `channel`. The topic may be up to 100 characters.

func (*Slack) ChannelUnarchive

func (s *Slack) ChannelUnarchive(channel ChannelId) (res *ChannelUnarchiveResult, err error)

ChannelUnarchive causes the public channel named by `channel` to be unarchived.

func (*Slack) GroupCreate

func (s *Slack) GroupCreate(name string) (res *GroupCreateResult, err error)

func (*Slack) RTMStart

func (s *Slack) RTMStart(simpleLatest, noUnreads bool) (res *RTMStartResult, err error)

RTMStart request a special Websocket URL plus a ton of anciliary information about the Slack instance we'll be talking to. `simpleLatest` will elide the timestamps for all but the most recent messages in each channel. `noUnreads` will skip counts for unread messages per channel.

type SlackRTM

type SlackRTM struct {
	Id chan uint64

	ChannelsLock sync.RWMutex
	Channels     map[ChannelId]*SlackRTMChannel
	// contains filtered or unexported fields
}

func (*SlackRTM) OpenChannel

func (rtm *SlackRTM) OpenChannel(c ChannelId) (rtmc *SlackRTMChannel)

type SlackRTMChannel

type SlackRTMChannel struct {
	Rx RTMMessageChan
	// contains filtered or unexported fields
}

func (*SlackRTMChannel) Close

func (rtmc *SlackRTMChannel) Close()

func (*SlackRTMChannel) Send

func (rtmc *SlackRTMChannel) Send(text string) (err error)

type SlackTime

type SlackTime string

SlackTime is a string that represents an unambiguously-sortable timeline event. It appears to be encoded as a unix timestamp, plus a dot, plus a zero-padded atomic index for each event that happens in that second. SlackTimes are mostly used for finding relative events (ie happened before, happened after) and not for precise time.

type TeamPrefs

type TeamPrefs struct {
	Display_Email_Addresses             bool
	Allow_Shared_Channel_Perms_Override bool
	Default_Channels                    []ChannelId
	Who_Can_Create_Groups               string // "ra", ... set of runes describing capable users?
	Warn_Before_At_Channel              string // "always", ...
	Auth_Mode                           string // "normal", ...
	Invites_Only_Admins                 bool
	Retention_Type                      int // 0, ...
	Allow_Retention_Override            bool
	Who_Has_Team_Visibility             string // "ra", ...
	Who_Can_Kick_Channels               string // "admin", ...
	Who_Can_Edit_User_Groups            string // "admin", ...
	Msg_Edit_Window_Mins                int
	Group_Retention_Duration            int
	Group_Retention_Type                int // 0, ...
	Allow_Shared_Channels               bool
	Invites_Limit                       bool
	Who_Can_At_Everyone                 string // "regular", ...
	Who_Can_Create_Channels             string // "regular", ...
	Who_Can_Archive_Channsl             string // "regular", ...
	Retention_Duration                  int
	Require_At_For_Mention              bool
	Who_Can_Create_Shared_Channels      string // "admin", ...
	Hide_Referers                       bool
	Calling_App_Name                    string // "Slack", ...
	Who_Can_Post_General                string // "ra", ...
	Who_Can_Kick_Groups                 string // "regular", ...
	Compliance_Export_Start             int    // 0, ...
	Allow_Message_Deletion              bool
	Allow_Calls                         bool
	Display_Real_Names                  bool
	Who_Can_At_Channel                  string // "ra", ...
	Who_Can_Create_Delete_User_Groups   string // "admin", ...
	Who_Can_Change_Team_Profile         string // "admin", ...

	DM_Retention_Duration int
	DM_Retention_Type     int // 0, ...

	Disable_File_Editing      bool
	Disable_File_Deleting     bool
	Disable_File_Uploads      string // "allow_all", ...
	Disallow_Public_File_URLs bool
	File_Retention_Duration   int
	File_Retention_Type       int // 0, ...

	Default_Rxns       []string // Rxns -> Reactions
	Team_Handy_Rxns    HandyReactionsInfo
	Channel_Handy_Rxns HandyReactionsInfo

	DND_Start_Hour string // "22:00", ...
	DND_End_Hour   string // "08:00", ...
	DND_Enabled    bool

	// These are not well-documented and look mostly useless
	Who_Can_Manage_Shared_Channels  interface{}
	Who_Can_Manage_Integrations     interface{}
	Who_Can_Post_In_Shared_Channels interface{}
}

type TeamSummary

type TeamSummary struct {
	Id                      string
	Name                    string
	Email_Domain            string // ie anybody@(email_domain) can sign up
	Domain                  string // ie (domain).slack.com
	Icon                    IconInfo
	Msg_Edit_Window_Mins    int
	Over_Storage_Limit      bool
	Over_Integrations_Limit bool
	Plan                    string
	Prefs                   TeamPrefs
}

type UnixTime

type UnixTime uint64

UnixTime is simply your bog-standard Unix epoch counter, such as used by time.Unix. No nanoseconds.

type UserBrief

type UserBrief struct {
	Id              UserId
	Name            string
	Prefs           interface{}
	Created         UnixTime
	Manual_Presence string
}

type UserId

type UserId string

A UserId is an opque string that represents a user or a bot.

type UserSummary

type UserSummary struct {
	UserBrief
	Deleted             bool
	Color               string
	Profile             map[string]string
	Is_Admin            bool
	Is_Owner            bool
	Is_Primary_Owner    bool
	Is_Restricted       bool
	Is_Ultra_Restricted bool
	Has_2FA             bool
	Two_Factor_Type     string // only present if Has_2FA is true
	Has_Files           bool
}

Jump to

Keyboard shortcuts

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