diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py index c590b032..4c948371 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py @@ -6,32 +6,32 @@ from . import mk_NyaCode # Twisuki async def twisuki(): - return str(mk_Info.twisuki()) + return str(await mk_Info.twisuki()) # MegaKits async def megakits(): - return str(mk_Info.megakits()) + return str(await mk_Info.megakits()) # Random Turntable -async def random_turntable(upper: int, lower: int = "0"): - return str(mk_Common.random_turntable(upper, lower)) +async def random_turntable(upper: int, lower: int = 0): + return str(await mk_Common.random_turntable(upper, lower)) # Number Calc async def number_calc(a: str, b: str, op: str): - return str(mk_Common.number_calc(a, b, op)) + return str(await mk_Common.number_calc(a, b, op)) # MorseCode Encrypt async def morse_encrypt(msg: str): - return str(mk_MorseCode.morse_encrypt(msg)) + return str(await mk_MorseCode.morse_encrypt(msg)) # MorseCode Decrypt async def morse_decrypt(msg: str): - return str(mk_MorseCode.morse_decrypt(msg)) + return str(await mk_MorseCode.morse_decrypt(msg)) # NyaCode Encrypt async def nya_encode(msg: str): - return str(mk_NyaCode.nya_encode(msg)) + return str(await mk_NyaCode.nya_encode(msg)) # NyaCode Decrypt async def nya_decode(msg: str): - return str(mk_NyaCode.nya_decode(msg)) + return str(await mk_NyaCode.nya_decode(msg)) diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py index 5d96525d..f93e0836 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py @@ -1,11 +1,11 @@ import random # Random Turntable -async def random_turntable(upper: int, lower: int = "0"): +async def random_turntable(upper: int, lower: int): return random.randint(lower, upper) # Number Calc -def number_calc(a: str, b: str, op: str): +async def number_calc(a: str, b: str, op: str): a, b = float(a), float(b) match op: case "+": diff --git a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py index f89bc32c..1178fb75 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Info.py @@ -1,7 +1,7 @@ # Twisuki -def twisuki(): - return "Twiuski(苏阳)是megakits插件作者, Github : 'https://github.com/Twisuki'" +async 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/LiteyukiStudio/marsho-toolsets/tree/main/Twisuki/marshoai-megakits'" +async def megakits(): + return "MegaKits插件是一个功能混杂的MarshoAI插件, 由Twisuki(Github : \"https://github.com/Twisuki\")开发, 插件仓库 : \"https://github.com/LiteyukiStudio/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 index e81e0cad..562d5f3c 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_MorseCode.py @@ -1,37 +1,37 @@ # 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': '-----', - '.': '.-.-.-', ':': '---...', ',': '--..--', ';': '-.-.-.', - '?': '..--..', '=': '-...-', '\'': '.----.', '/': '-..-.', - '!': '-.-.--', '-': '-....-', '_': '..--.-', '\"': '.-..-.', - '(': '-.--.', ')': '-.--.-', '$': '...-..-', '&': '....', - '@': '.--.-.', ' ': ' ' + "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): +async def morse_encrypt(msg: str): result = "" msg = msg.upper() for char in msg: if char in MorseEncode: result += MorseEncode[char] else: - result += '..--..' - result += ' ' + result += "..--.." + result += " " return result # MorseCode Decrypt -def morse_decrypt(msg: str): +async def morse_decrypt(msg: str): result = "" msg_arr = msg.split() @@ -39,6 +39,6 @@ def morse_decrypt(msg: str): if char in MorseDecode: result += MorseDecode[char] else: - result += '?' + 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 index 3ba1dbdc..57f692ab 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py +++ b/nonebot_plugin_marshoai/tools/marshoai-megakits/mk_NyaCode.py @@ -3,26 +3,26 @@ import base64 # NyaCode NyaCodeCharset = [ - '喵', '呜', '?', '~' + "喵", "呜", "?", "~" ] NyaCodeSpecialCharset = [ - '唔', '!', '...', '..' + "唔", "!", "...", ".." ] NyaCodeEncode = {} for i in range(64): - triplet = ''.join(NyaCodeCharset[(i // (4 ** j)) % 4] for j in range(3)) + 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) +async 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 char == '呜' and random.random() < 0.5: + if char == "呜" and random.random() < 0.5: result += "!" if random.random() < 0.25: @@ -33,8 +33,8 @@ def nya_encode(msg: str): # NyaCode Decrypt -def nya_decode(msg: str): - msg = msg.replace('唔', '').replace('!', '').replace('.', '') +async def nya_decode(msg: str): + msg = msg.replace("唔", "").replace("!", "").replace(".", "") msg_nyastr = [] i = 0 if len(msg) % 3 != 0 : @@ -47,7 +47,7 @@ def nya_decode(msg: str): i += 3 except Exception: 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: result = base64.b64decode(msg_b64str.encode()).decode() diff --git a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py index d7726f09..cec9ad3d 100644 --- a/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py +++ b/nonebot_plugin_marshoai/tools/marshoai-meogirl/mg_Search.py @@ -6,7 +6,7 @@ import urllib.parse from bs4 import BeautifulSoup headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" } async def get_async_data (url): @@ -19,7 +19,7 @@ async def search(msg : str, num : int): url = "https://mzh.moegirl.org.cn/index.php?search=" + urllib.parse.quote_plus(msg) response = await get_async_data(url) - logger.success(f"连接{url}完成, 状态码 : {response.status_code}") + logger.success(f"连接\"{url}\"完成, 状态码 : {response.status_code}") # 正常搜索 if response.status_code == 200: @@ -35,25 +35,25 @@ async def search(msg : str, num : int): └── li ... └── li ... """ - soup = BeautifulSoup(response.text, 'html.parser') + soup = BeautifulSoup(response.text, "html.parser") # 检测ul.mw-search-results, 是否有结果 - if soup.find('ul', class_='mw-search-results'): - ul_tag = soup.select('ul.mw-search-results')[0] - li_tags = ul_tag.select('li') + ul_tag = soup.find("ul", class_ = "mw-search-results") + if ul_tag: + li_tags = ul_tag.find_all("li") for li_tag in li_tags: - div_heading = li_tag.select('div.mw-search-result-heading')[0] + div_heading = li_tag.find("div", class_ = "mw-search-result-heading") if div_heading: - a_tag = div_heading.select('a')[0] - result += a_tag['title'] + "\n" - logger.info(f"搜索到 : \"{a_tag['title']}\"") + a_tag = div_heading.find("a") + result += a_tag["title"] + "\n" + logger.info(f"搜索到 : \"{a_tag["title"]}\"") - div_result = li_tag.find('div', class_='searchresult') + div_result = li_tag.find("div", class_="searchresult") if div_result: - content = str(div_result).replace('