chore(lint): 改进代码样式 (#1192)
Some checks are pending
打包最新版为 Docker Image / build docker (push) Waiting to run
最新版 / Build binary CI (386, linux) (push) Waiting to run
最新版 / Build binary CI (386, windows) (push) Waiting to run
最新版 / Build binary CI (amd64, linux) (push) Waiting to run
最新版 / Build binary CI (amd64, windows) (push) Waiting to run
最新版 / Build binary CI (arm, linux) (push) Waiting to run
最新版 / Build binary CI (arm64, linux) (push) Waiting to run
PushLint / lint (push) Waiting to run

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2025-09-02 13:13:22 +08:00 committed by GitHub
parent cd16a755d7
commit 35292a69fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 25 deletions

View File

@ -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
}
}

View File

@ -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))
}
}

View File

@ -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 == ""
}
}

View File

@ -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)
}
}