Skip to content

Commit

Permalink
feat: support Media.name in telegram adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 authored Jun 24, 2024
1 parent 3231ab9 commit 8927389
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ async def media(self, seg: Union[Image, Voice, Video, Audio, File], bot: Bot) ->
}[name]
if seg.id or seg.url:
return method(seg.id or seg.url)
elif seg.path:
return method(Path(seg.path).read_bytes())
if seg.path:
raw = Path(seg.path).read_bytes()
elif seg.raw:
return method(seg.raw_bytes)
raw = seg.raw_bytes
else:
raise SerializeFailed(lang.require("nbp-uniseg", "invalid_segment").format(type=name, seg=seg))
return method((seg.name, raw) if seg.name else raw)

@export
async def reply(self, seg: Reply, bot: Bot) -> "MessageSegment":
Expand Down

0 comments on commit 8927389

Please sign in to comment.