slack

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMessage     = "message"
	UserInviteLimit = 30
)

Slack consts

Variables

This section is empty.

Functions

func CreateNewConversation

func CreateNewConversation(token, conversationName string, isPrivate bool) (string, error)

CreateNewConversation creates new Slack conversation and returns its ID and error, if any

func DialWS added in v1.0.4

func DialWS(config *ws.Config) (conn *ws.Conn, err error)

DialWS wraps ws.DialConfig

func FindDMByUserID

func FindDMByUserID(token, userID string) (string, error)

FindDMByUserID returns Slack IM ID for the provided user ID

func GetConversationMembers

func GetConversationMembers(token, chanID string) ([]string, error)

GetConversationMembers returns the Slack conversation member list by conversation ID

func InitWSConfig added in v1.0.4

func InitWSConfig(token string) (config *ws.Config, userID string, err error)

InitWSConfig creates a websocket-based Real Time API session and returns the websocket config and the ID of the bot/user whom the token belongs to.

func InviteMembersToConversation

func InviteMembersToConversation(token, chanID string, memberIDs []string) error

InviteMembersToConversation adds members from the slice to the Slack conversation

func SendAPIMessage

func SendAPIMessage(token, chanID, message string) error

SendAPIMessage sends a message with Web API

func SendWSMessage

func SendWSMessage(conn *ws.Conn, m Message) error

SendWSMessage sends a message with RTM API

Types

type Conversation

type Conversation struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Created     int64     `json:"created"`
	IsArchived  bool      `json:"is_archived"`
	IsGeneral   bool      `json:"is_general"`
	Creator     string    `json:"creator"`
	NameNorm    string    `json:"name_normalized"`
	IsReadOnly  bool      `json:"is_read_only"`
	IsShared    bool      `json:"is_shared"`
	IsOrgShared bool      `json:"is_org_shared"`
	IsMember    bool      `json:"is_member"`
	IsPrivate   bool      `json:"is_private"`
	Topic       TopicInfo `json:"topic"`
	Purpose     TopicInfo `json:"purpose"`
}

Conversation describes Slack conversation

func GetConversationInfo

func GetConversationInfo(token, chanID string) (*Conversation, error)

GetConversationInfo returns info about the Slack conversation by its ID

func GetConversations

func GetConversations(token string, withArchived bool) ([]Conversation, error)

GetConversations returns info about all of the public and private Slack conversations in the workspace

type IM

type IM struct {
	ID            string `json:"id"`
	Created       int64  `json:"created"`
	IsIM          bool   `json:"is_im"`
	IsOrgShared   bool   `json:"is_org_shared"`
	User          string `json:"user"`
	IsUserDeleted bool   `json:"is_user_deleted"`
}

IM describes Slack instant message channel

type Message

type Message struct {
	ID           uint64 `json:"id"`
	User         string `json:"user,omitempty"`
	Type         string `json:"type"`
	Conversation string `json:"channel"`
	Text         string `json:"text"`
}

Message describes Slack messages

func GetWSMessage

func GetWSMessage(conn *ws.Conn) (m Message, err error)

GetWSMessage receives a message from RTM API

type TopicInfo

type TopicInfo struct {
	Value   string `json:"value"`
	Creator string `json:"creator"`
	LastSet int64  `json:"last_set"`
}

TopicInfo describes topic or purpose

type UserProfile

type UserProfile struct {
	ID              string `json:"id,omitempty"`
	Title           string `json:"title"`
	Phone           string `json:"phone"`
	Skype           string `json:"skype"` // used for birthday dates
	RealName        string `json:"real_name"`
	RealNameNorm    string `json:"real_name_norm"`
	DisplayName     string `json:"display_name"`
	DisplayNameNorm string `json:"display_name_norm"`
	Email           string `json:"email"`
	FirstName       string `json:"first_name"`
	LastName        string `json:"last_name"`
	ImageOriginal   string `json:"image_original"`
}

UserProfile describes Slack user profile

func GetUserProfile

func GetUserProfile(token, userID string) (*UserProfile, error)

GetUserProfile returns the Slack user's profile by user ID

Jump to

Keyboard shortcuts

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