zhenxun_bot/plugins/send_dinggong_voice/__init__.py
2021-11-04 16:11:50 +08:00

49 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from nonebot import on_keyword
from utils.message_builder import record
from configs.path_config import VOICE_PATH
import random
from services.log import logger
from nonebot.typing import T_State
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
from nonebot.rule import to_me
import os
__zx_plugin_name__ = "骂我"
__plugin_usage__ = """
usage
多骂我一点,球球了
指令:
骂老子
""".strip()
__plugin_des__ = "请狠狠的骂我一次!"
__plugin_cmd__ = ["骂老子/骂我"]
__plugin_version__ = 0.1
__plugin_author__ = "HibiKier"
__plugin_settings__ = {
"level": 5,
"default_status": True,
"limit_superuser": False,
"cmd": ["骂老子", "骂我"],
}
__plugin_cd_limit__ = {
"cd": 3,
"rst": "就...就算求我骂你也得慢慢来..."
}
dg_voice = on_keyword({""}, rule=to_me(), priority=5, block=True)
@dg_voice.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
if len(str((event.get_message()))) > 1:
voice = random.choice(os.listdir(VOICE_PATH + "dinggong/"))
result = record(voice, "dinggong")
await dg_voice.send(result)
await dg_voice.send(voice.split("_")[1])
logger.info(
f"(USER {event.user_id}, GROUP "
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 发送钉宫骂人:"
+ result
)