2021-05-20 19:21:05 +08:00
|
|
|
|
from nonebot import on_command
|
|
|
|
|
|
from nonebot.typing import T_State
|
2021-07-30 21:21:51 +08:00
|
|
|
|
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
|
2021-05-20 19:21:05 +08:00
|
|
|
|
from services.log import logger
|
2021-07-30 21:21:51 +08:00
|
|
|
|
from utils.message_builder import image
|
2021-05-20 19:21:05 +08:00
|
|
|
|
import requests
|
|
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
__plugin_name__ = "coser"
|
2021-06-15 10:57:08 +08:00
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
__plugin_usage__ = "用法:发送‘coser’"
|
2021-05-20 19:21:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
coser = on_command(
|
|
|
|
|
|
"cos", aliases={"coser", "括丝", "COS", "Cos", "cOS", "coS"}, priority=5, block=True
|
|
|
|
|
|
)
|
2021-05-20 19:21:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
url_2 = "http://api.rosysun.cn/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-05-20 19:21:05 +08:00
|
|
|
|
img_url = requests.get(url_2).text
|
|
|
|
|
|
await coser.send(image(img_url))
|
|
|
|
|
|
logger.info(
|
2021-07-30 21:21:51 +08:00
|
|
|
|
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'}) 发送COSER"
|
|
|
|
|
|
)
|