Skip to content

Commit 465c794

Browse files
committed
🐛 Middleware(OneBot V12): fix get_supported_actions
1 parent 53337e0 commit 465c794

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

nonebot_plugin_all4one/middlewares/onebot/v12.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ async def send_message(
9595

9696
async def get_supported_actions(self, **kwargs: Any) -> List[str]:
9797
_ = set()
98-
_.update(self.supported_actions)
98+
_.update(self._supported_actions)
9999
_.update(await self.bot.get_supported_actions(**kwargs))
100100
return list(_)
101101

102102
async def _call_api(self, api: str, **kwargs: Any) -> Any:
103-
if api in self.supported_actions:
103+
if api in self._supported_actions:
104104
return await getattr(self, api)(**kwargs)
105105
return await self.bot.call_api(api, **kwargs)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from nonebug import App
2+
from nonebot.adapters.onebot.v12 import Bot
3+
4+
5+
async def test_get_supported_action(app: App):
6+
from nonebot_plugin_all4one.middlewares.onebot.v12 import Middleware
7+
8+
async with app.test_api() as ctx:
9+
bot = ctx.create_bot(base=Bot, impl="test", platform="test")
10+
middleware = Middleware(bot)
11+
ctx.should_call_api("get_supported_actions", {}, [])
12+
supported_actions = await middleware.get_supported_actions()
13+
assert set(supported_actions) == {
14+
"upload_file",
15+
"get_file",
16+
"get_supported_actions",
17+
"send_message",
18+
}

0 commit comments

Comments
 (0)