This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
/
render.go
123 lines (101 loc) · 2.48 KB
/
render.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-License-Identifier: AGPL-3.0-or-later
package telegram
import (
"encoding/json"
"fmt"
)
func RenderAuditProcReport(text string) (richText string) {
doc := map[string]interface{}{}
json.Unmarshal([]byte(text), &doc)
if doc["type"].(string) != "audit::proc::report" {
return
}
judge := doc["judge"].(float64)
workdir := doc["workdir"].(string)
binary := doc["binary"].(string)
argv := doc["argv"].(string)
richText += "<b>进程审计</b>\n\n"
richText += "工作目录: "
richText += fmt.Sprintf("<u>%s</u>\n\n", workdir)
richText += "可执行程序: "
richText += fmt.Sprintf("<u>%s</u>\n\n", binary)
richText += "参数列表: "
richText += fmt.Sprintf("<u>%s</u>\n\n", argv)
richText += "状态: "
if judge == 1 {
richText += "<u>成功</u>\n"
} else {
richText += "<u>失败</u>\n"
}
return
}
func RenderUserMsgSub(text string) (rich string) {
doc := map[string]interface{}{}
json.Unmarshal([]byte(text), &doc)
if doc["type"].(string) != "user::msg::sub" {
return
}
code := doc["code"].(float64)
section := doc["section"].(string)
rich += "<b>消息订阅</b>\n\n"
rich += "字段: "
rich += fmt.Sprintf("<u>%s</u>\n\n", section)
rich += "状态: "
if code == 0 {
rich += "<u>成功</u>\n"
} else {
rich += "<u>失败</u>\n"
}
return
}
func RenderUserMsgUnsub(text string) (rich string) {
doc := map[string]interface{}{}
json.Unmarshal([]byte(text), &doc)
if doc["type"].(string) != "user::msg::unsub" {
return
}
code := doc["code"].(float64)
section := doc["section"].(string)
rich += "<b>消息退订</b>\n\n"
rich += "字段: "
rich += fmt.Sprintf("<u>%s</u>\n\n", section)
rich += "状态: "
if code == 0 {
rich += "<u>成功</u>\n"
} else {
rich += "<u>失败</u>\n"
}
return
}
func RenderKernelProcEnable(text string) (rich string) {
doc := map[string]interface{}{}
json.Unmarshal([]byte(text), &doc)
if doc["type"].(string) != "kernel::proc::enable" {
return
}
code := doc["code"].(float64)
rich += "<b>开启进程保护</b>\n\n"
rich += "状态: "
if code == 0 {
rich += "<u>成功</u>\n"
} else {
rich += "<u>失败</u>\n"
}
return
}
func RenderKernelProcDisable(text string) (rich string) {
doc := map[string]interface{}{}
json.Unmarshal([]byte(text), &doc)
if doc["type"].(string) != "kernel::proc::disable" {
return
}
code := doc["code"].(float64)
rich += "<b>关闭进程保护</b>\n\n"
rich += "状态: "
if code == 0 {
rich += "<u>成功</u>\n"
} else {
rich += "<u>失败</u>\n"
}
return
}