-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd-admin.go
More file actions
40 lines (34 loc) · 733 Bytes
/
cmd-admin.go
File metadata and controls
40 lines (34 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
)
type adminCmd struct{}
func (adminCmd) Command() string {
return "admin"
}
func (adminCmd) Description() string {
return "disables or enables admin mode for the active chat"
}
func (adminCmd) Help(_ []string) {
fmt.Fprintln(outputView, "No help available")
}
func (adminCmd) Execute(args []string) error {
if len(args) != 1 || activeChatID == 0 {
return nil
}
var chat chat
database.First(&chat, activeChatID)
if args[0] == "enable" {
chat.Admin = true
output(func(printer printer) {
printer("(admin enabled)")
})
} else if args[0] == "disable" {
chat.Admin = false
output(func(printer printer) {
printer("(admin disabled)")
})
}
database.Save(&chat)
return nil
}