mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-01-26 18:12:47 +08:00
✨ 更新 mypy 版本至 1.13.0,重构 marshoai-megakits 模块并添加随机数和计算功能
This commit is contained in:
parent
8defcfdd66
commit
5797381824
@ -11,10 +11,10 @@ repos:
|
||||
# - id: black
|
||||
# args: [--config=./pyproject.toml]
|
||||
|
||||
# - repo: https://github.com/pre-commit/mirrors-mypy
|
||||
# rev: v0.910
|
||||
# hooks:
|
||||
# - id: mypy
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.13.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
|
||||
# - repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
# rev: v4.0.1
|
||||
|
@ -220,7 +220,7 @@ async def marsho(target: MsgTarget, event: Event, text: Optional[UniMsg] = None)
|
||||
)
|
||||
is_reasoning_model = model_name.lower() in REASONING_MODELS
|
||||
usermsg = [] if is_support_image_model else ""
|
||||
for i in text:
|
||||
for i in text: # type: ignore
|
||||
if i.type == "text":
|
||||
if is_support_image_model:
|
||||
usermsg += [TextContentItem(text=i.data["text"] + nickname_prompt)] # type: ignore
|
||||
@ -230,11 +230,11 @@ async def marsho(target: MsgTarget, event: Event, text: Optional[UniMsg] = None)
|
||||
if is_support_image_model:
|
||||
usermsg.append( # type: ignore
|
||||
ImageContentItem(
|
||||
image_url=ImageUrl(
|
||||
url=str(await get_image_b64(i.data["url"]))
|
||||
)
|
||||
)
|
||||
)
|
||||
image_url=ImageUrl( # type: ignore
|
||||
url=str(await get_image_b64(i.data["url"])) # type: ignore
|
||||
) # type: ignore
|
||||
) # type: ignore
|
||||
) # type: ignore
|
||||
elif config.marshoai_enable_support_image_tip:
|
||||
await UniMessage("*此模型不支持图片处理。").send()
|
||||
backup_context = await get_backup_context(target.id, target.private)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import yaml as yaml_
|
||||
import yaml as yaml_ # type: ignore
|
||||
from nonebot import get_plugin_config, logger
|
||||
from pydantic import BaseModel
|
||||
from ruamel.yaml import YAML
|
||||
|
@ -1,41 +0,0 @@
|
||||
from . import mk_Common, mk_Info, mk_MorseCode, mk_NyaCode
|
||||
|
||||
|
||||
# Twisuki
|
||||
async def twisuki():
|
||||
return str(await mk_Info.twisuki())
|
||||
|
||||
|
||||
# MegaKits
|
||||
async def megakits():
|
||||
return str(await mk_Info.megakits())
|
||||
|
||||
|
||||
# Random Turntable
|
||||
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(await mk_Common.number_calc(a, b, op))
|
||||
|
||||
|
||||
# MorseCode Encrypt
|
||||
async def morse_encrypt(msg: str):
|
||||
return str(await mk_MorseCode.morse_encrypt(msg))
|
||||
|
||||
|
||||
# MorseCode Decrypt
|
||||
async def morse_decrypt(msg: str):
|
||||
return str(await mk_MorseCode.morse_decrypt(msg))
|
||||
|
||||
|
||||
# NyaCode Encrypt
|
||||
async def nya_encode(msg: str):
|
||||
return str(await mk_NyaCode.nya_encode(msg))
|
||||
|
||||
|
||||
# NyaCode Decrypt
|
||||
async def nya_decode(msg: str):
|
||||
return str(await mk_NyaCode.nya_decode(msg))
|
@ -1,26 +0,0 @@
|
||||
import random
|
||||
|
||||
|
||||
# Random Turntable
|
||||
async def random_turntable(upper: int, lower: int):
|
||||
return random.randint(lower, upper)
|
||||
|
||||
|
||||
# Number Calc
|
||||
async 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 "未知运算符"
|
41
nonebot_plugin_marshoai/tools/marshoai_megakits/__init__.py
Normal file
41
nonebot_plugin_marshoai/tools/marshoai_megakits/__init__.py
Normal file
@ -0,0 +1,41 @@
|
||||
from . import mk_common, mk_info, mk_morse_code, mk_nya_code
|
||||
|
||||
|
||||
# Twisuki
|
||||
async def twisuki():
|
||||
return str(await mk_info.twisuki())
|
||||
|
||||
|
||||
# MegaKits
|
||||
async def megakits():
|
||||
return str(await mk_info.megakits())
|
||||
|
||||
|
||||
# Random Turntable
|
||||
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(await mk_common.number_calc(a, b, op))
|
||||
|
||||
|
||||
# MorseCode Encrypt
|
||||
async def morse_encrypt(msg: str):
|
||||
return str(await mk_morse_code.morse_encrypt(msg))
|
||||
|
||||
|
||||
# MorseCode Decrypt
|
||||
async def morse_decrypt(msg: str):
|
||||
return str(await mk_morse_code.morse_decrypt(msg))
|
||||
|
||||
|
||||
# NyaCode Encrypt
|
||||
async def nya_encode(msg: str):
|
||||
return str(await mk_nya_code.nya_encode(msg))
|
||||
|
||||
|
||||
# NyaCode Decrypt
|
||||
async def nya_decode(msg: str):
|
||||
return str(await mk_nya_code.nya_decode(msg))
|
45
nonebot_plugin_marshoai/tools/marshoai_megakits/mk_Common.py
Normal file
45
nonebot_plugin_marshoai/tools/marshoai_megakits/mk_Common.py
Normal file
@ -0,0 +1,45 @@
|
||||
import random
|
||||
|
||||
|
||||
async def random_turntable(upper: int, lower: int):
|
||||
"""Random Turntable
|
||||
|
||||
Args:
|
||||
upper (int): _description_
|
||||
lower (int): _description_
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
return random.randint(lower, upper)
|
||||
|
||||
|
||||
|
||||
async def number_calc(a: str, b: str, op: str) -> str:
|
||||
"""Number Calc
|
||||
|
||||
Args:
|
||||
a (str): _description_
|
||||
b (str): _description_
|
||||
op (str): _description_
|
||||
|
||||
Returns:
|
||||
str: _description_
|
||||
"""
|
||||
a, b = float(a), float(b) # type: ignore
|
||||
match op:
|
||||
case "+":
|
||||
return str(a + b) # type: ignore
|
||||
case "-":
|
||||
return str(a - b) # type: ignore
|
||||
case "*":
|
||||
return str(a * b) # type: ignore
|
||||
case "/":
|
||||
return str(a / b) # type: ignore
|
||||
case "**":
|
||||
return str(a**b) # type: ignore
|
||||
case "%":
|
||||
return str(a % b)
|
||||
case _:
|
||||
return "未知运算符"
|
||||
|
@ -67,7 +67,7 @@ async def introduce(msg: str):
|
||||
from . import mg_Search
|
||||
|
||||
context = await mg_Search.search(msg, 1)
|
||||
keyword = re.search(r".*?\n", context, flags=re.DOTALL).group()[:-1]
|
||||
keyword = re.search(r".*?\n", context, flags=re.DOTALL).group()[:-1] # type: ignore
|
||||
|
||||
logger.success(f'搜索完成, 打开"{keyword}"')
|
||||
return await introduce(keyword)
|
@ -9,7 +9,7 @@ from tencentcloud.common.profile.client_profile import \
|
||||
from tencentcloud.common.profile.http_profile import \
|
||||
HttpProfile # type: ignore
|
||||
from tencentcloud.hunyuan.v20230901 import hunyuan_client # type: ignore
|
||||
from tencentcloud.hunyuan.v20230901 import models
|
||||
from tencentcloud.hunyuan.v20230901 import models # type: ignore
|
||||
|
||||
from .config import config
|
||||
|
||||
|
@ -56,4 +56,6 @@ dev = [
|
||||
"pytest>=8.3.4",
|
||||
"pre-commit>=4.0.1",
|
||||
"nonebot-adapter-onebot>=2.4.6",
|
||||
"mypy>=1.13.0",
|
||||
"black>=24.10.0",
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user