From 35292a69fc4f27335ba5cec38520b09a4c87cea2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:13:22 +0800 Subject: [PATCH] =?UTF-8?q?chore(lint):=20=E6=94=B9=E8=BF=9B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=B7=E5=BC=8F=20(#1192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- plugin/crypter/fumo.go | 17 +++++++++-------- plugin/crypter/handlers.go | 6 +++--- plugin/crypter/hou.go | 21 +++++++++++---------- plugin/crypter/main.go | 8 ++++---- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/plugin/crypter/fumo.go b/plugin/crypter/fumo.go index e488bcb3..a96a1dfb 100644 --- a/plugin/crypter/fumo.go +++ b/plugin/crypter/fumo.go @@ -20,14 +20,15 @@ var fumoChars = []string{ "fUmo,", "fuMo,", "fumO,", "FUmo,", "FuMo,", "FumO,", "fUMo,", "fUmO,", "fuMO,", "FUMo,", "FuMO,", "fUMO,", "FUMO,", "fumo+", "Fumo+", "fUmo+", "fuMo+", "fumO+", "FUmo+", "FuMo+", "FumO+", "fUMo+", "fUmO+", "fuMO+", - "FUMo+", "FUmO+", "fUMO+", "FUMO+", "fumo|", "Fumo|", "fUmo|", "fuMo|", - "fumO|", "FUmo|", "FuMo|", "FumO|", "fUMo|", "fUmO|", "fuMO|", "fumo/", + "FUMo+", "FUmO+", "fUMO+", "FUMO+", "fumo|", "Fumo|", "fUmo|", "fuMo|", + "fumO|", "FUmo|", "FuMo|", "FumO|", "fUMo|", "fUmO|", "fuMO|", "fumo/", "Fumo/", "fUmo/", } -//Base64 2 Fumo +// Base64 2 Fumo // 创建编码映射表 var encodeMap = make(map[byte]string) + // 创建解码映射表 var decodeMap = make(map[string]byte) @@ -35,13 +36,13 @@ func init() { for i := 0; i < 64 && i < len(fumoChars); i++ { base64Char := base64Chars[i] fumoChar := fumoChars[i] - + encodeMap[base64Char] = fumoChar decodeMap[fumoChar] = base64Char } } -//加密 +// 加密 func encryptFumo(text string) string { if text == "" { return "请输入要加密的文本" @@ -59,11 +60,11 @@ func encryptFumo(text string) string { } } result := fumoBody.String() + strings.Repeat("=", paddingCount) - + return result } -//解密 +// 解密 func decryptFumo(fumoText string) string { if fumoText == "" { return "请输入要解密的Fumo语密文" @@ -91,4 +92,4 @@ func decryptFumo(fumoText string) string { } originalText := string(decodedBytes) return originalText -} \ No newline at end of file +} diff --git a/plugin/crypter/handlers.go b/plugin/crypter/handlers.go index cc949378..e194e4b5 100644 --- a/plugin/crypter/handlers.go +++ b/plugin/crypter/handlers.go @@ -6,7 +6,7 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" ) -//hou +// hou func houEncryptHandler(ctx *zero.Ctx) { text := ctx.State["regex_matched"].([]string)[1] result := encodeHou(text) @@ -19,7 +19,7 @@ func houDecryptHandler(ctx *zero.Ctx) { ctx.SendChain(message.Text(result)) } -//fumo +// fumo func fumoEncryptHandler(ctx *zero.Ctx) { text := ctx.State["regex_matched"].([]string)[1] result := encryptFumo(text) @@ -30,4 +30,4 @@ func fumoDecryptHandler(ctx *zero.Ctx) { text := ctx.State["regex_matched"].([]string)[1] result := decryptFumo(text) ctx.SendChain(message.Text(result)) -} \ No newline at end of file +} diff --git a/plugin/crypter/hou.go b/plugin/crypter/hou.go index 7bda968a..6302375b 100644 --- a/plugin/crypter/hou.go +++ b/plugin/crypter/hou.go @@ -7,9 +7,10 @@ import ( // 齁语密码表 var houCodebook = []string{ - "齁", "哦", "噢", "喔", "咕", "咿", "嗯", "啊", + "齁", "哦", "噢", "喔", "咕", "咿", "嗯", "啊", "~", "哈", "!", "唔", "哼", "❤", "呃", "呼", } + // 索引: 0 1 2 3 4 5 6 7 // 8 9 10 11 12 13 14 15 @@ -35,7 +36,7 @@ func encodeHou(text string) string { encoded.WriteString(houCodebook[high]) encoded.WriteString(houCodebook[low]) } - + return encoded.String() } @@ -52,31 +53,31 @@ func decodeHou(code string) string { validChars = append(validChars, charStr) } } - + if len(validChars)%2 != 0 { return "齁语密文长度错误,无法解密" } - + // 解密过程 var byteList []byte for i := 0; i < len(validChars); i += 2 { highIdx, highExists := houCodebookMap[validChars[i]] lowIdx, lowExists := houCodebookMap[validChars[i+1]] - + if !highExists || !lowExists { return "齁语密文包含无效字符" } - + originalByte := byte((highIdx << 4) | lowIdx) byteList = append(byteList, originalByte) } - + result := string(byteList) - + if !isValidUTF8(result) { return "齁语解密失败,结果不是有效的文本" } - + return result } @@ -84,4 +85,4 @@ func decodeHou(code string) string { func isValidUTF8(s string) bool { // Go的string类型默认就是UTF-8,如果转换没有出错说明是有效的 return len(s) > 0 || s == "" -} \ No newline at end of file +} diff --git a/plugin/crypter/main.go b/plugin/crypter/main.go index e850a9b5..4a94ffca 100644 --- a/plugin/crypter/main.go +++ b/plugin/crypter/main.go @@ -10,7 +10,7 @@ import ( func init() { engine := control.Register("crypter", &ctrl.Options[*zero.Ctx]{ DisableOnDefault: false, - Brief: "奇怪语言加解密", + Brief: "奇怪语言加解密", Help: "多种语言加解密插件\n" + "- 齁语加解密:\n" + "- 齁语加密 [文本] 或 h加密 [文本]\n" + @@ -21,11 +21,11 @@ func init() { PublicDataFolder: "Crypter", }) - //hou + // hou engine.OnRegex(`^(?:齁语加密|h加密)\s*(.+)$`).SetBlock(true).Handle(houEncryptHandler) engine.OnRegex(`^(?:齁语解密|h解密)\s*(.+)$`).SetBlock(true).Handle(houDecryptHandler) - //Fumo + // Fumo engine.OnRegex(`^fumo加密\s*(.+)$`).SetBlock(true).Handle(fumoEncryptHandler) engine.OnRegex(`^fumo解密\s*(.+)$`).SetBlock(true).Handle(fumoDecryptHandler) -} \ No newline at end of file +}