MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / init

Function init

plugin/games/gamesystem/main.go:64–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62)
63
64func init() {
65 gamesystem.OnCommandGroup([]string{"上架", "下架"}, zero.UserOrGrpAdmin).SetBlock(true).Handle(func(ctx *zero.Ctx) {
66 model := extension.CommandModel{}
67 _ = ctx.Parse(&model)
68 gid := ctx.Event.GroupID
69 if strings.Contains(model.Command, "上架") {
70 err := gameManager[model.Args].SalesIn(gid)
71 if err != nil {
72 ctx.SendChain(message.Text("[ERROR]:", err))
73 return
74 }
75 ctx.SendChain(message.Text(model.Args, "游戏已上架"))
76 } else {
77 err := gameManager[model.Args].SalesOut(gid)
78 if err != nil {
79 ctx.SendChain(message.Text("[ERROR]:", err))
80 return
81 }
82 ctx.SendChain(message.Text(model.Args, "游戏已下架"))
83 }
84 })
85 gamesystem.OnFullMatch("游戏列表").SetBlock(true).Limit(ctxext.LimitByUser).
86 Handle(func(ctx *zero.Ctx) {
87 skrft, err := file.GetLazyData(text.SakuraFontFile, control.Md5File, false)
88 if err != nil {
89 ctx.SendChain(message.Text("[ERROR]:", err))
90 return
91 }
92 gid := ctx.Event.GroupID
93 i := 0
94 var imgs []image.Image
95 var yOfLine1 int // 第一列最大高度
96 var yOfLine2 int // 第二列最大高度
97 for gameName, info := range gamelist {
98 img, err := (&rendercard.Card{
99 TitleFontData: skrft,
100 TextFontData: skrft,
101 Title: gameName,
102 CanTitleShown: true,
103 TitleAlign: rendercard.AlignCenter,
104 Text: func() []string {
105 var infoText []string
106 if !whichGamePlayIn(gameName, gid) {
107 infoText = append(infoText, []string{"游戏状态:", " 下架中"}...)
108 }
109 infoText = append(infoText, []string{
110 "游戏指令:", " " + info.Command,
111 "游戏说明:", strings.ReplaceAll(" "+info.Help, "\n", "\n "),
112 "游戏奖励:", " " + info.Rewards}...)
113 return infoText
114 }(),
115 IsTextSplitPerElement: true,
116 }).DrawTextCard()
117 if err != nil {
118 ctx.SendChain(message.Text(serviceErr, err))
119 return
120 }
121 if i%2 == 0 { // 第一列

Callers

nothing calls this directly

Calls 3

whichGamePlayInFunction · 0.85
SalesInMethod · 0.80
SalesOutMethod · 0.80

Tested by

no test coverage detected