summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/item.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-01-08 22:41:38 +0100
committerWim <wim@42.be>2018-01-09 00:07:55 +0100
commitbe898b44c3c057c7b70efb83f66b7bbbdd5e9276 (patch)
tree01c8983913bcae177b5e0e015de9a45abe8369a7 /vendor/github.com/nlopes/slack/item.go
parent4828c434439949f62a6e219ab9947c221a06b111 (diff)
downloadmatterbridge-msglm-be898b44c3c057c7b70efb83f66b7bbbdd5e9276.tar.gz
matterbridge-msglm-be898b44c3c057c7b70efb83f66b7bbbdd5e9276.tar.bz2
matterbridge-msglm-be898b44c3c057c7b70efb83f66b7bbbdd5e9276.zip
Update vendor (slack)
Diffstat (limited to 'vendor/github.com/nlopes/slack/item.go')
-rw-r--r--vendor/github.com/nlopes/slack/item.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/item.go b/vendor/github.com/nlopes/slack/item.go
new file mode 100644
index 00000000..89af4eb1
--- /dev/null
+++ b/vendor/github.com/nlopes/slack/item.go
@@ -0,0 +1,75 @@
+package slack
+
+const (
+ TYPE_MESSAGE = "message"
+ TYPE_FILE = "file"
+ TYPE_FILE_COMMENT = "file_comment"
+ TYPE_CHANNEL = "channel"
+ TYPE_IM = "im"
+ TYPE_GROUP = "group"
+)
+
+// Item is any type of slack message - message, file, or file comment.
+type Item struct {
+ Type string `json:"type"`
+ Channel string `json:"channel,omitempty"`
+ Message *Message `json:"message,omitempty"`
+ File *File `json:"file,omitempty"`
+ Comment *Comment `json:"comment,omitempty"`
+ Timestamp string `json:"ts,omitempty"`
+}
+
+// NewMessageItem turns a message on a channel into a typed message struct.
+func NewMessageItem(ch string, m *Message) Item {
+ return Item{Type: TYPE_MESSAGE, Channel: ch, Message: m}
+}
+
+// NewFileItem turns a file into a typed file struct.
+func NewFileItem(f *File) Item {
+ return Item{Type: TYPE_FILE, File: f}
+}
+
+// NewFileCommentItem turns a file and comment into a typed file_comment struct.
+func NewFileCommentItem(f *File, c *Comment) Item {
+ return Item{Type: TYPE_FILE_COMMENT, File: f, Comment: c}
+}
+
+// NewChannelItem turns a channel id into a typed channel struct.
+func NewChannelItem(ch string) Item {
+ return Item{Type: TYPE_CHANNEL, Channel: ch}
+}
+
+// NewIMItem turns a channel id into a typed im struct.
+func NewIMItem(ch string) Item {
+ return Item{Type: TYPE_IM, Channel: ch}
+}
+
+// NewGroupItem turns a channel id into a typed group struct.
+func NewGroupItem(ch string) Item {
+ return Item{Type: TYPE_GROUP, Channel: ch}
+}
+
+// ItemRef is a reference to a message of any type. One of FileID,
+// CommentId, or the combination of ChannelId and Timestamp must be
+// specified.
+type ItemRef struct {
+ Channel string `json:"channel"`
+ Timestamp string `json:"timestamp"`
+ File string `json:"file"`
+ Comment string `json:"file_comment"`
+}
+
+// NewRefToMessage initializes a reference to to a message.
+func NewRefToMessage(channel, timestamp string) ItemRef {
+ return ItemRef{Channel: channel, Timestamp: timestamp}
+}
+
+// NewRefToFile initializes a reference to a file.
+func NewRefToFile(file string) ItemRef {
+ return ItemRef{File: file}
+}
+
+// NewRefToComment initializes a reference to a file comment.
+func NewRefToComment(comment string) ItemRef {
+ return ItemRef{Comment: comment}
+}