github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/app/slashcommands/command_dnd.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 "github.com/masterhung0112/hk_server/v5/app" 8 "github.com/masterhung0112/hk_server/v5/app/request" 9 "github.com/masterhung0112/hk_server/v5/model" 10 "github.com/masterhung0112/hk_server/v5/shared/i18n" 11 ) 12 13 type DndProvider struct { 14 } 15 16 const ( 17 CmdDND = "dnd" 18 ) 19 20 func init() { 21 app.RegisterCommandProvider(&DndProvider{}) 22 } 23 24 func (*DndProvider) GetTrigger() string { 25 return CmdDND 26 } 27 28 func (*DndProvider) GetCommand(a *app.App, T i18n.TranslateFunc) *model.Command { 29 return &model.Command{ 30 Trigger: CmdDND, 31 AutoComplete: true, 32 AutoCompleteDesc: T("api.command_dnd.desc"), 33 DisplayName: T("api.command_dnd.name"), 34 } 35 } 36 37 func (*DndProvider) DoCommand(a *app.App, c *request.Context, args *model.CommandArgs, message string) *model.CommandResponse { 38 a.SetStatusDoNotDisturb(args.UserId) 39 40 return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: args.T("api.command_dnd.success")} 41 }