mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-25 15:29:31 +08:00
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
This commit is contained in:
parent
4f92bdd6b6
commit
4f67d0c794
nonebot_plugin_marshoai/tools/marshoai-megakits
@ -1,5 +0,0 @@
|
||||
from nonebot import logger
|
||||
|
||||
|
||||
def b () :
|
||||
logger.success("测试成功")
|
24
nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py
Normal file
24
nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py
Normal file
@ -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 "未知运算符"
|
@ -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'"
|
@ -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
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user