zhenxun_bot/plugins/coser/__init__.py

52 lines
1.6 KiB
Python
Raw Normal View History

2022-02-19 18:20:19 +08:00
from nonebot import on_regex
2021-05-20 19:21:05 +08:00
from nonebot.typing import T_State
2022-02-19 18:20:19 +08:00
from nonebot.adapters.onebot.v11 import Bot, MessageEvent
2021-07-30 21:21:51 +08:00
from utils.message_builder import image
2021-11-23 21:44:59 +08:00
from services.log import logger
2021-11-29 13:09:47 +08:00
from utils.manager import withdraw_message_manager
from configs.config import Config
2021-05-20 19:21:05 +08:00
2021-10-03 14:24:07 +08:00
__zx_plugin_name__ = "coser"
__plugin_usage__ = """
usage
三次元也不戳嘿嘿嘿
指令
cos/coser
""".strip()
__plugin_des__ = "三次元也不戳,嘿嘿嘿"
__plugin_cmd__ = ["cos/coser"]
__plugin_version__ = 0.1
__plugin_author__ = "HibiKier"
__plugin_settings__ = {
"level": 5,
"default_status": True,
"limit_superuser": False,
"cmd": ["cos", "coser", "括丝", "COS", "Cos", "cOS", "coS"],
}
2021-11-29 13:09:47 +08:00
__plugin_configs__ = {
"WITHDRAW_COS_MESSAGE": {
"value": (0, 1),
"help": "自动撤回参1延迟撤回色图时间(秒)0 为关闭 | 参2监控聊天类型0(私聊) 1(群聊) 2(群聊+私聊)",
"default_value": (0, 1),
},
}
2021-05-20 19:21:05 +08:00
2022-02-19 18:20:19 +08:00
coser = on_regex("^(cos|COS|coser|括丝)$", priority=5, block=True)
2021-05-20 19:21:05 +08:00
2022-02-19 18:20:19 +08:00
url = "https://api.iyk0.com/cos"
2021-05-20 19:21:05 +08:00
@coser.handle()
2021-07-30 21:21:51 +08:00
async def _(bot: Bot, event: MessageEvent, state: T_State):
2021-11-23 21:44:59 +08:00
try:
2021-11-29 13:09:47 +08:00
msg_id = await coser.send(image(url))
withdraw_message_manager.withdraw_message(
event,
msg_id["message_id"],
Config.get_config("coser", "WITHDRAW_COS_MESSAGE"),
)
2021-11-23 21:44:59 +08:00
except Exception as e:
await coser.send("你cos给我看")
logger.error(f"coser 发送了未知错误 {type(e)}{e}")