command_online.go 985 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  2. // See LICENSE.txt for license information.
  3. package app
  4. import (
  5. goi18n "github.com/mattermost/go-i18n/i18n"
  6. "github.com/mattermost/mattermost-server/v5/model"
  7. )
  8. type OnlineProvider struct {
  9. }
  10. const (
  11. CMD_ONLINE = "online"
  12. )
  13. func init() {
  14. RegisterCommandProvider(&OnlineProvider{})
  15. }
  16. func (me *OnlineProvider) GetTrigger() string {
  17. return CMD_ONLINE
  18. }
  19. func (me *OnlineProvider) GetCommand(a *App, T goi18n.TranslateFunc) *model.Command {
  20. return &model.Command{
  21. Trigger: CMD_ONLINE,
  22. AutoComplete: true,
  23. AutoCompleteDesc: T("api.command_online.desc"),
  24. DisplayName: T("api.command_online.name"),
  25. }
  26. }
  27. func (me *OnlineProvider) DoCommand(a *App, args *model.CommandArgs, message string) *model.CommandResponse {
  28. a.SetStatusOnline(args.UserId, true)
  29. return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: args.T("api.command_online.success")}
  30. }