Skip to content

Commit

Permalink
v2.6.16 (#409)
Browse files Browse the repository at this point in the history
* chore: 引入格式化工具配置和代码检查工具配置

* fix: 修正 `nonebot_plugin_guild_patch` 的导入时机

* refactor(routes): 使用自动扫描的方式自动导入路由规则

* fix: 修正一些代码检查问题

* chore(release): v2.6.16
  • Loading branch information
NekoAria authored Mar 22, 2023
1 parent 9039520 commit 2b4384b
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"dependencyDashboard": false,
"rangeStrategy": "bump",
"enabledManagers": [
"github-actions",
"pip_requirements",
"poetry",
"github-actions"
"pre-commit"
],
"packageRules": [
{
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
minimum_pre_commit_version: "3.2.0"
files: ^.*\.py$
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.257'
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ELF_RSS"
version = "2.6.15"
version = "2.6.16"
description = "QQ机器人 RSS订阅 插件,订阅源建议选择 RSSHub"
authors = ["Quan666 <[email protected]>"]
license = "GPL-3.0-only"
Expand Down Expand Up @@ -42,12 +42,24 @@ nb-cli = "^1.0.5"

[tool.mypy]
python_version = "3.8"
plugins = [
"pydantic.mypy"
]
ignore_missing_imports = true
implicit_reexport = true
pretty = true
show_error_codes = true
strict = true

[tool.ruff]
select = ["F", "E", "W", "I"]
target-version = "py38"
line-length = 120

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"*.py" = ["E402", "F811"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion src/plugins/ELF_RSS2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require("nonebot_plugin_apscheduler")
from nonebot_plugin_apscheduler import scheduler # noqa

VERSION = "2.6.15"
VERSION = "2.6.16"

__plugin_meta__ = PluginMetadata(
name="ELF_RSS",
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/ELF_RSS2/command/add_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me

require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from .. import my_trigger as tr
from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss

require("nonebot_plugin_guild_patch")
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

RSS_ADD = on_command(
"add",
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ELF_RSS2/command/change_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me

require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from .. import my_trigger as tr
from ..config import DATA_PATH
from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss
from ..utils import regex_validate

require("nonebot_plugin_guild_patch")
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

RSS_CHANGE = on_command(
"change",
aliases={"修改订阅", "modify"},
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ELF_RSS2/command/del_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me

require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from .. import my_trigger as tr
from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss

require("nonebot_plugin_guild_patch")
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

RSS_DELETE = on_command(
"deldy",
aliases={"drop", "unsub", "删除订阅"},
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/ELF_RSS2/command/rsshub_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from nonebot.typing import T_State
from yarl import URL

require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from ..config import config
from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss
from .add_dy import add_feed

require("nonebot_plugin_guild_patch")
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

rsshub_routes: Dict[str, Any] = {}


Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ELF_RSS2/command/show_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me

require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss
from .show_dy import handle_rss_list

require("nonebot_plugin_guild_patch")
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

RSS_SHOW_ALL = on_command(
"show_all",
aliases={"showall", "select_all", "selectall", "所有订阅"},
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ELF_RSS2/command/show_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me

from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss

require("nonebot_plugin_guild_patch")
require("nonebot_plugin_guild_patch") # noqa
from nonebot_plugin_guild_patch import GuildMessageEvent # noqa
from nonebot_plugin_guild_patch.permission import GUILD_ADMIN, GUILD_OWNER # noqa

from ..permission import GUILD_SUPERUSER
from ..rss_class import Rss

RSS_SHOW = on_command(
"show",
aliases={"查看订阅"},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ELF_RSS2/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .handle_images import handle_img
from .handle_translation import handle_translation
from .parsing_rss import ParsingBase
from .routes import *
from .routes import ALL_MODULES
from .send_message import handle_send_msgs
from .utils import get_proxy, get_summary

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/ELF_RSS2/parsing/handle_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def file_name_format(file_url: URL, rss: Rss) -> Tuple[Path, str]:
"""
可以根据用户设置的规则来格式化文件名
"""
format_rule = config.img_format
down_path = config.img_down_path
format_rule = config.img_format or ""
down_path = config.img_down_path or ""
rules = { # 替换格式化字符串
"{subs}": rss.name,
"{name}": file_url.name
Expand Down
23 changes: 12 additions & 11 deletions src/plugins/ELF_RSS2/parsing/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from . import (
bilibili,
danbooru,
nga,
pixiv,
south_plus,
twitter,
weibo,
yande_re,
youtube,
)
from typing import List


def __list_all_modules() -> List[str]:
from pathlib import Path

module_paths = list(Path(__file__).parent.glob("*.py"))
return [module.name[:-3] for module in module_paths if module.name != "__init__.py"]


ALL_MODULES = sorted(__list_all_modules())
__all__ = ALL_MODULES + ["ALL_MODULES"]
6 changes: 5 additions & 1 deletion src/plugins/ELF_RSS2/rss_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
"Accept": "application/xhtml+xml,application/xml,*/*",
"Accept-Language": "en-US,en;q=0.9",
"Cache-Control": "max-age=0",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/111.0.0.0 Safari/537.36"
),
"Connection": "keep-alive",
"Content-Type": "application/xml; charset=utf-8",
}
Expand Down

0 comments on commit 2b4384b

Please sign in to comment.