summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/messages.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-09-05 16:34:37 +0200
committerWim <wim@42.be>2016-09-05 16:34:37 +0200
commitb30e85836e575974bac1b2ea91e9b6c2dd39fe44 (patch)
treeb3aa5d148e436cacd6c737ad56ba3fc0b9369e26 /vendor/github.com/nlopes/slack/messages.go
parente449a97bd0114e55c2a73aa79b061b55d755aa16 (diff)
downloadmatterbridge-msglm-b30e85836e575974bac1b2ea91e9b6c2dd39fe44.tar.gz
matterbridge-msglm-b30e85836e575974bac1b2ea91e9b6c2dd39fe44.tar.bz2
matterbridge-msglm-b30e85836e575974bac1b2ea91e9b6c2dd39fe44.zip
Add Slack support
Diffstat (limited to 'vendor/github.com/nlopes/slack/messages.go')
-rw-r--r--vendor/github.com/nlopes/slack/messages.go131
1 files changed, 131 insertions, 0 deletions
diff --git a/vendor/github.com/nlopes/slack/messages.go b/vendor/github.com/nlopes/slack/messages.go
new file mode 100644
index 00000000..3433e06b
--- /dev/null
+++ b/vendor/github.com/nlopes/slack/messages.go
@@ -0,0 +1,131 @@
+package slack
+
+// OutgoingMessage is used for the realtime API, and seems incomplete.
+type OutgoingMessage struct {
+ ID int `json:"id"`
+ Channel string `json:"channel,omitempty"`
+ Text string `json:"text,omitempty"`
+ Type string `json:"type,omitempty"`
+}
+
+// Message is an auxiliary type to allow us to have a message containing sub messages
+type Message struct {
+ Msg
+ SubMessage *Msg `json:"message,omitempty"`
+}
+
+// Msg contains information about a slack message
+type Msg struct {
+ // Basic Message
+ Type string `json:"type,omitempty"`
+ Channel string `json:"channel,omitempty"`
+ User string `json:"user,omitempty"`
+ Text string `json:"text,omitempty"`
+ Timestamp string `json:"ts,omitempty"`
+ IsStarred bool `json:"is_starred,omitempty"`
+ PinnedTo []string `json:"pinned_to, omitempty"`
+ Attachments []Attachment `json:"attachments,omitempty"`
+ Edited *Edited `json:"edited,omitempty"`
+
+ // Message Subtypes
+ SubType string `json:"subtype,omitempty"`
+
+ // Hidden Subtypes
+ Hidden bool `json:"hidden,omitempty"` // message_changed, message_deleted, unpinned_item
+ DeletedTimestamp string `json:"deleted_ts,omitempty"` // message_deleted
+ EventTimestamp string `json:"event_ts,omitempty"`
+
+ // bot_message (https://api.slack.com/events/message/bot_message)
+ BotID string `json:"bot_id,omitempty"`
+ Username string `json:"username,omitempty"`
+ Icons *Icon `json:"icons,omitempty"`
+
+ // channel_join, group_join
+ Inviter string `json:"inviter,omitempty"`
+
+ // channel_topic, group_topic
+ Topic string `json:"topic,omitempty"`
+
+ // channel_purpose, group_purpose
+ Purpose string `json:"purpose,omitempty"`
+
+ // channel_name, group_name
+ Name string `json:"name,omitempty"`
+ OldName string `json:"old_name,omitempty"`
+
+ // channel_archive, group_archive
+ Members []string `json:"members,omitempty"`
+
+ // file_share, file_comment, file_mention
+ File *File `json:"file,omitempty"`
+
+ // file_share
+ Upload bool `json:"upload,omitempty"`
+
+ // file_comment
+ Comment *Comment `json:"comment,omitempty"`
+
+ // pinned_item
+ ItemType string `json:"item_type,omitempty"`
+
+ // https://api.slack.com/rtm
+ ReplyTo int `json:"reply_to,omitempty"`
+ Team string `json:"team,omitempty"`
+
+ // reactions
+ Reactions []ItemReaction `json:"reactions,omitempty"`
+}
+
+// Icon is used for bot messages
+type Icon struct {
+ IconURL string `json:"icon_url,omitempty"`
+ IconEmoji string `json:"icon_emoji,omitempty"`
+}
+
+// Edited indicates that a message has been edited.
+type Edited struct {
+ User string `json:"user,omitempty"`
+ Timestamp string `json:"ts,omitempty"`
+}
+
+// Event contains the event type
+type Event struct {
+ Type string `json:"type,omitempty"`
+}
+
+// Ping contains information about a Ping Event
+type Ping struct {
+ ID int `json:"id"`
+ Type string `json:"type"`
+}
+
+// Pong contains information about a Pong Event
+type Pong struct {
+ Type string `json:"type"`
+ ReplyTo int `json:"reply_to"`
+}
+
+// NewOutgoingMessage prepares an OutgoingMessage that the user can
+// use to send a message. Use this function to properly set the
+// messageID.
+func (rtm *RTM) NewOutgoingMessage(text string, channel string) *OutgoingMessage {
+ id := rtm.idGen.Next()
+ return &OutgoingMessage{
+ ID: id,
+ Type: "message",
+ Channel: channel,
+ Text: text,
+ }
+}
+
+// NewTypingMessage prepares an OutgoingMessage that the user can
+// use to send as a typing indicator. Use this function to properly set the
+// messageID.
+func (rtm *RTM) NewTypingMessage(channel string) *OutgoingMessage {
+ id := rtm.idGen.Next()
+ return &OutgoingMessage{
+ ID: id,
+ Type: "typing",
+ Channel: channel,
+ }
+}