slackapi

package module
v0.0.0-...-2326bb5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2016 License: MIT Imports: 7 Imported by: 0

README

Slack Bot API (IN DEVELOPMENT)

I'm tinkering with the Slack API to write some bots, and am not sure yet where this is going.

I'd recommend against relying on this for now.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDirectMessageChannel

func IsDirectMessageChannel(channelID string) bool

IsDirectMessageChannel returns whether the channel ID is formatted as a direct message channel

Types

type Channel

type Channel struct {
	ID                 string      `json:"id"`
	Name               string      `json:"name"`
	IsChannel          bool        `json:"is_channel"`
	Created            uint64      `json:"created"`
	Creator            string      `json:"creator"`
	IsArchived         bool        `json:"is_archived"`
	IsGeneral          bool        `json:"is_general"`
	Members            []string    `json:"members"`
	IsMember           bool        `json:"is_member"`
	LastRead           string      `json:"last_read"`
	UnreadCount        uint64      `json:"unread_count"`
	UnreadCountDisplay uint64      `json:"unread_count_display"`
	Topic              ChannelInfo `json:"topic"`
	Purpose            ChannelInfo `json:"purpose"`
}

Channel represents a Slack channel

func GetChannelInfo

func GetChannelInfo(token string, channelID string) (*Channel, error)

GetChannelInfo returns a *Channel from the input channelID

type ChannelInfo

type ChannelInfo struct {
	Value   string `json:"value"`
	Creator string `json:"creator"`
	LastSet uint64 `json:"last_set"`
}

ChannelInfo holds a text value set by a user - used in Channel

type RTMMessage

type RTMMessage struct {
	ID      uint64 `json:"id"`
	Type    string `json:"type"`
	Channel string `json:"channel"`
	Text    string `json:"text"`
	User    string `json:"user"`
}

RTMMessage is a real-time message sent/received to/from Slack

type RTMMessageErrorCode

type RTMMessageErrorCode struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

RTMMessageErrorCode is included in RTMMessageResponse on error

type RTMMessageResponse

type RTMMessageResponse struct {
	OK      bool `json:"ok"`       // success: true
	ReplyTo int  `json:"reply_to"` // ID of the request this responds to

	Text  string              `json:"text"`  // potentially modified version of the request
	Error RTMMessageErrorCode `json:"error"` // error, if OK==false
	// contains filtered or unexported fields
}

RTMMessageResponse is received in response to RTMMessage requests

type RealTimeMessager

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

RealTimeMessager sends/receives real-time messages from Slack

func NewRealTimeMessager

func NewRealTimeMessager(token string) (*RealTimeMessager, error)

NewRealTimeMessager returns a new RealTimeMessager

func (*RealTimeMessager) Connect

func (rtm *RealTimeMessager) Connect() error

Connect connects to the Slack real-time Messaging endpoint

func (*RealTimeMessager) ReceiveMessage

func (rtm *RealTimeMessager) ReceiveMessage() (*RTMMessage, error)

ReceiveMessage blocks while waiting for the next real-time message from Slack

func (*RealTimeMessager) SendMessage

func (rtm *RealTimeMessager) SendMessage(request RTMMessage) error

SendMessage sends a message request to Slack

type User

type User struct {
	ID      string `json:"id"`
	TeamID  string `json:"team_id"`
	Name    string `json:"name"`
	Deleted bool   `json:"deleted"`
	Color   string `json:"color"`
	Profile struct {
		FirstName string `json:"first_name"`
		LastName  string `json:"last_name"`
		RealName  string `json:"real_name"`
		Email     string `json:"email"`
		Skype     string `json:"skype"`
		Phone     string `json:"phone"`
		Image24   string `json:"image_24"`
		Image32   string `json:"image_32"`
		Image48   string `json:"image_48"`
		Image72   string `json:"image_72"`
		Image192  string `json:"image_192"`
	} `json:"profile"`
	IsAdmin  bool `json:"is_admin"`
	IsOwner  bool `json:"is_owner"`
	Has2FA   bool `json:"has_2va"`
	HasFiles bool `json:"has_files"`
}

User represents a Slack user

func GetUserInfo

func GetUserInfo(token string, userID string) (*User, error)

GetUserInfo returns a *User from the input userID

Jump to

Keyboard shortcuts

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