github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/app/slashcommands/command_shortcuts.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package slashcommands
     5  
     6  import (
     7  	goi18n "github.com/mattermost/go-i18n/i18n"
     8  
     9  	"github.com/mattermost/mattermost-server/v5/app"
    10  	"github.com/mattermost/mattermost-server/v5/model"
    11  )
    12  
    13  type ShortcutsProvider struct {
    14  }
    15  
    16  const (
    17  	CmdShortcuts = "shortcuts"
    18  )
    19  
    20  func init() {
    21  	app.RegisterCommandProvider(&ShortcutsProvider{})
    22  }
    23  
    24  func (*ShortcutsProvider) GetTrigger() string {
    25  	return CmdShortcuts
    26  }
    27  
    28  func (*ShortcutsProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Command {
    29  	return &model.Command{
    30  		Trigger:          CmdShortcuts,
    31  		AutoComplete:     true,
    32  		AutoCompleteDesc: T("api.command_shortcuts.desc"),
    33  		AutoCompleteHint: "",
    34  		DisplayName:      T("api.command_shortcuts.name"),
    35  	}
    36  }
    37  
    38  func (*ShortcutsProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
    39  	// This command is handled client-side and shouldn't hit the server.
    40  	return &model.CommandResponse{
    41  		Text:         args.T("api.command_shortcuts.unsupported.app_error"),
    42  		ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
    43  	}
    44  }