From b1a7c1acf139efbb5312b4aa939bd94155e6a9e6 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sat, 9 Jan 2016 08:54:07 -0600 Subject: adding different commands --- api/command_shrug.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 api/command_shrug.go (limited to 'api/command_shrug.go') diff --git a/api/command_shrug.go b/api/command_shrug.go new file mode 100644 index 000000000..e34f80110 --- /dev/null +++ b/api/command_shrug.go @@ -0,0 +1,29 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package api + +import ( + "github.com/mattermost/platform/model" +) + +type ShrugProvider struct { +} + +func init() { + RegisterCommandProvider(&ShrugProvider{}) +} + +func (me *ShrugProvider) GetCommand() *model.Command { + return &model.Command{ + Trigger: "shrug", + AutoComplete: true, + AutoCompleteDesc: `Adds ¯\_(ツ)_/¯ to your message`, + AutoCompleteHint: "[message]", + DisplayName: "shrug", + } +} + +func (me *ShrugProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_IN_CHANNEL, Text: `¯\_(ツ)_/¯`} +} -- cgit v1.2.3-1-g7c22 From 3edcf960a0502fbeb3e4b46e87ecb958646eeb39 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sat, 9 Jan 2016 09:22:14 -0600 Subject: Fixing unit tests --- api/command_shrug.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'api/command_shrug.go') diff --git a/api/command_shrug.go b/api/command_shrug.go index e34f80110..c49bd46ae 100644 --- a/api/command_shrug.go +++ b/api/command_shrug.go @@ -25,5 +25,10 @@ func (me *ShrugProvider) GetCommand() *model.Command { } func (me *ShrugProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { - return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_IN_CHANNEL, Text: `¯\_(ツ)_/¯`} + rmsg := `¯\\\_(ツ)\_/¯` + if len(message) > 0 { + rmsg = message + " " + rmsg + } + + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_IN_CHANNEL, Text: rmsg} } -- cgit v1.2.3-1-g7c22 From 27586a320add265f3e032d2cb21b27e93b51a2b0 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 1 Feb 2016 18:52:43 -0800 Subject: Adding loc to new command backend --- api/command_shrug.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'api/command_shrug.go') diff --git a/api/command_shrug.go b/api/command_shrug.go index c49bd46ae..8fb5bc200 100644 --- a/api/command_shrug.go +++ b/api/command_shrug.go @@ -10,17 +10,25 @@ import ( type ShrugProvider struct { } +const ( + CMD_SHRUG = "shrug" +) + func init() { RegisterCommandProvider(&ShrugProvider{}) } -func (me *ShrugProvider) GetCommand() *model.Command { +func (me *ShrugProvider) GetTrigger() string { + return CMD_SHRUG +} + +func (me *ShrugProvider) GetCommand(c *Context) *model.Command { return &model.Command{ - Trigger: "shrug", + Trigger: CMD_SHRUG, AutoComplete: true, - AutoCompleteDesc: `Adds ¯\_(ツ)_/¯ to your message`, - AutoCompleteHint: "[message]", - DisplayName: "shrug", + AutoCompleteDesc: c.T("api.command_shrug.desc"), + AutoCompleteHint: c.T("api.command_shrug.hint"), + DisplayName: c.T("api.command_shrug.name"), } } -- cgit v1.2.3-1-g7c22