slack

package
v0.0.0-...-d2e4c14 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeMessage indicates that incoming message type is "message"
	TypeMessage = "message"

	// TypeMessageDeleted indicates that incoming message type is
	// "message_deleted"
	TypeMessageDeleted = "message_deleted"

	// TypeMessageChanged indicates that the incoming message type is
	// "message_changed"
	TypeMessageChanged = "message_changed"

	// TypeReactionAdded indicates that incoming message type is "reaction_added"
	TypeReactionAdded = "reaction_added"

	// TypeReactionRemoved indicates that incoming message type is
	// "reaction_removed"
	TypeReactionRemoved = "reaction_removed"

	// TypeEmojiChanged indicates that incoming message type is "emoji_changed"
	TypeEmojiChanged = "emoji_changed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Token        string
	Users        map[string]RTMUser
	Channels     map[string]RTMChannel
	WebSocketURL string
	Channel      chan RTMMessage
}

Client provides an abstration to the Slack Real-Time API. After connecting, it caches known Channels and Users in order to perform querying operations and replacing Users and Channels IDs from incoming data with their respective instances.

func (*Client) Listen

func (c *Client) Listen()

Listen initializes the WebSocket connection with the remote RTM server, and pushes incoming messages into the provided channel.

type RTMChannel

type RTMChannel struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	IsChannel bool   `json:"is_channel"`
	IsMember  bool   `json:"is_member"`
}

RTMChannel represents an channel or group from the Team account

type RTMMessage

type RTMMessage struct {
	Type           string      `json:"type"`
	SubType        string      `json:"subtype"`
	Message        string      `json:"txt"`
	DeletionTarget string      `json:"deleted_ts"`
	EventTimestamp string      `json:"event_ts"`
	ChannelID      string      `json:"channel"`
	UserID         string      `json:"user"`
	Timestamp      string      `json:"ts"`
	Reaction       string      `json:"reaction"`
	Item           *RTMMessage `json:"item"`
	Client         Client
	Channel        RTMChannel
	User           RTMUser
}

RTMMessage is the common structure used to unmarshal incoming common data from the remote RTM server

type RTMUser

type RTMUser struct {
	ID       string         `json:"id"`
	Username string         `json:"name"`
	Deleted  bool           `json:"deleted"`
	Profile  RTMUserProfile `json:"profile"`
}

RTMUser represents an User that belongs to the Team account

type RTMUserProfile

type RTMUserProfile struct {
	RealName       string `json:"real_name"`
	ProfilePicture string `json:"image_192"`
	Title          string `json:"title"`
}

RTMUserProfile represents the Profile section of a given RTMUser

Jump to

Keyboard shortcuts

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