Skip to content

Commit a94897f

Browse files
committed
🔥 block event is useless
1 parent 8c5b164 commit a94897f

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
[NoneBot2](https://github.com/nonebot/nonebot2) 成为 OneBot 实现!
77

88
[![License](https://img.shields.io/github/license/nonepkg/nonebot-plugin-all4one?style=flat-square)](LICENSE)
9+
[![codecov](https://codecov.io/gh/nonepkg/plugin-all4one/branch/master/graph/badge.svg?token=BOK429DAHO)](https://codecov.io/gh/nonepkg/plugin-all4one)
10+
[![pdm-managed](https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json)](https://pdm-project.org)
911
![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg?style=flat-square)
10-
[![NoneBot Version](https://img.shields.io/badge/nonebot-2.3.0+-red.svg?style=flat-square)](https://v2.nonebot.dev/)
11-
[![OneBot 4A](https://img.shields.io/badge/OneBot-4A-black?style=flat-square)](https://onebot4all.vercel.app/)
12+
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
1213
[![PyPI Version](https://img.shields.io/pypi/v/nonebot-plugin-all4one.svg?style=flat-square)](https://pypi.python.org/pypi/nonebot-plugin-all4one)
13-
[![codecov](https://codecov.io/gh/nonepkg/plugin-all4one/branch/master/graph/badge.svg?token=BOK429DAHO)](https://codecov.io/gh/nonepkg/plugin-all4one)
14+
[![OneBot 4A](https://img.shields.io/badge/OneBot-4A-black?style=flat-square)](https://onebot4all.vercel.app/)
15+
[![NoneBot Version](https://img.shields.io/badge/nonebot-2.3.0+-red.svg?style=flat-square)](https://v2.nonebot.dev/)
16+
[![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-all4one)](https://registry.nonebot.dev/plugin/nonebot-plugin-all4one:nonebot_plugin_all4one)
17+
[![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-all4one)](https://registry.nonebot.dev/plugin/nonebot-plugin-all4one:nonebot_plugin_all4one)
1418

1519
</div>
1620

@@ -33,8 +37,6 @@ pdm add nonebot-plugin-all4one
3337
```dotenv
3438
obimpl_connections = [{"type":"websocket_rev","url":"ws://127.0.0.1:8080/onebot/v12/"}] # 其它连接方式的配置同理
3539
middlewares = ["OneBot V11"] # 自定义加载的 Middleware,默认加载全部
36-
block_event = False # 是否中止已转发 Event 的处理流程,默认中止
37-
blocked_plugins = ["echo"] # 在 block_event=False 时生效,可自定义处理流程中要中止的插件
3840
```
3941

4042
## Feature
@@ -49,12 +51,14 @@ blocked_plugins = ["echo"] # 在 block_event=False 时生效,可自定义处
4951
### Middlewares
5052

5153
- [x] [OneBot V11](https://github.com/nonebot/adapter-onebot)
52-
- [x] [Telegram](http://github.com/nonebot/adapter-telegram)
54+
- [x] [Telegram](https://github.com/nonebot/adapter-telegram)
55+
- [x] [Discord](https://github.com/nonebot/adapter-discord) 测试中
5356
- [ ] [QQ](https://github.com/nonebot/adapter-qq) [@he0119](https://github.com/he0119) 寻求新维护者
5457

5558
## 相关链接
5659

57-
- [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) 复用代码
60+
- [nonebot/adapter-onebot](https://github.com/nonebot/adapter-onebot) 复用代码
5861
- [zhamao-robot/go-cqhttp-adapter-plugin](https://github.com/zhamao-robot/go-cqhttp-adapter-plugin) OneBot V11 -> V12 逻辑参考
59-
- [nonebot-plugin-params](https://github.com/iyume/nonebot-plugin-params) 灵感来源
62+
- [iyume/nonebot-plugin-params](https://github.com/iyume/nonebot-plugin-params) 灵感来源
6063
- [felinae98/nonebot-plugin-send-anything-anywhere](https://github.com/felinae98/nonebot-plugin-send-anything-anywhere) 友情推荐
64+
- [nonebot/plugin-alconna](https://github.com/nonebot/plugin-alconna) 同上

docker/.env

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ DRIVER=~fastapi+~aiohttp
44
OBIMPL_CONNECTIONS=[{"type":"websocket_rev","url":"ws://127.0.0.1:8080/onebot/v12/"}]
55
# 自定义加载的 Middleware,默认加载全部
66
MIDDLEWARES
7-
# 是否中止已转发 Event 的处理流程,默认中止
8-
BLOCK_EVENT=True
9-
# 在 block_event=False 时生效,可自定义处理流程中要中止的插件
10-
BLOCKED_PLUGINS=[]
117

128
# QQ 频道
139
# https://github.com/nonebot/adapter-qqguild

nonebot_plugin_all4one/__init__.py

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
from copy import deepcopy
22

3-
from nonebot.matcher import Matcher
43
from nonebot.adapters import Bot, Event
54
from nonebot.plugin import PluginMetadata
65
from nonebot import on, require, get_driver
7-
from nonebot.exception import IgnoredException
8-
from nonebot.message import run_preprocessor, event_preprocessor
6+
from nonebot.message import event_preprocessor
97

108
require("nonebot_plugin_localstore")
119
require("nonebot_plugin_orm")
1210

13-
from .config import Config
14-
from .onebotimpl import OneBotImplementation
11+
from .onebotimpl import Config, OneBotImplementation
1512

1613
__plugin_meta__ = PluginMetadata(
1714
name="OneBot 实现",
1815
description="让 NoneBot2 成为 OneBot 实现!",
19-
usage="""obimpl_connections = [{"type":"websocket_rev","url":"ws://127.0.0.1:8080/onebot/v12/"}] # 其它连接方式的配置同理
20-
middlewares = ["OneBot V11"] # 自定义加载的 Middleware,默认加载全部
21-
block_event = False # 是否中止已转发 Event 的处理流程,默认中止
22-
blocked_plugins = ["echo"] # 在 block_event=False 时生效,可自定义处理流程中要中止的插件""",
16+
usage="""
17+
obimpl_connections = [{"type":"websocket_rev","url":"ws://127.0.0.1:8080/onebot/v12/"}]
18+
# 其它连接方式的配置同理
19+
middlewares = ["OneBot V11"]
20+
# 自定义加载的 Middleware,默认加载全部
21+
""",
2322
type="application",
2423
homepage="https://github.com/nonepkg/nonebot-plugin-all4one",
2524
config=Config,
26-
supported_adapters={"~onebot.v11", "~telegram"},
25+
supported_adapters={"~onebot.v11", "~telegram", "~discord"},
2726
)
2827

2928
driver = get_driver()
30-
a4o_config = Config(**driver.config.model_dump())
3129
obimpl = OneBotImplementation(driver)
3230

3331
on(priority=1, block=False)
@@ -42,18 +40,3 @@ async def _(bot: Bot, event: Event):
4240
await queue.get()
4341
event = deepcopy(event)
4442
await queue.put(deepcopy(event))
45-
if a4o_config.block_event:
46-
raise IgnoredException("All4One has transfer it to OneBot V12")
47-
48-
49-
if not a4o_config.block_event and a4o_config.blocked_plugins:
50-
51-
@run_preprocessor
52-
async def _(bot: Bot, matcher: Matcher):
53-
if (
54-
bot.type in obimpl._middlewares
55-
and matcher.plugin_name
56-
and a4o_config.blocked_plugins
57-
and matcher.plugin_name in a4o_config.blocked_plugins
58-
):
59-
raise IgnoredException("All4One has blocked it")

nonebot_plugin_all4one/config.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)