Moving slash-commands out of app package (#14979)
* Moving slash-commands out of app package * Fixing golint checks * Fixing golangci-lint * Fixing golangci-lint errors
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
788c130774
Коммит
1f09d86f42
44
app/slashcommands/command_help.go
Обычный файл
44
app/slashcommands/command_help.go
Обычный файл
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package slashcommands
|
||||
|
||||
import (
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/app"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
type HelpProvider struct {
|
||||
}
|
||||
|
||||
const (
|
||||
CMD_HELP = "help"
|
||||
)
|
||||
|
||||
func init() {
|
||||
app.RegisterCommandProvider(&HelpProvider{})
|
||||
}
|
||||
|
||||
func (h *HelpProvider) GetTrigger() string {
|
||||
return CMD_HELP
|
||||
}
|
||||
|
||||
func (h *HelpProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Command {
|
||||
return &model.Command{
|
||||
Trigger: CMD_HELP,
|
||||
AutoComplete: true,
|
||||
AutoCompleteDesc: T("api.command_help.desc"),
|
||||
DisplayName: T("api.command_help.name"),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *HelpProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
|
||||
helpLink := *a.Config().SupportSettings.HelpLink
|
||||
|
||||
if helpLink == "" {
|
||||
helpLink = model.SUPPORT_SETTINGS_DEFAULT_HELP_LINK
|
||||
}
|
||||
|
||||
return &model.CommandResponse{GotoLocation: helpLink}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user