Skip to content

Commit

Permalink
✨ 更新 mypy 版本至 1.13.0,重构 marshoai-megakits 模块并添加随机数和计算功能
Browse files Browse the repository at this point in the history
  • Loading branch information
snowykami committed Dec 12, 2024
1 parent 8defcfd commit 5797381
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 80 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions nonebot_plugin_marshoai/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_marshoai/config.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
41 changes: 0 additions & 41 deletions nonebot_plugin_marshoai/tools/marshoai-megakits/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions nonebot_plugin_marshoai/tools/marshoai-megakits/mk_Common.py

This file was deleted.

41 changes: 41 additions & 0 deletions nonebot_plugin_marshoai/tools/marshoai_megakits/__init__.py
Original file line number Diff line number Diff line change
@@ -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 changes: 45 additions & 0 deletions nonebot_plugin_marshoai/tools/marshoai_megakits/mk_Common.py
Original file line number Diff line number Diff line change
@@ -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 "未知运算符"

Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_marshoai/util_hunyuan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

0 comments on commit 5797381

Please sign in to comment.