summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-10-22 08:11:26 -0400
committerJoram Wilander <jwawilander@gmail.com>2015-10-22 08:11:26 -0400
commit2d922fde7e33125b55fd70f713c867db89ebfcf5 (patch)
treec712cce4c45e4a4aceca652c5bb37ab7a6706a36 /api
parentd8f6cb939f3f931d74833deedc17b29d807ad035 (diff)
parentb1d9af215494d5c5cee6eb092876fe27c4ef4e71 (diff)
downloadchat-2d922fde7e33125b55fd70f713c867db89ebfcf5.tar.gz
chat-2d922fde7e33125b55fd70f713c867db89ebfcf5.tar.bz2
chat-2d922fde7e33125b55fd70f713c867db89ebfcf5.zip
Merge pull request #1094 from trashcan/slash-shrug
Add a /shrug command
Diffstat (limited to 'api')
-rw-r--r--api/command.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/api/command.go b/api/command.go
index 52ff8fffd..54f863c48 100644
--- a/api/command.go
+++ b/api/command.go
@@ -22,6 +22,7 @@ var commands = []commandHandler{
joinCommand,
loadTestCommand,
echoCommand,
+ shrugCommand,
}
var echoSem chan bool
@@ -160,6 +161,34 @@ func echoCommand(c *Context, command *model.Command) bool {
return false
}
+func shrugCommand(c *Context, command *model.Command) bool {
+ cmd := "/shrug"
+
+ if !command.Suggest && strings.Index(command.Command, cmd) == 0 {
+ message := "¯\\_(ツ)_/¯"
+
+ parameters := strings.SplitN(command.Command, " ", 2)
+ if len(parameters) > 1 {
+ message += " " + parameters[1]
+ }
+
+ post := &model.Post{}
+ post.Message = message
+ post.ChannelId = command.ChannelId
+ if _, err := CreatePost(c, post, false); err != nil {
+ l4g.Error("Unable to create /shrug post post, err=%v", err)
+ return false
+ }
+ command.Response = model.RESP_EXECUTED
+ return true
+
+ } else if strings.Index(cmd, command.Command) == 0 {
+ command.AddSuggestion(&model.SuggestCommand{Suggestion: cmd, Description: "Adds ¯\\_(ツ)_/¯ to your message, /shrug [message]"})
+ }
+
+ return false
+}
+
func joinCommand(c *Context, command *model.Command) bool {
// looks for "/join channel-name"