PLT-394: Add a /me command
- Just italicizes the message to mark it as 'action' - Same behavior as slack - Is super useful for people moving from IRC, since /me is often burnt into muscle memory
Этот коммит содержится в:
@@ -24,6 +24,7 @@ var (
|
|||||||
"loadTestCommand": "/loadtest",
|
"loadTestCommand": "/loadtest",
|
||||||
"echoCommand": "/echo",
|
"echoCommand": "/echo",
|
||||||
"shrugCommand": "/shrug",
|
"shrugCommand": "/shrug",
|
||||||
|
"meCommand": "/me",
|
||||||
}
|
}
|
||||||
commands = []commandHandler{
|
commands = []commandHandler{
|
||||||
logoutCommand,
|
logoutCommand,
|
||||||
@@ -31,6 +32,7 @@ var (
|
|||||||
loadTestCommand,
|
loadTestCommand,
|
||||||
echoCommand,
|
echoCommand,
|
||||||
shrugCommand,
|
shrugCommand,
|
||||||
|
meCommand,
|
||||||
}
|
}
|
||||||
commandNotImplementedErr = model.NewAppError("checkCommand", "Command not implemented", "")
|
commandNotImplementedErr = model.NewAppError("checkCommand", "Command not implemented", "")
|
||||||
)
|
)
|
||||||
@@ -194,6 +196,34 @@ func echoCommand(c *Context, command *model.Command) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func meCommand(c *Context, command *model.Command) bool {
|
||||||
|
cmd := cmds["meCommand"]
|
||||||
|
|
||||||
|
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 /me 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: "Do an action, /me [message]"})
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func shrugCommand(c *Context, command *model.Command) bool {
|
func shrugCommand(c *Context, command *model.Command) bool {
|
||||||
cmd := cmds["shrugCommand"]
|
cmd := cmds["shrugCommand"]
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user