slack

package
v0.0.0-...-d726a1a Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseStyleFull = ParseStyle("full")
	ParseStyleNone = ParseStyle("none")
)
View Source
const (
	ResponseTypeEphermal  ResponseType = "ephemeral"
	ResponseTypeInChannel              = "in_channel"
	ResponseTypeDelayed                = "__delayed"
)
View Source
const MessageTSCharsAfterDot = 6
View Source
const MsgFieldRawBytes = "_rawBytes"

Variables

This section is empty.

Functions

func ArchiveURL

func ArchiveURL(teamDomain string, channelName string, msgID MessageID) string

func IsDMChannel

func IsDMChannel(channel ChannelID) bool

func ReplaceEntities

func ReplaceEntities(msg string, f func(e Entity) string) string

func UnescapeAngleBrackets

func UnescapeAngleBrackets(msg string) string

func UnescapeText

func UnescapeText(msg string) string

UnescapeText unwraps URLs in a Slack message and otherwise canonicalizes certain entities for use by Marvin.

Notably, &lt; and &gt; are left alone to prevent someone from typing <!everyone> and having Marvin repeat it as a @everyone.

func UnescapeTextAll

func UnescapeTextAll(msg string) string

Types

type APIResponse

type APIResponse struct {
	OK         bool   `json:"ok"`
	SlackError string `json:"error"`
	Warning    string `json:"warning"`
}

func (APIResponse) Error

func (r APIResponse) Error() string

type Attachment

type Attachment struct {
	Fallback      string            `json:"fallback"`
	Pretext       string            `json:"pretext,omitempty"`
	Text          string            `json:"text,omitempty"`
	Color         string            `json:"color,omitempty"`
	Fields        []AttachmentField `json:"fields,omitempty"`
	AuthorName    string            `json:"author_name,omitempty"`
	AuthorLink    string            `json:"author_link,omitempty"`
	AuthorIcon    string            `json:"author_icon,omitempty"`
	AuthorSubname string            `json:"author_subname,omitempty"`
	Title         string            `json:"title,omitempty"`
	TitleLink     string            `json:"title_link,omitempty"`
	TS            int64             `json:"ts,omitempty"`
	ImageURL      string            `json:"image_url,omitempty"`
	Footer        string            `json:"footer,omitempty"`
	FooterIcon    string            `json:"footer_icon,omitempty"`
	FromURL       string            `json:"from_url,omitempty"`
	ServiceName   string            `json:"service_name,omitempty"`
	ServiceURL    string            `json:"service_url,omitempty"`
}

type AttachmentField

type AttachmentField struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short,omitempty"`
}

type Channel

type Channel struct {
	CacheTS  time.Time `json:"-"`
	NotExist bool      `json:"-"`

	ID         ChannelID
	Name       string
	IsChannel  bool        `json:"is_channel"`
	IsGroup    interface{} `json:"is_group"`
	IsMPIM     interface{} `json:"is_mpim"`
	Created    int         // unix millis
	Creator    UserID
	IsArchived bool `json:"is_archived"`
	IsGeneral  bool `json:"is_general"`
	HasPins    bool `json:"has_pins"`

	// The Members element may be out of date. The rtm.Client keeps an up-to-date list of
	// channel memberships for public and private channels. This can be used for MPIMs, however.
	Members    []UserID `json:"members"`
	NumMembers int      `json:"num_members"`

	// IM only
	IsUserDeleted bool `json:"is_user_deleted"`
	IsOpen        bool `json:"is_open"`

	Topic   ChannelTopicPurpose
	Purpose ChannelTopicPurpose
}

func (*Channel) IsMultiIM

func (c *Channel) IsMultiIM() bool

func (*Channel) IsPrivateChannel

func (c *Channel) IsPrivateChannel() bool

func (*Channel) IsPublicChannel

func (c *Channel) IsPublicChannel() bool

type ChannelID

type ChannelID string

func ParseChannelID

func ParseChannelID(arg string) ChannelID

type ChannelIM

type ChannelIM struct {
	ID            ChannelID `json:"id"`
	User          UserID    `json:"user"`
	Created       int64     `json:"created"`
	IsUserDeleted bool      `json:"is_user_deleted"`
}

type ChannelTopicPurpose

type ChannelTopicPurpose struct {
	Value   string
	Creator UserID
	LastSet float64 `json:"last_set"`
}

type CodedError

type CodedError struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func (CodedError) Error

func (ce CodedError) Error() string

type EditMessage

type EditMessage struct {
	RTMRawMessage
}

func (EditMessage) AssertText

func (m EditMessage) AssertText() bool

func (EditMessage) EditHash

func (m EditMessage) EditHash() map[string]interface{}

func (EditMessage) EditingUserID

func (m EditMessage) EditingUserID() UserID

func (EditMessage) EventTS

func (m EditMessage) EventTS() MessageTS

func (EditMessage) MessageID

func (m EditMessage) MessageID() MessageID

func (EditMessage) MessageTS

func (m EditMessage) MessageTS() MessageTS

func (EditMessage) MessageUserID

func (m EditMessage) MessageUserID() UserID

func (EditMessage) Subtype

func (m EditMessage) Subtype() string

func (EditMessage) Text

func (m EditMessage) Text() string

func (EditMessage) UserID

func (m EditMessage) UserID() UserID

type EnterpriseID

type EnterpriseID string

type Entity

type Entity struct {
	Type  string
	Left  string
	Mid   string
	Right string
}

type FileCommentID

type FileCommentID string

type FileID

type FileID string

type IncomingReaction

type IncomingReaction struct {
	Type       string
	IsRemoval  bool
	UserID     UserID
	Reaction   string
	ItemUserID UserID
	Item       struct {
		Type string
		// type = message
		MsgChannelID ChannelID
		MsgTS        MessageTS
		// type = file
		FileID FileID
		// type = file_comment
		FileCommentID FileCommentID
	}
}

type LatestMsg

type LatestMsg struct {
	User    string    `json:"user"`
	Text    string    `json:"text"`
	Type    string    `json:"type"`
	Subtype string    `json:"subtype"`
	Ts      MessageTS `json:"ts"`
}

type MessageID

type MessageID struct {
	ChannelID
	MessageTS
}

func MsgID

func MsgID(ch ChannelID, ts MessageTS) MessageID

type MessageTS

type MessageTS string

type OutgoingSlackMessage

type OutgoingSlackMessage struct {
	Text        string        `json:"text,omitempty"`
	ThreadTS    MessageTS     `json:"thread_ts,omitempty"`
	Attachments []Attachment  `json:"attachments,omitempty"`
	UnfurlLinks util.TriValue `json:"unfurl_links,omitempty"`
	UnfurlMedia util.TriValue `json:"unfurl_media,omitempty"`
	Parse       ParseStyle    `json:"parse,omitempty"`
	LinkNames   util.TriValue `json:"link_names,omitempty"`
	Markdown    util.TriValue `json:"mrkdwn,omitempty"`
}

type ParseStyle

type ParseStyle string

type PinnedItem

type PinnedItem struct {
	Type      string    `json:"type"`
	Channel   ChannelID `json:"channel"`
	Created   int64     `json:"created"`
	CreatedBy UserID    `json:"created_id"`

	Message struct {
		TS        MessageTS `json:"ts"`
		Permalink string    `json:"permalink"`
	} `json:"message"`
	File struct {
		ID        FileID `json:"id"`
		Permalink string `json:"permalink"`
	} `json:"file"`
	Comment struct {
		ID      FileCommentID `json:"id"`
		Comment string
	} `json:"comment"`
}

type Profile

type Profile struct {
	DisplayName        string `json:"display_name_normalized"`
	RealName           string `json:"real_name"`
	RealNameNormalized string `json:"real_name_normalized"`
	FirstName          string `json:"first_name"`
	LastName           string `json:"last_name"`
	Email              string `json:"email"`
	Phone              string `json:"phone"`
	Title              string `json:"title"`
	Skype              string `json:"skype"`
	Image24            string `json:"image_24"`
	Image32            string `json:"image_32"`
	Image48            string `json:"image_48"`
	Image72            string `json:"image_72"`
	Image128           string `json:"image_128"`
	Image192           string `json:"image_192"`
	Image512           string `json:"image_512"`
	Image1024          string `json:"image_1024"`
	ImageOriginal      string `json:"image_original"`
}

type RTMRawMessage

type RTMRawMessage map[string]interface{}

func (RTMRawMessage) AssertText

func (m RTMRawMessage) AssertText() bool

func (RTMRawMessage) Attachments

func (m RTMRawMessage) Attachments() []Attachment

func (RTMRawMessage) ChannelID

func (m RTMRawMessage) ChannelID() ChannelID

func (RTMRawMessage) EventTS

func (m RTMRawMessage) EventTS() MessageTS

func (RTMRawMessage) IsHidden

func (m RTMRawMessage) IsHidden() bool

func (RTMRawMessage) MessageID

func (m RTMRawMessage) MessageID() MessageID

func (RTMRawMessage) MessageTS

func (m RTMRawMessage) MessageTS() MessageTS

func (RTMRawMessage) Okay

func (m RTMRawMessage) Okay() bool

func (RTMRawMessage) Original

func (m RTMRawMessage) Original() []byte

func (RTMRawMessage) ReMarshal

func (m RTMRawMessage) ReMarshal(v interface{}) error

func (RTMRawMessage) ReplyTo

func (m RTMRawMessage) ReplyTo() int

func (RTMRawMessage) String

func (m RTMRawMessage) String() string

func (RTMRawMessage) StringField

func (m RTMRawMessage) StringField(field string) string

func (RTMRawMessage) Subtype

func (m RTMRawMessage) Subtype() string

func (RTMRawMessage) Text

func (m RTMRawMessage) Text() string

func (RTMRawMessage) Type

func (m RTMRawMessage) Type() string

func (RTMRawMessage) UserID

func (m RTMRawMessage) UserID() UserID

type ResponseType

type ResponseType string

type SelfPrefs

type SelfPrefs struct {
	MutedChannels string `json:"muted_channels"`
}

type SlackTextMessage

type SlackTextMessage interface {
	UserID() UserID
	ChannelID() ChannelID
	MessageID() MessageID
	MessageTS() MessageTS
	EventTS() MessageTS
	Subtype() string
	Text() string
	AssertText() bool
}

type SlashCommandRequest

type SlashCommandRequest struct {
	Token       string
	TeamId      TeamID    `schema:"team_id"`
	TeamDomain  string    `schema:"team_domain"` // no .slack.com
	ChannelId   ChannelID `schema:"channel_id"`
	ChannelName string    `schema:"channel_name"`
	UserId      UserID    `schema:"user_id"`
	UserName    string    `schema:"user_name"`
	Command     string
	Text        string
	Msg         RTMRawMessage `schema:"-"`
	ResponseURL string        `schema:"response_url"`
}

type SlashCommandResponse

type SlashCommandResponse struct {
	OutgoingSlackMessage
	ResponseType ResponseType `json:"response_type,omitempty"`
}

type TeamID

type TeamID string

type TeamInfo

type TeamInfo struct {
	ID                    TeamID `json:"id"`
	Name                  string
	Domain                string
	EmailDomain           string `json:"email_domain"`
	Icon                  interface{}
	MsgEditWindowMins     float64 `json:"msg_edit_window_mins"`
	OverStorageLimit      bool    `json:"over_storage_limit"`
	Prefs                 interface{}
	Plan                  string
	AvatarBaseURL         string `json:"avatar_base_url"`
	OverIntegrationsLimit bool   `json:"over_integrations_limit"`
}

type User

type User struct {
	NotExist bool      `json:"-"`
	CacheTS  time.Time `json:"-"`

	ID                UserID      `json:"id"`
	TeamID            TeamID      `json:"team_id"`
	Name              string      `json:"-"`
	Deleted           bool        `json:"deleted"`
	Status            interface{} `json:"status"`
	Color             string      `json:"color"`
	RealName          string      `json:"real_name"`
	Tz                string      `json:"tz"`
	TzLabel           string      `json:"tz_label"`
	TzOffset          int         `json:"tz_offset"`
	Updated           int64       `json:"updated"`
	Profile           Profile     `json:"profile"`
	IsAdmin           bool        `json:"is_admin"`
	IsOwner           bool        `json:"is_owner"`
	IsPrimaryOwner    bool        `json:"is_primary_owner"`
	IsRestricted      bool        `json:"is_restricted"`
	IsUltraRestricted bool        `json:"is_ultra_restricted"`
	IsBot             bool        `json:"is_bot"`
	Presence          string      `json:"presence"`
	Has2Fa            bool        `json:"has_2fa,omitempty"`
}

func (*User) Avatar

func (u *User) Avatar(size int) string

type UserID

type UserID string

func ParseUserMention

func ParseUserMention(arg string) UserID

func (UserID) Format

func (u UserID) Format(f fmt.State, c rune)

func (UserID) Raw

func (u UserID) Raw() string

func (UserID) ToAtForm

func (u UserID) ToAtForm() string

Directories

Path Synopsis
The controller package implements the Team type.
The controller package implements the Team type.

Jump to

Keyboard shortcuts

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