-
Notifications
You must be signed in to change notification settings - Fork 10
/
chatdriver.go
46 lines (39 loc) · 2.02 KB
/
chatdriver.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
package slackscot
import (
"github.com/slack-go/slack"
)
// RealTimeMessageSender is implemented by any value that has the NewOutgoingMessage method.
// The main purpose is a slight decoupling of the slack.RTM in order for plugins to be able to write
// tests more easily if all they do is send new messages on a channel
type RealTimeMessageSender interface {
// NewOutgoingMessage is the function that creates a new message to send. See https://godoc.org/github.com/slack-go/slack#RTM.NewOutgoingMessage for more details
NewOutgoingMessage(text string, channelID string, options ...slack.RTMsgOption) *slack.OutgoingMessage
// SendMessage is the function that sends a new real time message. See https://godoc.org/github.com/slack-go/slack#RTM.SendMessage for more details
SendMessage(outMsg *slack.OutgoingMessage)
}
// messageSender is implemented by any value that has the SendMessage method. Note that the difference between the RealTimeMessageSender
// version is that this one is synchronous and returns the information identifying the sent message.
//
// slack.Client implements this interface
type messageSender interface {
SendMessage(channelID string, options ...slack.MsgOption) (rChannelID string, rTimestamp string, rText string, err error)
}
// messageUpdater is implemented by any value that has the UpdateMessage method.
//
// slack.Client implements this interface
type messageUpdater interface {
UpdateMessage(channelID, timestamp string, options ...slack.MsgOption) (rChannelID string, rTimestamp string, rText string, err error)
}
// messageDeleter is implemented by any value that has the DeleteMessage method.
//
// slack.Client implements this interface
type messageDeleter interface {
DeleteMessage(channelID string, timestamp string) (rChannelID string, rTimestamp string, err error)
}
// ChatDriver encompasses all MessageSender, MessageUpdater and MessageDeleter interfaces and is implemented by any values that
// has all methods of those interfaces
type chatDriver interface {
messageDeleter
messageSender
messageUpdater
}