添加随机数生成器插件,支持生成指定数量的随机数

This commit is contained in:
远野千束(神羽) 2024-12-16 03:16:27 +08:00
parent 05cce4b8e8
commit dd05e603e0

View File

@ -0,0 +1,18 @@
import random
from nonebot_plugin_marshoai.plugin import Integer, PluginMetadata, on_function_call
__marsho_meta__ = PluginMetadata(
name="随机数生成器", author="MarshoAI", description="生成指定数量的随机数"
)
@on_function_call(description="生成随机数").params(
count=Integer(description="随机数的数量")
)
async def generate_random_numbers(count: int) -> str:
random_numbers = [random.randint(1, 100) for _ in range(count)]
return f"生成的随机数为: {', '.join(map(str, random_numbers))}"
# 该插件由MarshoAI自举编写