mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 21:46:10 +08:00
modified: nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py
This commit is contained in:
parent
553e2b8b25
commit
580f01d844
@ -6,7 +6,7 @@ NyaCodeCharset = [
|
|||||||
'喵', '呜', '?', '~'
|
'喵', '呜', '?', '~'
|
||||||
]
|
]
|
||||||
NyaCodeSpecialCharset = [
|
NyaCodeSpecialCharset = [
|
||||||
'唔', '!', '...', '....'
|
'唔', '!', '...', '..'
|
||||||
]
|
]
|
||||||
NyaCodeEncode = {}
|
NyaCodeEncode = {}
|
||||||
for i in range(64):
|
for i in range(64):
|
||||||
@ -22,7 +22,10 @@ def nya_encode(msg: str):
|
|||||||
msg_nyastr = ''.join(NyaCodeEncode[base64_char] for base64_char in msg_b64str)
|
msg_nyastr = ''.join(NyaCodeEncode[base64_char] for base64_char in msg_b64str)
|
||||||
result = ""
|
result = ""
|
||||||
for char in msg_nyastr:
|
for char in msg_nyastr:
|
||||||
if random.random() < 0.2:
|
if char == '呜' and random.random() < 0.5:
|
||||||
|
result += "!"
|
||||||
|
|
||||||
|
if random.random() < 0.25:
|
||||||
result += random.choice(NyaCodeSpecialCharset) + char
|
result += random.choice(NyaCodeSpecialCharset) + char
|
||||||
else:
|
else:
|
||||||
result += char
|
result += char
|
||||||
@ -31,7 +34,7 @@ def nya_encode(msg: str):
|
|||||||
|
|
||||||
# NyaCode Decrypt
|
# NyaCode Decrypt
|
||||||
def nya_decode(msg: str):
|
def nya_decode(msg: str):
|
||||||
msg = msg.replace('唔', '').replace('.', '').replace('!', '')
|
msg = msg.replace('唔', '').replace('!', '').replace('.', '')
|
||||||
msg_nyastr = []
|
msg_nyastr = []
|
||||||
i = 0
|
i = 0
|
||||||
if len(msg) % 3 != 0 :
|
if len(msg) % 3 != 0 :
|
||||||
@ -45,6 +48,7 @@ def nya_decode(msg: str):
|
|||||||
except Exception:
|
except Exception:
|
||||||
return "这句话不是正确的猫语"
|
return "这句话不是正确的猫语"
|
||||||
msg_b64str = ''.join(NyaCodeDecode[nya_char] for nya_char in msg_nyastr)
|
msg_b64str = ''.join(NyaCodeDecode[nya_char] for nya_char in msg_nyastr)
|
||||||
|
msg_b64str += "=" * (4 - len(msg_b64str) % 4)
|
||||||
try:
|
try:
|
||||||
result = base64.b64decode(msg_b64str.encode()).decode()
|
result = base64.b64decode(msg_b64str.encode()).decode()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user