MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / init

Function init

plugin/chrev/init.go:13–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func init() {
14 // 初始化engine
15 engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
16 DisableOnDefault: false,
17 Brief: "英文字符翻转",
18 Help: "例: 翻转 I love you",
19 })
20 // 处理字符翻转指令
21 engine.OnRegex(`^翻转\s*([A-Za-z\s]*)$`).SetBlock(true).
22 Handle(func(ctx *zero.Ctx) {
23 // 获取需要翻转的字符串
24 str := ctx.State["regex_matched"].([]string)[1]
25 // 将字符顺序翻转
26 tmp := strings.Builder{}
27 for i := len(str) - 1; i >= 0; i-- {
28 tmp.WriteRune(charMap[str[i]])
29 }
30 // 发送翻转后的字符串
31 ctx.SendChain(message.Text(tmp.String()))
32 })
33}

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected