mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-02 11:40:04 +00:00
✨ 添加 mk_common.py 和 mk_info.py 文件,提供随机转盘和数字计算功能
This commit is contained in:
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 "未知运算符"
|
||||
|
Reference in New Issue
Block a user