slack

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

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

Go to latest
Published: Jun 9, 2023 License: BSD-3-Clause, MIT Imports: 8 Imported by: 0

README

slack-go

Connect to the Slack API.

Install

go mod init
go mod tidy

Documentation

Index

Constants

View Source
const Version = "0.1.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatService

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

func (*ChatService) DeleteMessage

func (c *ChatService) DeleteMessage(ctx context.Context, channelID, messageID string) (*response, error)

https://api.slack.com/methods/chat.delete

func (c *ChatService) GetPermalink(ctx context.Context, channelID, messageID string) (*permalinkResponse, error)

https://api.slack.com/methods/chat.getPermalink

`channelID` has to be the ID of the channel (C*), this endpoint does not support the encoded channel names (#foo).

func (*ChatService) PostMessage

func (c *ChatService) PostMessage(ctx context.Context, data url.Values) (*response, error)

https://api.slack.com/methods/chat.postMessage

type Client

type Client struct {
	*restclient.Client

	Chat  *ChatService
	Users *UserService
	// contains filtered or unexported fields
}

func New

func New(token string) *Client

func (*Client) CreateResource

func (c *Client) CreateResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error

CreateResource makes a POST request to the given resource.

func (*Client) ListResource

func (c *Client) ListResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error

func (*Client) MakeRequest

func (c *Client) MakeRequest(ctx context.Context, method string, pathPart string, data url.Values, v interface{}) error

Make a request to the Slack API.

func (*Client) SendMessage

func (c *Client) SendMessage(channel string, text string) error

SendMessage sends the text to the given channel. For more granular control use the client.Chat.PostMessage endpoint.

type SlackTime

type SlackTime struct {
	Time      time.Time
	Timestamp string
}

func (SlackTime) MarshalJSON

func (s SlackTime) MarshalJSON() ([]byte, error)

func (*SlackTime) UnmarshalJSON

func (s *SlackTime) UnmarshalJSON(data []byte) error

type User

type User struct {
	ID      string       `json:"id"`
	Name    string       `json:"name"`
	Updated SlackTime    `json:"updated"`
	Profile *UserProfile `json:"profile"`
}

type UserProfile

type UserProfile struct {
	Email string `json:"email"`
	Team  string `json:"team"`
}

type UserResponse

type UserResponse struct {
	User *User `json:"user"`
}

type UserService

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

func (*UserService) Get

func (u *UserService) Get(ctx context.Context, data url.Values) (*User, error)

Get information about a particular user. https://api.slack.com/methods/users.info

func (*UserService) List

func (u *UserService) List(ctx context.Context, data url.Values) (*UsersListResponse, error)

type UsersListResponse

type UsersListResponse struct {
	Members []*User `json:"members"`
}

Jump to

Keyboard shortcuts

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