-
Notifications
You must be signed in to change notification settings - Fork 2k
插件crypter添加qq表情加密并支持回应密文进行解密,与添加运势新底图 #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,25 @@ func init() { | |
| "- 齁语解密 [密文] 或 h解密 [密文]\n\n" + | ||
| "- Fumo语加解密:\n" + | ||
| "- fumo加密 [文本]\n" + | ||
| "- fumo解密 [密文]\n\n", | ||
| "- fumo解密 [密文]\n\n" + | ||
| "- QQ表情加解密:\n" + | ||
| "- qq加密 [文本]\n" + | ||
| "- qq解密 [密文]\n\n" + | ||
| "注意:QQ表情解密建议使用回复,尽量不要复制粘贴\n\n", | ||
| PublicDataFolder: "Crypter", | ||
| }) | ||
|
|
||
| re := `(?:\[CQ:reply,id=-?\d+\])?` | ||
|
|
||
| // hou | ||
| engine.OnRegex(`^(?:齁语加密|h加密)\s*(.+)$`).SetBlock(true).Handle(houEncryptHandler) | ||
| engine.OnRegex(`^(?:齁语解密|h解密)\s*(.+)$`).SetBlock(true).Handle(houDecryptHandler) | ||
| engine.OnRegex(re + `^(?:齁语加密|h加密)\s*(.+)$`).SetBlock(true).Handle(houEncryptHandler) | ||
| engine.OnRegex(re + `(?:齁语解密|h解密)\s*(.*)$`).SetBlock(true).Handle(houDecryptHandler) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为什么用
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在比如有人发密文,可以直接回复那条消息发xx解密,不用带参数 |
||
|
|
||
| // Fumo | ||
| engine.OnRegex(`^fumo加密\s*(.+)$`).SetBlock(true).Handle(fumoEncryptHandler) | ||
| engine.OnRegex(`^fumo解密\s*(.+)$`).SetBlock(true).Handle(fumoDecryptHandler) | ||
| engine.OnRegex(re + `^fumo加密\s*(.+)$`).SetBlock(true).Handle(fumoEncryptHandler) | ||
| engine.OnRegex(re + `fumo解密\s*(.*)$`).SetBlock(true).Handle(fumoDecryptHandler) | ||
|
|
||
| // QQ表情 | ||
| engine.OnRegex(re + `^qq加密\s*(.+)$`).SetBlock(true).Handle(qqEmojiEncryptHandler) | ||
| engine.OnRegex(re + `qq解密`).SetBlock(true).Handle(qqEmojiDecryptHandler) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Package crypter QQ表情加解密 | ||
| package crypter | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "unicode/utf8" | ||
|
|
||
| "github.com/wdvxdr1123/ZeroBot/message" | ||
| ) | ||
|
|
||
| const ( | ||
| emojiZeroID = 297 | ||
| emojiOneID = 424 | ||
| ) | ||
|
|
||
| func encodeQQEmoji(text string) message.Message { | ||
| if text == "" { | ||
| return message.Message{message.Text("请输入要加密的文本")} | ||
| } | ||
|
|
||
| var bin strings.Builder | ||
| for _, b := range []byte(text) { | ||
| fmt.Fprintf(&bin, "%08b", b) | ||
| } | ||
|
|
||
| s := bin.String() | ||
| msg := make(message.Message, 0, len(s)) | ||
| for _, bit := range s { | ||
| if bit == '0' { | ||
| msg = append(msg, message.Face(emojiZeroID)) | ||
| } else { | ||
| msg = append(msg, message.Face(emojiOneID)) | ||
| } | ||
| } | ||
| return msg | ||
| } | ||
|
|
||
| func decodeQQEmoji(faceIDs []int) string { | ||
| var bin strings.Builder | ||
| for _, id := range faceIDs { | ||
| if id == emojiZeroID { | ||
| bin.WriteByte('0') | ||
| } else if id == emojiOneID { | ||
| bin.WriteByte('1') | ||
| } | ||
| } | ||
| binary := bin.String() | ||
| if len(binary) == 0 || len(binary)%8 != 0 { | ||
| return "QQ表情密文格式错误" | ||
| } | ||
|
|
||
| data := make([]byte, len(binary)/8) | ||
| for i := range data { | ||
| for j := 0; j < 8; j++ { | ||
| if binary[i*8+j] == '1' { | ||
| data[i] |= 1 << (7 - j) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if !utf8.Valid(data) { | ||
| return "QQ表情解密失败:结果不是有效文本" | ||
| } | ||
| return string(data) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不好。应当用
FindAllStringSubmatch直接提取出所有数字。