-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
43 lines (39 loc) · 791 Bytes
/
utils.go
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
41
42
43
package main
import (
"encoding/json"
zero "github.com/wdvxdr1123/ZeroBot"
)
func CheckMessageType(ctx *zero.Ctx) string {
if zero.OnlyGroup(ctx) {
return "group"
} else {
return "direct"
}
}
func CheckUserPermission(ctx *zero.Ctx) int {
switch {
case zero.SuperUserPermission(ctx):
return 1
case zero.OwnerPermission(ctx):
return 2
case zero.AdminPermission(ctx):
return 3
default:
return 6
}
}
func ParseCoreMessage(ReceiveMessage []byte) (CoreReceiveMessage, error) {
var RecMessageStrutc CoreReceiveMessage
err := json.Unmarshal(ReceiveMessage, &RecMessageStrutc)
if err != nil {
return CoreReceiveMessage{}, err
}
return RecMessageStrutc, nil
}
func GroupIsExit(GroupId string) string {
if GroupId == "0" {
return ""
} else {
return GroupId
}
}