github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/app/slashcommands/command_online.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 OnlineProvider struct {
    14  }
    15  
    16  const (
    17  	CmdOnline = "online"
    18  )
    19  
    20  func init() {
    21  	app.RegisterCommandProvider(&OnlineProvider{})
    22  }
    23  
    24  func (*OnlineProvider) GetTrigger() string {
    25  	return CmdOnline
    26  }
    27  
    28  func (*OnlineProvider) GetCommand(a *app.App, T goi18n.TranslateFunc) *model.Command {
    29  	return &model.Command{
    30  		Trigger:          CmdOnline,
    31  		AutoComplete:     true,
    32  		AutoCompleteDesc: T("api.command_online.desc"),
    33  		DisplayName:      T("api.command_online.name"),
    34  	}
    35  }
    36  
    37  func (*OnlineProvider) DoCommand(a *app.App, args *model.CommandArgs, message string) *model.CommandResponse {
    38  	a.SetStatusOnline(args.UserId, true)
    39  
    40  	return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: args.T("api.command_online.success")}
    41  }