Documentation ¶
Index ¶
- Constants
- type Attachment
- type Client
- func (c *Client) PostMessage(ctx context.Context, channelID string, msg string) (*MessageResponse, error)
- func (c *Client) RefreshUsersCache(ctx context.Context) error
- func (c *Client) RespondToCommand(ctx context.Context, responseURL string, msg string, visible bool) error
- func (c *Client) UploadImage(ctx context.Context, channels []string, ...) error
- func (c *Client) User(id string) (User, bool)
- func (c *Client) UserID(name string) string
- func (c *Client) Users(ctx context.Context) (map[string]User, error)
- func (c *Client) UsersList(ctx context.Context) ([]User, error)
- type Message
- type MessageResponse
- type Option
- type User
- type UsersListResponse
Constants ¶
const ( // DefaultTimeout represents the time to wait for a response from slack. DefaultTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { Text string `json:"text,omitempty"` ID int `json:"id,omitempty"` Fallback string `json:"fallback,omitempty"` }
Attachment is a part of the Message.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Slack client for Web API.
func (*Client) PostMessage ¶
func (c *Client) PostMessage(ctx context.Context, channelID string, msg string) (*MessageResponse, error)
PostMessage sends a message to the Slack channel. see. https://api.slack.com/methods/chat.postMessage
func (*Client) RefreshUsersCache ¶
RefreshUsersCache updates the client's cached user map.
func (*Client) RespondToCommand ¶ added in v1.4.0
func (c *Client) RespondToCommand(ctx context.Context, responseURL string, msg string, visible bool) error
RespondToCommand responds to the Slack command.
func (*Client) UploadImage ¶
func (c *Client) UploadImage(ctx context.Context, channels []string, title, fileName, fileType, comment string, img io.Reader) error
UploadImage uploads an image by files.upload API. see. https://api.slack.com/methods/files.upload
func (*Client) UserID ¶
UserID returns the userID corresponding to the username from the client's user cache.
type Message ¶
type Message struct { Text string `json:"text,omitempty"` Username string `json:"username,omitempty"` BotID string `json:"bot_id,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` Type string `json:"type,omitempty"` SubType string `json:"sub_type,omitempty"` TS string `json:"ts,omitempty"` }
Message represents the Slack message.
type MessageResponse ¶
type MessageResponse struct { OK bool `json:"ok,omitempty"` Error string `json:"error,omitempty"` Needed string `json:"needed,omitempty"` Provided string `json:"provided,omitempty"` Channel string `json:"channel,omitempty"` TS string `json:"ts,omitempty"` Message Message `json:"message,omitempty"` }
MessageResponse represents the response of the chat.postMessage API.
type Option ¶
Option represents the client's option.
func CacheUsers ¶
func CacheUsers() Option
CacheUsers lists all users in a Slack team and caches it. required scopes: `users:read`
type User ¶
type User struct { ID string `json:"id,omitempty"` TeamID string `json:"team_id,omitempty"` Name string `json:"name,omitempty"` RealName string `json:"real_name,omitempty"` IsBot bool `json:"is_bot,omitempty"` Deleted bool `json:"deleted,omitempty"` IsAppUser bool `json:"is_app_user"` }
User represents the Slack user.