slack

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlackOriginUrl = "https://api.slack.com/"
)

Variables

This section is empty.

Functions

func GetSlackChannelName

func GetSlackChannelName(input string) string

func GetSlackUserName

func GetSlackUserName(input string) string

func IsSlackChannelName

func IsSlackChannelName(input string) bool

func IsSlackUserName

func IsSlackUserName(input string) bool

func Start

func Start(token string) (wsurl, id string, err error)

slackStart does a rtm.start, and returns a websocket URL and user ID. The websocket URL can be used to initiate an RTM session.

Types

type Client

type Client struct {
	Id string
	// contains filtered or unexported fields
}

Client defines a client for Slack API.

func (*Client) Connect

func (c *Client) Connect(token string) error

Starts a websocket-based Real Time API session and return the websocket and the ID of the (bot-)user whom the token belongs to.

func (*Client) GetMessage

func (c *Client) GetMessage() (m Message, err error)

func (*Client) GetTeamChannels

func (c *Client) GetTeamChannels() ([]SlackChannel, error)

func (*Client) GetTeamUsers

func (c *Client) GetTeamUsers() ([]SlackUser, error)

func (*Client) PostMessage

func (c *Client) PostMessage(m Message) error

type Message

type Message struct {
	Id      uint64 `json:"Id"`
	Type    string `json:"type"`
	Channel string `json:"channel"`
	Text    string `json:"text"`
	User    string `json:"user"`
}

These are the messages read off and written into the websocket. Since this struct serves as both read and write, we include the "Id" field which is required only for writing.

type SlackChannel

type SlackChannel struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type SlackChannelsResult

type SlackChannelsResult struct {
	Ok       bool           `json:"ok"`
	Channels []SlackChannel `json:"channels"`
}

type SlackMembersResult

type SlackMembersResult struct {
	Ok      bool        `json:"ok"`
	Members []SlackUser `json:"members"`
}

type SlackUser

type SlackUser struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	IsAdmin     bool   `json:"is_admin"`
	IsBot       bool   `json:"is_bot"`
	ProfileDesc string `json:"profileDesc"`
	Class       string `json:"class"`
}

Jump to

Keyboard shortcuts

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