slack

package module
v0.0.0-...-f5b9d6a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2016 License: MIT Imports: 7 Imported by: 2

README

slack-bot Build Status

A rough implementation of Slack API

APIs implemented

Usage

Check out the examples directory, or the repos

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func RtmSend

func RtmSend(ws *websocket.Conn, m Message) error

func RtmStart

func RtmStart(token string) (wsurl string, err error)

Calls rtm.start API, return websocket url and bot id

func ValidateCommand

func ValidateCommand(handler http.Handler, commands map[string]string) http.HandlerFunc

Types

type Attachment

type Attachment struct {
	Fallback   string   `json:"fallback"`
	Color      string   `json:"color"`
	Pretext    string   `json:"pretext"`
	AuthorName string   `json:"author_name"`
	Title      string   `json:"title"`
	TitleLink  string   `json:"title_link"`
	Text       string   `json:"text"`
	Fields     []Field  `json:"fields"`
	MrkdwnIn   []string `json:"mrkdwn_in"`
}

type Bot

type Bot struct {
	Token  string `json:"token"`
	UserId string `json:"user_id"`
	User   string `json:"user"`
	Client *http.Client
}

func NewBot

func NewBot(token string) *Bot

func (Bot) ChannelsHistory

func (b Bot) ChannelsHistory(params url.Values) ([]Message, error)

func (Bot) ChannelsInfo

func (b Bot) ChannelsInfo(channelId string) ([]string, error)

func (Bot) ChannelsList

func (b Bot) ChannelsList() ([]Channel, error)

func (Bot) ChatPostMessage

func (b Bot) ChatPostMessage(data url.Values) (err error)

func (*Bot) Get

func (b *Bot) Get(endpoint string, params url.Values) (*http.Response, error)

func (Bot) PostForm

func (b Bot) PostForm(endpoint string, data url.Values) (respJson map[string]interface{}, err error)

func (Bot) UsersGetPresence

func (b Bot) UsersGetPresence(user string) (presence string, err error)

func (Bot) UsersList

func (b Bot) UsersList(presence string) (present []string, err error)

for presence now

func (*Bot) WithClient

func (b *Bot) WithClient(c *http.Client) *Bot

type Channel

type Channel struct {
	Id       string   `json:"id"`
	Name     string   `json:"name"`
	IsMember bool     `json:"is_member"`
	Members  []string `json:"members"`
}

type ChannelsListResp

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

type Credentials

type Credentials struct {
	HookToken   string
	Bot         Bot
	SlackbotUrl string
	Commands    map[string]string
}

func LoadCredentials

func LoadCredentials(filename string) (credentials Credentials, err error)

type Field

type Field struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

type FileObject

type FileObject struct {
	Mimetype   string `json:"mimetype"`
	Filetype   string `json:"filetype"`
	PrettyType string `json:"pretty_type"`
}

type Message

type Message struct {
	Type        string       `json:"type"`
	SubType     string       `json:"subtype"`
	Channel     string       `json:"channel"`
	User        string       `json:"user"`
	Text        string       `json:"text"`
	Ts          string       `json:"ts"`
	File        FileObject   `json:"file"`
	Attachments []Attachment `json:"attachments"`
}

func RtmReceive

func RtmReceive(ws *websocket.Conn) (m Message, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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