diff --git a/bot.py b/bot.py index c75c6f0..287bf2d 100644 --- a/bot.py +++ b/bot.py @@ -42,6 +42,7 @@ def main(): # nonebot.load_builtin_plugin("echo") nonebot.load_plugins("konabot/plugins") + nonebot.load_plugin("nonebot_plugin_analysis_bilibili") nonebot.run() diff --git a/konabot/plugins/bilibili_fetch_fix.py b/konabot/plugins/bilibili_fetch_fix.py new file mode 100644 index 0000000..527361b --- /dev/null +++ b/konabot/plugins/bilibili_fetch_fix.py @@ -0,0 +1,24 @@ +import re +from loguru import logger +from nonebot import on_message +from nonebot_plugin_alconna import 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小程序(?:&#93;|]|\])哔哩哔哩).{0,500}" +) + + +@matcher_fix.handle() +async def _(msg: UniMsg, event: Event): + if not re.search(pattern, msg.extract_plain_text()): + return + logger.info("检测到有 Bilibili 相关的消息,直接进行一个调用") + _module = __import__("nonebot_plugin_analysis_bilibili") + await _module.handle_analysis(event) + diff --git a/konabot/plugins/simple_notify/__init__.py b/konabot/plugins/simple_notify/__init__.py index 94215b2..3f0d964 100644 --- a/konabot/plugins/simple_notify/__init__.py +++ b/konabot/plugins/simple_notify/__init__.py @@ -187,7 +187,7 @@ async def _(msg: UniMsg, mEvt: Event): notify_time=target_time, notify_msg=notify_text, ) - task = create_notify_task(notify) + create_notify_task(notify) cfg.notifies.append(notify) save_notify_config(cfg) diff --git a/poetry.lock b/poetry.lock index 6439eb3..9b385b8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -748,6 +748,18 @@ all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (> standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[standard-no-fastapi-cloud-cli] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] +[[package]] +name = "filetype" +version = "1.2.0" +description = "Infer file type and MIME type of any file/buffer. No external dependencies." +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "filetype-1.2.0-py2.py3-none-any.whl", hash = "sha256:7ce71b6880181241cf7ac8697a2f1eb6a8bd9b429f7ad6d27b8db9ba5f1c2d25"}, + {file = "filetype-1.2.0.tar.gz", hash = "sha256:66b56cd6474bf41d8c54660347d37afcc3f7d1970648de365c102ef77548aadb"}, +] + [[package]] name = "frozenlist" version = "1.7.0" @@ -1630,6 +1642,23 @@ nonebot-plugin-waiter = ">=0.6.0" nonebot2 = ">=2.3.0" tarina = ">=0.6.8,<0.7" +[[package]] +name = "nonebot-plugin-analysis-bilibili" +version = "2.8.1" +description = "nonebot2解析bilibili插件" +optional = false +python-versions = "<4.0,>=3.8" +groups = ["main"] +files = [ + {file = "nonebot_plugin_analysis_bilibili-2.8.1-py3-none-any.whl", hash = "sha256:f882a0428ca87fc77a56fae6013607f6b286d8ae0ed46a1a87b4a1a6d3f4d011"}, + {file = "nonebot_plugin_analysis_bilibili-2.8.1.tar.gz", hash = "sha256:17c2c15a1783a2e1075638861384bd55b3fef09c0c7eb94857f811f60dbb446a"}, +] + +[package.dependencies] +aiohttp = ">=3.7,<4.0" +nonebot-plugin-send-anything-anywhere = ">=0,<1" +nonebot2 = ">=2.1.1,<3.0.0" + [[package]] name = "nonebot-plugin-apscheduler" version = "0.5.0" @@ -1647,6 +1676,25 @@ apscheduler = ">=3.7.0,<4.0.0" nonebot2 = ">=2.2.0,<3.0.0" pydantic = ">=1.10.0,<2.5.0 || >2.5.0,<2.5.1 || >2.5.1,<3.0.0" +[[package]] +name = "nonebot-plugin-send-anything-anywhere" +version = "0.7.1" +description = "An adaptor for nonebot2 adaptors" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "nonebot_plugin_send_anything_anywhere-0.7.1-py3-none-any.whl", hash = "sha256:b52044272be9a7bc77bd7a53ef700481c071fd4e889ae21a0411d0df22d13c16"}, + {file = "nonebot_plugin_send_anything_anywhere-0.7.1.tar.gz", hash = "sha256:ec9c7ba59c824238b812950146a894acc88ca8da98f500de15217feebcd5e868"}, +] + +[package.dependencies] +anyio = ">=3.3.0,<5.0.0" +filetype = ">=1.2.0,<2.0.0" +nonebot2 = ">=2.3.0,<3.0.0" +pydantic = ">=1.10.0,<2.5.0 || >2.5.0,<2.5.1 || >2.5.1,<3.0.0" +strenum = ">=0.4.8,<0.5.0" + [[package]] name = "nonebot-plugin-waiter" version = "0.8.1" @@ -2620,6 +2668,23 @@ typing-extensions = {version = ">=4.10.0", markers = "python_version < \"3.13\"" [package.extras] full = ["httpx (>=0.27.0,<0.29.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.18)", "pyyaml"] +[[package]] +name = "strenum" +version = "0.4.15" +description = "An Enum that inherits from str." +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "StrEnum-0.4.15-py3-none-any.whl", hash = "sha256:a30cda4af7cc6b5bf52c8055bc4bf4b2b6b14a93b574626da33df53cf7740659"}, + {file = "StrEnum-0.4.15.tar.gz", hash = "sha256:878fb5ab705442070e4dd1929bb5e2249511c0bcf2b0eeacf3bcd80875c82eff"}, +] + +[package.extras] +docs = ["myst-parser[linkify]", "sphinx", "sphinx-rtd-theme"] +release = ["twine"] +test = ["pylint", "pytest", "pytest-black", "pytest-cov", "pytest-pylint"] + [[package]] name = "tarina" version = "0.6.8" @@ -3260,4 +3325,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.12,<4.0" -content-hash = "0c7709438b8eb3d468b775417b8ef642cd7a8c1031805fdc71fec32c48346e54" +content-hash = "013942994a91012f285305194d73b6609fe71bbd214a63dce443877853dcd764" diff --git a/pyproject.toml b/pyproject.toml index 9785469..906e987 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dependencies = [ "returns (>=0.26.0,<0.27.0)", "ptimeparse (>=0.1.1,<0.2.0)", "skia-python (>=138.0,<139.0)", + "nonebot-plugin-analysis-bilibili (>=2.8.1,<3.0.0)", ] [build-system]