Skip to content

Commit

Permalink
Add Message.file_id
Browse files Browse the repository at this point in the history
  • Loading branch information
z44d committed Oct 14, 2024
1 parent cfa3172 commit d35900d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tgram/bound/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,20 @@ def link(self: "tgram.types.Message") -> Optional[str]:
else None
)

@property
def file_id(self: "tgram.types.Message") -> str:
media = self.media

if media is None:
raise ValueError("This message has no media.")

m = getattr(self, media)

if isinstance(m, list):
return getattr(m[-1], "file_id")
else:
return getattr(m, "file_id")

@property
def user(self: "tgram.types.Message") -> Optional["tgram.types.User"]:
return self.from_user
Expand Down

0 comments on commit d35900d

Please sign in to comment.