diff --git a/README.md b/README.md index 3dd76ef8..7fbafcee 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,11 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__ ## 更新 +### 2022/7/16 + +* cos提供连发命令 +* 修复B站视频解析中b23解析错误 + ### 2022/7/13 * B站订阅提供配置项`LIVE_MSG_AT_ALL`,`UP_MSG_AT_ALL`:控制UP动态投稿和直播是否AT全体 diff --git a/plugins/coser/__init__.py b/plugins/coser/__init__.py index 4b797b0a..5d44b0f5 100755 --- a/plugins/coser/__init__.py +++ b/plugins/coser/__init__.py @@ -1,4 +1,7 @@ +from typing import Tuple, Any + from nonebot import on_regex +from nonebot.params import RegexGroup from nonebot.typing import T_State from nonebot.adapters.onebot.v11 import Bot, MessageEvent from utils.message_builder import image @@ -11,7 +14,9 @@ __plugin_usage__ = """ usage: 三次元也不戳,嘿嘿嘿 指令: - cos/coser + ?N连cos/coser + 示例:cos + 示例:5连cos (单次请求张数小于9) """.strip() __plugin_des__ = "三次元也不戳,嘿嘿嘿" __plugin_cmd__ = ["cos/coser"] @@ -31,21 +36,23 @@ __plugin_configs__ = { }, } -coser = on_regex("^(cos|COS|coser|括丝)$", priority=5, block=True) +coser = on_regex(r"^(\d)连?(cos|COS|coser|括丝)$", priority=5, block=True) url = "https://api.iyk0.com/cos" @coser.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): - try: - msg_id = await coser.send(image(url)) - withdraw_message_manager.withdraw_message( - event, - msg_id["message_id"], - Config.get_config("coser", "WITHDRAW_COS_MESSAGE"), - ) - except Exception as e: - await coser.send("你cos给我看!") - logger.error(f"coser 发送了未知错误 {type(e)}:{e}") +async def _(bot: Bot, event: MessageEvent, reg_group: Tuple[Any, ...] = RegexGroup()): + num = reg_group[0] or 1 + for _ in range(int(num)): + try: + msg_id = await coser.send(image(url)) + withdraw_message_manager.withdraw_message( + event, + msg_id["message_id"], + Config.get_config("coser", "WITHDRAW_COS_MESSAGE"), + ) + except Exception as e: + await coser.send("你cos给我看!") + logger.error(f"coser 发送了未知错误 {type(e)}:{e}") diff --git a/plugins/parse_bilibili_json.py b/plugins/parse_bilibili_json.py index b82cfa00..ca6628aa 100755 --- a/plugins/parse_bilibili_json.py +++ b/plugins/parse_bilibili_json.py @@ -56,18 +56,11 @@ async def _(event: GroupMessageEvent): ) as session: async with session.get( data["meta"]["detail_1"]["qqdocurl"], - proxy=get_local_proxy(), timeout=7, ) as response: url = str(response.url).split("?")[0] bvid = url.split("/")[-1] vd_info = await video.get_video_base_info(bvid) - # response = await AsyncHttpx.get( - # data["meta"]["detail_1"]["qqdocurl"], timeout=7 - # ) - # url = str(response.url).split("?")[0] - # bvid = url.split("/")[-1] - # vd_info = await video.Video(bvid=bvid).get_info() # 转发专栏 if ( data.get("meta") @@ -123,11 +116,17 @@ async def _(event: GroupMessageEvent): url = f"https://www.bilibili.com/video/{msg}" vd_info = await video.get_video_base_info(msg) elif "https://b23.tv" in msg: - url = "https://" + msg[msg.find("b23.tv") : msg.find("b23.tv") + 13] - res = await AsyncHttpx.get(url, timeout=7) - url = str(res.url).split("?")[0] - bvid = url.split("/")[-1] - vd_info = await video.get_video_base_info(bvid) + url = "https://" + msg[msg.find("b23.tv"): msg.find("b23.tv") + 14] + async with aiohttp.ClientSession( + headers=get_user_agent() + ) as session: + async with session.get( + url, + timeout=7, + ) as response: + url = str(response.url).split("?")[0] + bvid = url.split("/")[-1] + vd_info = await video.get_video_base_info(bvid) if vd_info: if ( url in _tmp.keys() and time.time() - _tmp[url] > 30