slack

package
v0.0.0-...-4629a29 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResp

type APIResp struct {
	Ok       bool      `json:"ok"`
	Self     Self      `json:"self"`
	Error    string    `json:"error"`
	Users    []User    `json:"users"`
	Channels []Channel `json:"channels"`
	URL      string    `json:"url"`
}

APIResp represents the API response of rtm.start See https://api.slack.com/methods/rtm.start

type Channel

type Channel struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	IsChannel  bool   `json:"is_channel"`
	Creator    string `json:"creator"`
	IsArchived bool   `json:"is_archived"`
}

type Client

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

func NewClient

func NewClient(botToken string) (sc *Client)

func (*Client) Close

func (sc *Client) Close()

func (*Client) Connect

func (sc *Client) Connect() (err error)

func (*Client) Connected

func (sc *Client) Connected() bool

func (*Client) HandleFunc

func (sc *Client) HandleFunc(msgType string, hf HandlerFunc)

func (*Client) IsSelfMsg

func (sc *Client) IsSelfMsg(event *Event) bool

func (*Client) Send

func (sc *Client) Send(target, msg string)

type Error

type Error struct {
	Code int    `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
}

type Event

type Event struct {
	ID          int64  `json:"id"` // Every event should have a unique (for that connection) positive integer ID.
	Error       *Error `json:"error,omitempty"`
	Type        string `json:"type"`
	ChannelID   string `json:"channel"`
	Channelname string `json:"-"`
	UserID      string `json:"user,omitempty"`
	Username    string `json:"-"`
	Text        string `json:"text,omitempty"`
	Presence    string `json:"presence,omitempty"` //active, away
	SubType     string `json:"subtype,omitempty"`
	Team        string `json:"team,omitempty"`
	Ts          string `json:"ts,omitempty"`
}

func (*Event) Chan

func (se *Event) Chan() string

func (*Event) Msg

func (se *Event) Msg() string

func (*Event) Usernick

func (se *Event) Usernick() string

type EventType

type EventType struct {
	Type string `json:"type"`
}

type File

type File struct {
	ID       string   `json:"id"` // Every event should have a unique (for that connection) positive integer ID.
	UserID   string   `json:"user,omitempty"`
	PubPerma string   `json:"permalink_public,omitempty"`
	Channels []string `json:"channels,omitempty"`
}

type FileApiResp

type FileApiResp struct {
	OK    bool   `json:"ok"`
	Error string `json:"error,omitempty"`
	File  *File  `json:"file,omitempty"`
}

type FileEvent

type FileEvent struct {
	Type   string `json:"type"`
	FileID string `json:"file_id"`
}

UserEvent carries a UserProfile instead of a UserID under the `user` key (in contrast to Event)

type HandlerFunc

type HandlerFunc func(*Client, *Event)

type Profile

type Profile struct {
	DisplayName           string `json:"display_name"`
	DisplayNameNormalized string `json:"display_name_normalized,omitempty"`
}

type Self

type Self struct {
	ID   string
	Name string
}

type User

type User struct {
	ID       string    `json:"id"`
	Name     string    `json:"name"`
	RealName string    `json:"real_name,omitempty"`
	Profile  Profile   `json:"profile"`
	Deleted  bool      `json:"deleted"`
	IsBot    bool      `json:"is_bot"`
	IsAdmin  bool      `json:"is_admin"`
	Presence string    `json:"presence"` //active, away
	LastSeen time.Time `json:"-"`
}

type UserEvent

type UserEvent struct {
	ID          int64  `json:"id"` // Every event should have a unique (for that connection) positive integer ID.
	Error       *Error `json:"error,omitempty"`
	Type        string `json:"type"`
	ChannelID   string `json:"channel,omitempty"`
	Channelname string `json:"-"`
	User        *User  `json:"user,omitempty"`
	Text        string `json:"text,omitempty"`
	Ts          string `json:"ts,omitempty"`
}

UserEvent carries a UserProfile instead of a UserID under the `user` key (in contrast to Event)

Jump to

Keyboard shortcuts

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