40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import re
|
|
|
|
from nonebot import on_message
|
|
from nonebot_plugin_alconna import Reference, Reply, UniMsg
|
|
|
|
from nonebot.adapters import Event
|
|
|
|
|
|
matcher_fix = on_message()
|
|
|
|
pattern = (
|
|
r"^(?:(?:av|cv)\d+|BV[a-zA-Z0-9]{10})|"
|
|
r"(?:b23\.tv|bili(?:22|23|33|2233)\.cn|\.bilibili\.com|QQ小程序(?:]|]|\])哔哩哔哩).{0,500}"
|
|
)
|
|
|
|
|
|
@matcher_fix.handle()
|
|
async def _(msg: UniMsg, event: Event):
|
|
to_search = msg.exclude(Reply, Reference).dump(json=True)
|
|
to_search2 = msg.exclude(Reply, Reference).extract_plain_text()
|
|
if not re.search(pattern, to_search) and not re.search(pattern, to_search2):
|
|
return
|
|
|
|
from nonebot_plugin_analysis_bilibili import handle_analysis
|
|
|
|
await handle_analysis(event)
|
|
|
|
# b_url: str
|
|
# b_page: str | None
|
|
# b_time: str | None
|
|
#
|
|
# from nonebot_plugin_analysis_bilibili.analysis_bilibili import extract as bilibili_extract
|
|
#
|
|
# b_url, b_page, b_time = bilibili_extract(to_search)
|
|
# if b_url is None:
|
|
# return
|
|
#
|
|
# await matcher_fix.send(await UniMessage().text(b_url).export())
|
|
|