summaryrefslogtreecommitdiff
path: root/teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-11-02 15:27:18 +0800
committerMistivia <i@mistivia.com>2025-11-02 15:27:18 +0800
commite9c24f4af7ed56760f6db7941827d09f6db9020b (patch)
tree62128c43b883ce5e3148113350978755779bb5de /teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go
parent58d5e7cfda4781d8a57ec52aefd02983835c301a (diff)
add matterbridge
Diffstat (limited to 'teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go')
-rw-r--r--teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go94
1 files changed, 94 insertions, 0 deletions
diff --git a/teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go b/teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go
new file mode 100644
index 0000000..ef97c8d
--- /dev/null
+++ b/teleirc/matterbridge/vendor/github.com/slack-go/slack/pins.go
@@ -0,0 +1,94 @@
+package slack
+
+import (
+ "context"
+ "errors"
+ "net/url"
+)
+
+type listPinsResponseFull struct {
+ Items []Item
+ Paging `json:"paging"`
+ SlackResponse
+}
+
+// AddPin pins an item in a channel
+func (api *Client) AddPin(channel string, item ItemRef) error {
+ return api.AddPinContext(context.Background(), channel, item)
+}
+
+// AddPinContext pins an item in a channel with a custom context
+func (api *Client) AddPinContext(ctx context.Context, channel string, item ItemRef) error {
+ values := url.Values{
+ "channel": {channel},
+ "token": {api.token},
+ }
+ if item.Timestamp != "" {
+ values.Set("timestamp", item.Timestamp)
+ }
+ if item.File != "" {
+ values.Set("file", item.File)
+ }
+ if item.Comment != "" {
+ values.Set("file_comment", item.Comment)
+ }
+
+ response := &SlackResponse{}
+ if err := api.postMethod(ctx, "pins.add", values, response); err != nil {
+ return err
+ }
+
+ return response.Err()
+}
+
+// RemovePin un-pins an item from a channel
+func (api *Client) RemovePin(channel string, item ItemRef) error {
+ return api.RemovePinContext(context.Background(), channel, item)
+}
+
+// RemovePinContext un-pins an item from a channel with a custom context
+func (api *Client) RemovePinContext(ctx context.Context, channel string, item ItemRef) error {
+ values := url.Values{
+ "channel": {channel},
+ "token": {api.token},
+ }
+ if item.Timestamp != "" {
+ values.Set("timestamp", item.Timestamp)
+ }
+ if item.File != "" {
+ values.Set("file", item.File)
+ }
+ if item.Comment != "" {
+ values.Set("file_comment", item.Comment)
+ }
+
+ response := &SlackResponse{}
+ if err := api.postMethod(ctx, "pins.remove", values, response); err != nil {
+ return err
+ }
+
+ return response.Err()
+}
+
+// ListPins returns information about the items a user reacted to.
+func (api *Client) ListPins(channel string) ([]Item, *Paging, error) {
+ return api.ListPinsContext(context.Background(), channel)
+}
+
+// ListPinsContext returns information about the items a user reacted to with a custom context.
+func (api *Client) ListPinsContext(ctx context.Context, channel string) ([]Item, *Paging, error) {
+ values := url.Values{
+ "channel": {channel},
+ "token": {api.token},
+ }
+
+ response := &listPinsResponseFull{}
+ err := api.postMethod(ctx, "pins.list", values, response)
+ if err != nil {
+ return nil, nil, err
+ }
+ if !response.Ok {
+ return nil, nil, errors.New(response.Error)
+ }
+ return response.Items, &response.Paging, nil
+}