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

Function init

plugin/cybercat/catdata.go:191–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189)
190
191func init() {
192 engine.OnRegex(`^吸(.*猫)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
193 typeOfcat := ctx.State["regex_matched"].([]string)[1]
194 if typeOfcat == "猫" {
195 result := suineko()
196 if result.Err != nil {
197 ctx.SendChain(message.Text("[ERROR]: ", result.Err))
198 return
199 }
200 ctx.SendChain(
201 message.Image(result.ImageURL),
202 message.Text("品种: ", result.TypeName,
203 "\n气质:\n", result.Temperament,
204 "\n描述:\n", result.Description),
205 )
206 return
207 }
208 breeds, ok := typeZH2Breeds[typeOfcat]
209 if !ok {
210 ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("没有相关该品种的猫图"))
211 return
212 }
213 picurl, err := getPicByBreed(breeds)
214 if err != nil {
215 ctx.SendChain(message.Text("[ERROR]: ", err))
216 return
217 }
218 ctx.SendChain(message.Text("品种: ", typeOfcat), message.Image(picurl))
219 })
220}
221
222func suineko() breedInfo {
223 data, err := web.GetData(apiURL + "search?has_breeds=1")

Callers

nothing calls this directly

Calls 2

suinekoFunction · 0.85
getPicByBreedFunction · 0.85

Tested by

no test coverage detected