forked from slack-io/slacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
81 lines (65 loc) · 2.71 KB
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package slacker
import (
"github.com/slack-go/slack"
)
// newResponseReplier creates a new response structure
func newResponseReplier(writer *Writer, replier *Replier) *ResponseReplier {
return &ResponseReplier{writer: writer, replier: replier}
}
// ResponseReplier sends messages to Slack
type ResponseReplier struct {
writer *Writer
replier *Replier
}
// Reply send a message to the current channel
func (r *ResponseReplier) Reply(message string, options ...ReplyOption) (string, error) {
return r.replier.Reply(message, options...)
}
// ReplyError send an error to the current channel
func (r *ResponseReplier) ReplyError(err error, options ...ReplyOption) (string, error) {
return r.replier.ReplyError(err, options...)
}
// ReplyBlocks send blocks to the current channel
func (r *ResponseReplier) ReplyBlocks(blocks []slack.Block, options ...ReplyOption) (string, error) {
return r.replier.ReplyBlocks(blocks, options...)
}
// Post send a message to a channel
func (r *ResponseReplier) Post(channel string, message string, options ...PostOption) (string, error) {
return r.writer.Post(channel, message, options...)
}
// PostError send an error to a channel
func (r *ResponseReplier) PostError(channel string, err error, options ...PostOption) (string, error) {
return r.writer.PostError(channel, err, options...)
}
// PostBlocks send blocks to a channel
func (r *ResponseReplier) PostBlocks(channel string, blocks []slack.Block, options ...PostOption) (string, error) {
return r.writer.PostBlocks(channel, blocks, options...)
}
// Delete deletes a message in a channel
func (r *ResponseReplier) Delete(channel string, messageTimestamp string) (string, error) {
return r.writer.Delete(channel, messageTimestamp)
}
// newWriterResponse creates a new response structure
func newWriterResponse(writer *Writer) *ResponseWriter {
return &ResponseWriter{writer: writer}
}
// ResponseWriter sends messages to slack
type ResponseWriter struct {
writer *Writer
}
// Post send a message to a channel
func (r *ResponseWriter) Post(channel string, message string, options ...PostOption) (string, error) {
return r.writer.Post(channel, message, options...)
}
// PostError send an error to a channel
func (r *ResponseWriter) PostError(channel string, err error, options ...PostOption) (string, error) {
return r.writer.PostError(channel, err, options...)
}
// PostBlocks send blocks to a channel
func (r *ResponseWriter) PostBlocks(channel string, blocks []slack.Block, options ...PostOption) (string, error) {
return r.writer.PostBlocks(channel, blocks, options...)
}
// Delete deletes a message in a channel
func (r *ResponseWriter) Delete(channel string, messageTimestamp string) (string, error) {
return r.writer.Delete(channel, messageTimestamp)
}