mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-06-06 12:26:38 +00:00
🐛 Fix Message._construct
error
This commit is contained in:
parent
afd01796aa
commit
be244f4538
@ -45,8 +45,8 @@ class MessageSegment(BaseMessageSegment):
|
|||||||
self.data["at"]["isAtAll"] = value
|
self.data["at"]["isAtAll"] = value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def text(text: str) -> "MessageSegment":
|
def text(text_: str) -> "MessageSegment":
|
||||||
return MessageSegment("text", {"text": {"content": text.strip()}})
|
return MessageSegment("text", {"text": {"content": text_.strip()}})
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def markdown(title: str, text: str) -> "MessageSegment":
|
def markdown(title: str, text: str) -> "MessageSegment":
|
||||||
@ -130,4 +130,4 @@ class Message(BaseMessage):
|
|||||||
elif isinstance(msg, TextMessage):
|
elif isinstance(msg, TextMessage):
|
||||||
yield MessageSegment("text", {"text": msg.dict()})
|
yield MessageSegment("text", {"text": msg.dict()})
|
||||||
elif isinstance(msg, str):
|
elif isinstance(msg, str):
|
||||||
yield MessageSegment.text(str)
|
yield MessageSegment.text(msg)
|
||||||
|
@ -2,6 +2,7 @@ from nonebot.rule import to_me
|
|||||||
from nonebot.typing import Event
|
from nonebot.typing import Event
|
||||||
from nonebot.plugin import on_startswith
|
from nonebot.plugin import on_startswith
|
||||||
from nonebot.adapters.cqhttp import Bot
|
from nonebot.adapters.cqhttp import Bot
|
||||||
|
from nonebot.adapters.ding import Bot as DingBot, Event as DingEvent
|
||||||
from nonebot.permission import GROUP_ADMIN
|
from nonebot.permission import GROUP_ADMIN
|
||||||
|
|
||||||
test_command = on_startswith("hello", to_me(), permission=GROUP_ADMIN)
|
test_command = on_startswith("hello", to_me(), permission=GROUP_ADMIN)
|
||||||
@ -9,4 +10,9 @@ test_command = on_startswith("hello", to_me(), permission=GROUP_ADMIN)
|
|||||||
|
|
||||||
@test_command.handle()
|
@test_command.handle()
|
||||||
async def test_handler(bot: Bot, event: Event, state: dict):
|
async def test_handler(bot: Bot, event: Event, state: dict):
|
||||||
await test_command.finish("hello")
|
await test_command.finish("cqhttp hello")
|
||||||
|
|
||||||
|
|
||||||
|
@test_command.handle()
|
||||||
|
async def test_handler(bot: DingBot, event: DingEvent, state: dict):
|
||||||
|
await test_command.finish("ding hello")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user