Skip to content

Commit

Permalink
Remove nonebot plugin guild patch (#500)
Browse files Browse the repository at this point in the history
* remove: nonebot_plugin_guild_patch #499
  • Loading branch information
Quan666 authored May 10, 2024
1 parent 7ea332b commit c914ffc
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 103 deletions.
2 changes: 0 additions & 2 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ PORT=8080
DEBUG=false
# 配置 NoneBot 超级用户:管理员qq,支持多管理员,逗号分隔 注意,启动消息只发送给第一个管理员
SUPERUSERS=["123123123"]
# 配置 NoneBot 频道超级用户:管理员频道号,注意非qq号,可发送@后在gocq控制台获取
#GUILD_SUPERUSERS=["144115218677832239"]
# 配置机器人的昵称
NICKNAME=["elf","ELF"]
# 配置命令起始字符
Expand Down
1 change: 0 additions & 1 deletion docs/2.0 使用教程.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
> 4. 私聊直接发送命令即可,群聊和子频道需在消息首部或尾部添加 **机器人昵称** 或者 **@机器人**
> 5. 群聊中也可以回复机器人发的消息执行命令,子频道暂不支持
> 6. 所有参数之间均用空格分割,符号为英文标点
> 7. 子频道中需要手动添加管理员频道号到 `GUILD_SUPERUSERS`
## 添加订阅

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ELF_RSS"
version = "2.6.22"
version = "2.6.23"
description = "QQ机器人 RSS订阅 插件,订阅源建议选择 RSSHub"
authors = ["Quan666 <i@Rori.eMail>"]
license = "GPL-3.0-only"
Expand All @@ -26,7 +26,6 @@ ImageHash = "^4.3.1"
magneturi = "^1.3"
nonebot-adapter-onebot = "^2.4.3"
nonebot-plugin-apscheduler = "^0.4.0"
nonebot-plugin-guild-patch = "^0.2.3"
nonebot2 = {extras = ["fastapi"], version = "^2.3.0"}
pikpakapi = "^0.1.6"
Pillow = "^10.3.0"
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ magneturi~=1.3
nb-cli~=1.4.1
nonebot-adapter-onebot~=2.4.3
nonebot-plugin-apscheduler~=0.4.0
nonebot-plugin-guild-patch~=0.2.3
nonebot2[fastapi]~=2.3.0
pikpakapi~=0.1.6
Pillow~=10.3.0
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/ELF_RSS2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from nonebot.plugin import PluginMetadata

require("nonebot_plugin_apscheduler")
require("nonebot_plugin_guild_patch")

from . import command
from . import my_trigger as tr
Expand All @@ -15,7 +14,7 @@
from .rss_class import Rss
from .utils import send_message_to_admin

VERSION = "2.6.22"
VERSION = "2.6.23"

__plugin_meta__ = PluginMetadata(
name="ELF_RSS",
Expand Down
15 changes: 2 additions & 13 deletions src/plugins/ELF_RSS2/command/add_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,16 @@
from nonebot.params import ArgPlainText, CommandArg
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER, GuildMessageEvent

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

RSS_ADD = on_command(
"add",
aliases={"添加订阅", "sub"},
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down Expand Up @@ -78,11 +71,7 @@ async def add_feed(
rss.url = url
user = str(event.user_id) if isinstance(event, PrivateMessageEvent) else None
group = str(event.group_id) if isinstance(event, GroupMessageEvent) else None
guild_channel = (
f"{str(event.guild_id)}@{str(event.channel_id)}"
if isinstance(event, GuildMessageEvent)
else None
)
guild_channel = None
rss.add_user_or_group_or_channel(user, group, guild_channel)
await RSS_ADD.send(f"👏 已成功添加订阅 {name} !")
await tr.add_job(rss)
15 changes: 2 additions & 13 deletions src/plugins/ELF_RSS2/command/change_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
from nonebot.params import ArgPlainText, CommandArg
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER, GuildMessageEvent

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

Expand All @@ -24,12 +22,7 @@
aliases={"修改订阅", "modify"},
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down Expand Up @@ -248,11 +241,7 @@ async def handle_rss_change(
event: MessageEvent, change_info: str = ArgPlainText("RSS_CHANGE")
) -> None:
group_id = event.group_id if isinstance(event, GroupMessageEvent) else None
guild_channel_id = (
f"{event.guild_id}@{event.channel_id}"
if isinstance(event, GuildMessageEvent)
else None
)
guild_channel_id = None
name_list = change_info.split(" ")[0].split(",")
rss_list: List[Rss] = []
for name in name_list:
Expand Down
15 changes: 2 additions & 13 deletions src/plugins/ELF_RSS2/command/del_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@
from nonebot.params import ArgPlainText, CommandArg
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER, GuildMessageEvent

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

RSS_DELETE = on_command(
"deldy",
aliases={"drop", "unsub", "删除订阅"},
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down Expand Up @@ -76,11 +69,7 @@ async def handle_rss_delete(
event: MessageEvent, rss_name: str = ArgPlainText("RSS_DELETE")
) -> None:
group_id = event.group_id if isinstance(event, GroupMessageEvent) else None
guild_channel_id = (
f"{event.guild_id}@{event.channel_id}"
if isinstance(event, GuildMessageEvent)
else None
)
guild_channel_id = None

rss_name_list = rss_name.strip().split(" ")

Expand Down
9 changes: 1 addition & 8 deletions src/plugins/ELF_RSS2/command/rsshub_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot.typing import T_State
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER
from yarl import URL

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

Expand All @@ -24,12 +22,7 @@
"rsshub_add",
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down
15 changes: 2 additions & 13 deletions src/plugins/ELF_RSS2/command/show_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from nonebot.params import CommandArg
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER, GuildMessageEvent

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

Expand All @@ -24,12 +22,7 @@
aliases={"showall", "select_all", "selectall", "所有订阅"},
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down Expand Up @@ -75,11 +68,7 @@ async def handle_rss_show_all(
search_keyword = args.extract_plain_text().strip()

group_id = event.group_id if isinstance(event, GroupMessageEvent) else None
guild_channel_id = (
f"{event.guild_id}@{event.channel_id}"
if isinstance(event, GuildMessageEvent)
else None
)
guild_channel_id = None

if not (rss_list := get_rss_list(group_id, guild_channel_id)):
await RSS_SHOW_ALL.finish("❌ 当前没有任何订阅!")
Expand Down
15 changes: 2 additions & 13 deletions src/plugins/ELF_RSS2/command/show_dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
from nonebot.params import CommandArg
from nonebot.permission import SUPERUSER
from nonebot.rule import to_me
from nonebot_plugin_guild_patch import GUILD_ADMIN, GUILD_OWNER, GuildMessageEvent

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

RSS_SHOW = on_command(
"show",
aliases={"查看订阅"},
rule=to_me(),
priority=5,
permission=GROUP_ADMIN
| GROUP_OWNER
| GUILD_ADMIN
| GUILD_OWNER
| GUILD_SUPERUSER
| SUPERUSER,
permission=GROUP_ADMIN | GROUP_OWNER | SUPERUSER,
)


Expand Down Expand Up @@ -55,11 +48,7 @@ async def handle_rss_show(event: MessageEvent, args: Message = CommandArg()) ->

user_id = event.get_user_id()
group_id = event.group_id if isinstance(event, GroupMessageEvent) else None
guild_channel_id = (
f"{event.guild_id}@{event.channel_id}"
if isinstance(event, GuildMessageEvent)
else None
)
guild_channel_id = None

if rss_name:
rss_msg = await show_rss_by_name(rss_name, group_id, guild_channel_id)
Expand Down
22 changes: 0 additions & 22 deletions src/plugins/ELF_RSS2/permission.py

This file was deleted.

0 comments on commit c914ffc

Please sign in to comment.