-
Notifications
You must be signed in to change notification settings - Fork 34
/
level.go
47 lines (38 loc) · 1.01 KB
/
level.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
package notices
import (
"github.com/TeaWeb/code/teaconfigs/notices"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
)
type LevelAction actions.Action
// 级别
func (this *LevelAction) Run(params struct {
Level uint8
}) {
level := notices.FindNoticeLevel(params.Level)
if level == nil {
this.Fail("找不到Level信息")
}
this.Data["level"] = level
setting := notices.SharedNoticeSetting()
config := setting.LevelConfig(types.Uint8(params.Level))
receivers := []maps.Map{}
for _, receiver := range config.Receivers {
media := setting.FindMedia(receiver.MediaId)
if media == nil {
continue
}
receivers = append(receivers, maps.Map{
"on": receiver.On,
"id": receiver.Id,
"name": receiver.Name,
"user": receiver.User,
"mediaName": media.Name,
"mediaType": media.Type,
"mediaTypeName": notices.FindNoticeMediaTypeName(media.Type),
})
}
this.Data["receivers"] = receivers
this.Show()
}