From 76bfdeeb70281af6d19abfd6a4980aaf30b23f6a Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Sun, 18 Jan 2015 20:07:21 -0800 Subject: [PATCH] /slap --- chat/command.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chat/command.go b/chat/command.go index ea313c8..df83575 100644 --- a/chat/command.go +++ b/chat/command.go @@ -114,7 +114,7 @@ func InitCommands(c *Commands) { Handler: func(room *Room, msg CommandMsg) error { me := strings.TrimLeft(msg.body, "/me") if me == "" { - me = " is at a loss for words." + me = "is at a loss for words." } else { me = me[1:] } @@ -216,4 +216,21 @@ func InitCommands(c *Commands) { return nil }, }) + + c.Add(Command{ + Prefix: "/slap", + PrefixHelp: "NAME", + Handler: func(room *Room, msg CommandMsg) error { + var me string + args := msg.Args() + if len(args) == 0 { + me = "slaps themselves around a bit with a large trout." + } else { + me = fmt.Sprintf("slaps %s around a bit with a large trout.", strings.Join(args, " ")) + } + + room.Send(NewEmoteMsg(me, msg.From())) + return nil + }, + }) }