From 4f67d0c79461f232c1017c0c2cfaa0d3f8106707 Mon Sep 17 00:00:00 2001 From: Twisuki Date: Thu, 5 Dec 2024 13:45:54 +0800 Subject: [PATCH] deleted: nonebot_plugin_marshoai/tools/marshoai-megakits/a.py new file: nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py new file: nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py new file: nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py new file: nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py nonebot_plugin_marshoai/tools/marshoai-megakits/tools.json --- .../tools/marshoai-megakits/a.py | 5 -- .../tools/marshoai-megakits/mk_Common.py | 24 +++++++++ .../tools/marshoai-megakits/mk_Info.py | 7 +++ .../tools/marshoai-megakits/mk_MorseCode.py | 44 ++++++++++++++++ .../tools/marshoai-megakits/mk_NyaCode.py | 52 +++++++++++++++++++ 5 files changed, 127 insertions(+), 5 deletions(-) delete mode 100644 nonebot_plugin_marshoai/tools/marshoai-megakits/a.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py create mode 100644 nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/a.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/a.py deleted file mode 100644 index 930ad197..00000000 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/a.py +++ /dev/null @@ -1,5 +0,0 @@ -from nonebot import logger - - -def b () : - logger.success("测试成功") \ No newline at end of file diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py new file mode 100644 index 00000000..5d96525d --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py @@ -0,0 +1,24 @@ +import random + +# Random Turntable +async def random_turntable(upper: int, lower: int = "0"): + return random.randint(lower, upper) + +# Number Calc +def number_calc(a: str, b: str, op: str): + a, b = float(a), float(b) + match op: + case "+": + return str(a + b) + case "-": + return str(a - b) + case "*": + return str(a * b) + case "/": + return str(a / b) + case "**": + return str(a ** b) + case "%": + return str(a % b) + case _: + return "未知运算符" \ No newline at end of file diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py new file mode 100644 index 00000000..c9611e95 --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py @@ -0,0 +1,7 @@ +# Twisuki +def twisuki(): + return "Twiuski(苏阳)是megakits插件作者, Github : 'https://github.com/Twisuki'" + +# MegaKits +def megakits(): + return "MegaKits插件是一个功能混杂的MarshoAI插件, 由Twisuki(Github : 'https://github.com/Twisuki')开发, 插件仓库 : 'https://github.com/Twisuki/marsho-toolsets/tree/main/Twisuki/marshoai-megakits'" diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py new file mode 100644 index 00000000..e81e0cad --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py @@ -0,0 +1,44 @@ +# MorseCode +MorseEncode = { + 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', + 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', + 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', + 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', + 'Y': '-.--', 'Z': '--..', + '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', + '6': '-....', '7': '--...', '8': '---..', '9': '----.', '0': '-----', + '.': '.-.-.-', ':': '---...', ',': '--..--', ';': '-.-.-.', + '?': '..--..', '=': '-...-', '\'': '.----.', '/': '-..-.', + '!': '-.-.--', '-': '-....-', '_': '..--.-', '\"': '.-..-.', + '(': '-.--.', ')': '-.--.-', '$': '...-..-', '&': '....', + '@': '.--.-.', ' ': ' ' +} +MorseDecode = {value: key for key, value in MorseEncode.items()} + + +# MorseCode Encrypt +def morse_encrypt(msg: str): + result = "" + msg = msg.upper() + for char in msg: + if char in MorseEncode: + result += MorseEncode[char] + else: + result += '..--..' + result += ' ' + + return result + + +# MorseCode Decrypt +def morse_decrypt(msg: str): + result = "" + + msg_arr = msg.split() + for char in msg_arr: + if char in MorseDecode: + result += MorseDecode[char] + else: + result += '?' + + return result diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py new file mode 100644 index 00000000..299394b6 --- /dev/null +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py @@ -0,0 +1,52 @@ +import random +import base64 + +# NyaCode +NyaCodeCharset = [ + '喵', '呜', '?', '~' +] +NyaCodeSpecialCharset = [ + '唔', '!', '...', '....' +] +NyaCodeEncode = {} +for i in range(64): + triplet = ''.join(NyaCodeCharset[(i // (4 ** j)) % 4] for j in range(3)) + NyaCodeEncode[chr(65 + i if i < 26 else 97 + (i - 26) if i < 52 else 48 + (i - 52) if i < 62 else ( + 43 if i == 62 else 47))] = triplet +NyaCodeDecode = {value: key for key, value in NyaCodeEncode.items()} + + +# NyaCode Encrypt +def nya_encode(msg: str): + msg_b64str = base64.b64encode(msg.encode()).decode().replace('=', '') + msg_nyastr = ''.join(NyaCodeEncode[base64_char] for base64_char in msg_b64str) + result = "" + for char in msg_nyastr: + if random.random() < 0.2: + result += random.choice(NyaCodeSpecialCharset) + char + else: + result += char + return result + + +# NyaCode Decrypt +def nya_decode(msg: str): + msg = msg.replace('唔', '').replace('.', '').replace('!', '') + msg_nyastr = [] + i = 0 + if len(msg) % 3 != 0 : + return "这句话不是正确的猫语" + while i < len(msg): + nyachar = msg[i : i + 3] + try: + if all(char in NyaCodeCharset for char in nyachar): + msg_nyastr.append(nyachar) + i += 3 + except Exception: + return "这句话不是正确的猫语" + msg_b64str = ''.join(NyaCodeDecode[nya_char] for nya_char in msg_nyastr) + try: + result = base64.b64decode(msg_b64str.encode()).decode() + except Exception: + return "翻译失败" + return result