Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
strip trailing white space in command solves Issue #96
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleedavis committed May 11, 2019
1 parent 1dcc6cd commit f63af2c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo

T, locale := p.translation(user)
location := p.location(user)
command := strings.Trim(args.Command, " ")

if strings.Trim(args.Command, " ") == "/"+CommandTrigger {
if strings.Trim(command, " ") == "/"+CommandTrigger {
p.InteractiveSchedule(args.TriggerId, user)
return &model.CommandResponse{}, nil
}

if strings.HasSuffix(args.Command, T("help")) {
if strings.HasSuffix(command, T("help")) {
post := model.Post{
ChannelId: args.ChannelId,
UserId: p.remindUserId,
Expand All @@ -57,7 +58,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
return &model.CommandResponse{}, nil
}

if strings.HasSuffix(args.Command, T("list")) {
if strings.HasSuffix(command, T("list")) {
listMessage := p.ListReminders(user, args.ChannelId)
if listMessage != "" {
return &model.CommandResponse{
Expand All @@ -70,7 +71,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
return &model.CommandResponse{}, nil
}

payload := strings.Trim(strings.Replace(args.Command, "/"+CommandTrigger, "", -1), " ")
payload := strings.Trim(strings.Replace(command, "/"+CommandTrigger, "", -1), " ")

if strings.HasPrefix(payload, T("me")) ||
strings.HasPrefix(payload, "@") ||
Expand Down Expand Up @@ -102,7 +103,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
// debug & troubleshooting commands

// clear all reminders for current user
if strings.HasSuffix(args.Command, "__clear") {
if strings.HasSuffix(command, "__clear") {
post := model.Post{
ChannelId: args.ChannelId,
UserId: p.remindUserId,
Expand All @@ -113,7 +114,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
}

// display the plugin version
if strings.HasSuffix(args.Command, "__version") {
if strings.HasSuffix(command, "__version") {
post := model.Post{
ChannelId: args.ChannelId,
UserId: p.remindUserId,
Expand All @@ -124,7 +125,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo
}

// display the locale & location of user
if strings.HasSuffix(args.Command, "__user") {
if strings.HasSuffix(command, "__user") {
post := model.Post{
ChannelId: args.ChannelId,
UserId: p.remindUserId,
Expand Down

0 comments on commit f63af2c

Please sign in to comment.