mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
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
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:
parent
cd16a755d7
commit
35292a69fc
@ -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+", "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 encodeMap = make(map[byte]string)
|
||||||
|
|
||||||
// 创建解码映射表
|
// 创建解码映射表
|
||||||
var decodeMap = make(map[string]byte)
|
var decodeMap = make(map[string]byte)
|
||||||
|
|
||||||
@ -35,13 +36,13 @@ func init() {
|
|||||||
for i := 0; i < 64 && i < len(fumoChars); i++ {
|
for i := 0; i < 64 && i < len(fumoChars); i++ {
|
||||||
base64Char := base64Chars[i]
|
base64Char := base64Chars[i]
|
||||||
fumoChar := fumoChars[i]
|
fumoChar := fumoChars[i]
|
||||||
|
|
||||||
encodeMap[base64Char] = fumoChar
|
encodeMap[base64Char] = fumoChar
|
||||||
decodeMap[fumoChar] = base64Char
|
decodeMap[fumoChar] = base64Char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//加密
|
// 加密
|
||||||
func encryptFumo(text string) string {
|
func encryptFumo(text string) string {
|
||||||
if text == "" {
|
if text == "" {
|
||||||
return "请输入要加密的文本"
|
return "请输入要加密的文本"
|
||||||
@ -59,11 +60,11 @@ func encryptFumo(text string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result := fumoBody.String() + strings.Repeat("=", paddingCount)
|
result := fumoBody.String() + strings.Repeat("=", paddingCount)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
//解密
|
// 解密
|
||||||
func decryptFumo(fumoText string) string {
|
func decryptFumo(fumoText string) string {
|
||||||
if fumoText == "" {
|
if fumoText == "" {
|
||||||
return "请输入要解密的Fumo语密文"
|
return "请输入要解密的Fumo语密文"
|
||||||
@ -91,4 +92,4 @@ func decryptFumo(fumoText string) string {
|
|||||||
}
|
}
|
||||||
originalText := string(decodedBytes)
|
originalText := string(decodedBytes)
|
||||||
return originalText
|
return originalText
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
//hou
|
// hou
|
||||||
func houEncryptHandler(ctx *zero.Ctx) {
|
func houEncryptHandler(ctx *zero.Ctx) {
|
||||||
text := ctx.State["regex_matched"].([]string)[1]
|
text := ctx.State["regex_matched"].([]string)[1]
|
||||||
result := encodeHou(text)
|
result := encodeHou(text)
|
||||||
@ -19,7 +19,7 @@ func houDecryptHandler(ctx *zero.Ctx) {
|
|||||||
ctx.SendChain(message.Text(result))
|
ctx.SendChain(message.Text(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
//fumo
|
// fumo
|
||||||
func fumoEncryptHandler(ctx *zero.Ctx) {
|
func fumoEncryptHandler(ctx *zero.Ctx) {
|
||||||
text := ctx.State["regex_matched"].([]string)[1]
|
text := ctx.State["regex_matched"].([]string)[1]
|
||||||
result := encryptFumo(text)
|
result := encryptFumo(text)
|
||||||
@ -30,4 +30,4 @@ func fumoDecryptHandler(ctx *zero.Ctx) {
|
|||||||
text := ctx.State["regex_matched"].([]string)[1]
|
text := ctx.State["regex_matched"].([]string)[1]
|
||||||
result := decryptFumo(text)
|
result := decryptFumo(text)
|
||||||
ctx.SendChain(message.Text(result))
|
ctx.SendChain(message.Text(result))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,10 @@ import (
|
|||||||
|
|
||||||
// 齁语密码表
|
// 齁语密码表
|
||||||
var houCodebook = []string{
|
var houCodebook = []string{
|
||||||
"齁", "哦", "噢", "喔", "咕", "咿", "嗯", "啊",
|
"齁", "哦", "噢", "喔", "咕", "咿", "嗯", "啊",
|
||||||
"~", "哈", "!", "唔", "哼", "❤", "呃", "呼",
|
"~", "哈", "!", "唔", "哼", "❤", "呃", "呼",
|
||||||
}
|
}
|
||||||
|
|
||||||
// 索引: 0 1 2 3 4 5 6 7
|
// 索引: 0 1 2 3 4 5 6 7
|
||||||
// 8 9 10 11 12 13 14 15
|
// 8 9 10 11 12 13 14 15
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ func encodeHou(text string) string {
|
|||||||
encoded.WriteString(houCodebook[high])
|
encoded.WriteString(houCodebook[high])
|
||||||
encoded.WriteString(houCodebook[low])
|
encoded.WriteString(houCodebook[low])
|
||||||
}
|
}
|
||||||
|
|
||||||
return encoded.String()
|
return encoded.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,31 +53,31 @@ func decodeHou(code string) string {
|
|||||||
validChars = append(validChars, charStr)
|
validChars = append(validChars, charStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(validChars)%2 != 0 {
|
if len(validChars)%2 != 0 {
|
||||||
return "齁语密文长度错误,无法解密"
|
return "齁语密文长度错误,无法解密"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解密过程
|
// 解密过程
|
||||||
var byteList []byte
|
var byteList []byte
|
||||||
for i := 0; i < len(validChars); i += 2 {
|
for i := 0; i < len(validChars); i += 2 {
|
||||||
highIdx, highExists := houCodebookMap[validChars[i]]
|
highIdx, highExists := houCodebookMap[validChars[i]]
|
||||||
lowIdx, lowExists := houCodebookMap[validChars[i+1]]
|
lowIdx, lowExists := houCodebookMap[validChars[i+1]]
|
||||||
|
|
||||||
if !highExists || !lowExists {
|
if !highExists || !lowExists {
|
||||||
return "齁语密文包含无效字符"
|
return "齁语密文包含无效字符"
|
||||||
}
|
}
|
||||||
|
|
||||||
originalByte := byte((highIdx << 4) | lowIdx)
|
originalByte := byte((highIdx << 4) | lowIdx)
|
||||||
byteList = append(byteList, originalByte)
|
byteList = append(byteList, originalByte)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := string(byteList)
|
result := string(byteList)
|
||||||
|
|
||||||
if !isValidUTF8(result) {
|
if !isValidUTF8(result) {
|
||||||
return "齁语解密失败,结果不是有效的文本"
|
return "齁语解密失败,结果不是有效的文本"
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,4 +85,4 @@ func decodeHou(code string) string {
|
|||||||
func isValidUTF8(s string) bool {
|
func isValidUTF8(s string) bool {
|
||||||
// Go的string类型默认就是UTF-8,如果转换没有出错说明是有效的
|
// Go的string类型默认就是UTF-8,如果转换没有出错说明是有效的
|
||||||
return len(s) > 0 || s == ""
|
return len(s) > 0 || s == ""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("crypter", &ctrl.Options[*zero.Ctx]{
|
engine := control.Register("crypter", &ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Brief: "奇怪语言加解密",
|
Brief: "奇怪语言加解密",
|
||||||
Help: "多种语言加解密插件\n" +
|
Help: "多种语言加解密插件\n" +
|
||||||
"- 齁语加解密:\n" +
|
"- 齁语加解密:\n" +
|
||||||
"- 齁语加密 [文本] 或 h加密 [文本]\n" +
|
"- 齁语加密 [文本] 或 h加密 [文本]\n" +
|
||||||
@ -21,11 +21,11 @@ func init() {
|
|||||||
PublicDataFolder: "Crypter",
|
PublicDataFolder: "Crypter",
|
||||||
})
|
})
|
||||||
|
|
||||||
//hou
|
// hou
|
||||||
engine.OnRegex(`^(?:齁语加密|h加密)\s*(.+)$`).SetBlock(true).Handle(houEncryptHandler)
|
engine.OnRegex(`^(?:齁语加密|h加密)\s*(.+)$`).SetBlock(true).Handle(houEncryptHandler)
|
||||||
engine.OnRegex(`^(?:齁语解密|h解密)\s*(.+)$`).SetBlock(true).Handle(houDecryptHandler)
|
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(fumoEncryptHandler)
|
||||||
engine.OnRegex(`^fumo解密\s*(.+)$`).SetBlock(true).Handle(fumoDecryptHandler)
|
engine.OnRegex(`^fumo解密\s*(.+)$`).SetBlock(true).Handle(fumoDecryptHandler)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user