Skip to content

Commit

Permalink
fix: 修复 telegram 适配
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Feb 29, 2024
1 parent 82ea0c0 commit 90a4a9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nonebot_plugin_chatrecorder/adapters/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def record_send_msg(
tg_message = type_validate_python(TGMessage, result)
chat = tg_message.chat
message_id = f"{chat.id}_{tg_message.message_id}"
message = type_validate_python(Message, result)
message = Message.model_validate(result)

elif api == "send_media_group":
tg_messages = [type_validate_python(TGMessage, res) for res in result]
Expand All @@ -89,7 +89,7 @@ async def record_send_msg(
message_id = f"{chat.id}_{message_id}"
message = Message()
for res in result:
message += type_validate_python(Message, res)
message += Message.model_validate(res)

else:
return
Expand Down
6 changes: 3 additions & 3 deletions tests/test_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
GroupMessageEvent,
PrivateMessageEvent,
)
from nonebot.adapters.telegram.model import InputMedia
from nonebot.adapters.telegram.model import InputMediaPhoto
from nonebug import App

from .utils import check_record
Expand Down Expand Up @@ -194,14 +194,14 @@ async def test_record_send_msg(app: App):
"chat_id": 3344,
"message_thread_id": None,
"media": [
InputMedia(
InputMediaPhoto(
type="photo",
media="attach://ac01.jpg",
caption=None,
parse_mode=None,
caption_entities=None,
),
InputMedia(
InputMediaPhoto(
type="photo",
media="attach://ac02.jpg",
caption=None,
Expand Down

0 comments on commit 90a4a9c

Please sign in to comment.