2024-05-29 19:27:58 +08:00
|
|
|
|
import asyncio
|
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
|
|
from nonebot import on_command
|
|
|
|
|
|
from nonebot.plugin import PluginMetadata
|
|
|
|
|
|
from nonebot_plugin_alconna import UniMsg
|
|
|
|
|
|
from nonebot_plugin_session import EventSession
|
|
|
|
|
|
|
2024-08-24 17:06:23 +08:00
|
|
|
|
from zhenxun.configs.config import BotConfig
|
2024-05-29 19:27:58 +08:00
|
|
|
|
from zhenxun.configs.utils import PluginExtraData
|
|
|
|
|
|
from zhenxun.services.log import logger
|
2024-07-18 23:16:29 +08:00
|
|
|
|
from zhenxun.utils.depends import UserName
|
2024-08-11 15:57:33 +08:00
|
|
|
|
from zhenxun.utils.message import MessageUtils
|
2024-05-29 19:27:58 +08:00
|
|
|
|
|
|
|
|
|
|
__plugin_meta__ = PluginMetadata(
|
|
|
|
|
|
name="roll",
|
|
|
|
|
|
description="犹豫不决吗?那就让我帮你决定吧",
|
|
|
|
|
|
usage="""
|
|
|
|
|
|
usage:
|
|
|
|
|
|
随机数字 或 随机选择事件
|
|
|
|
|
|
指令:
|
|
|
|
|
|
roll: 随机 0-100 的数字
|
|
|
|
|
|
roll *[文本]: 随机事件
|
|
|
|
|
|
示例:roll 吃饭 睡觉 打游戏
|
|
|
|
|
|
""".strip(),
|
|
|
|
|
|
extra=PluginExtraData(author="HibiKier", version="0.1").dict(),
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_matcher = on_command("roll", priority=5, block=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@_matcher.handle()
|
|
|
|
|
|
async def _(
|
|
|
|
|
|
session: EventSession,
|
|
|
|
|
|
message: UniMsg,
|
2024-07-18 23:16:29 +08:00
|
|
|
|
user_name: str = UserName(),
|
2024-05-29 19:27:58 +08:00
|
|
|
|
):
|
|
|
|
|
|
text = message.extract_plain_text().strip().replace("roll", "", 1).split()
|
|
|
|
|
|
if not text:
|
2024-08-11 15:57:33 +08:00
|
|
|
|
await MessageUtils.build_message(f"roll: {random.randint(0, 100)}").finish(
|
|
|
|
|
|
reply_to=True
|
|
|
|
|
|
)
|
|
|
|
|
|
await MessageUtils.build_message(
|
2024-05-29 19:27:58 +08:00
|
|
|
|
random.choice(
|
|
|
|
|
|
[
|
|
|
|
|
|
"转动命运的齿轮,拨开眼前迷雾...",
|
|
|
|
|
|
f"启动吧,命运的水晶球,为{user_name}指引方向!",
|
|
|
|
|
|
"嗯哼,在此刻转动吧!命运!",
|
|
|
|
|
|
f"在此祈愿,请为{user_name}降下指引...",
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|
|
|
|
|
|
).send()
|
|
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
|
|
random_text = random.choice(text)
|
2024-08-11 15:57:33 +08:00
|
|
|
|
await MessageUtils.build_message(
|
2024-05-29 19:27:58 +08:00
|
|
|
|
random.choice(
|
|
|
|
|
|
[
|
2024-08-24 19:32:52 +08:00
|
|
|
|
f"让{BotConfig.self_nickname}看看是什么结果!答案是:‘{random_text}’",
|
2024-05-29 19:27:58 +08:00
|
|
|
|
f"根据命运的指引,接下来{user_name} ‘{random_text}’ 会比较好",
|
|
|
|
|
|
f"祈愿被回应了!是 ‘{random_text}’!",
|
|
|
|
|
|
f"结束了,{user_name},命运之轮停在了 ‘{random_text}’!",
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|
2024-08-11 15:57:33 +08:00
|
|
|
|
).send(reply_to=True)
|
2024-05-29 19:27:58 +08:00
|
|
|
|
logger.info(f"发送roll:{text}", "roll", session=session)
|