mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
View animated stickers thumbnail (#106)
* Draft: adding lock to message update and using indexes for msgs * Fix black formatting * Rename msg_ids->msg_idx to better represent what variable contains * Fix black formatting * Check if msg_id in not_found * Use lock in udpate_handler * Add shortcut to jump to replied msg * Open preview for animated sticker and show it's emoji * Remove lock * Show if sticker is animated
This commit is contained in:
parent
2a0c726792
commit
4460c5f94b
2 changed files with 16 additions and 3 deletions
16
tg/msg.py
16
tg/msg.py
|
@ -17,7 +17,7 @@ class MsgProxy:
|
|||
"messageAudio": ("audio", "audio"),
|
||||
"messageVideo": ("video", "video"),
|
||||
"messageVideoNote": ("video_note", "video"),
|
||||
"messageSticker": ("sticker", "sticker"),
|
||||
"messageSticker": ("sticker", "thumbnail", "photo"),
|
||||
}
|
||||
|
||||
types = {
|
||||
|
@ -114,7 +114,7 @@ class MsgProxy:
|
|||
|
||||
@property
|
||||
def local_path(self) -> Optional[str]:
|
||||
if self.msg["content"]["@type"] is None:
|
||||
if self.content_type is None:
|
||||
return None
|
||||
doc = self.get_doc(self.msg)
|
||||
return doc["local"]["path"]
|
||||
|
@ -196,3 +196,15 @@ class MsgProxy:
|
|||
if not caption:
|
||||
return None
|
||||
return caption["text"]
|
||||
|
||||
@property
|
||||
def sticker_emoji(self) -> Optional[str]:
|
||||
if self.content_type != "sticker":
|
||||
return None
|
||||
return self.msg["content"].get("sticker", {}).get("emoji")
|
||||
|
||||
@property
|
||||
def is_animated(self) -> bool:
|
||||
if self.content_type != "sticker":
|
||||
return False
|
||||
return self.msg["content"].get("sticker", {}).get("is_animated")
|
||||
|
|
|
@ -111,7 +111,6 @@ class StatusView:
|
|||
|
||||
buff = ""
|
||||
while True:
|
||||
log.info("here:")
|
||||
key = self.win.get_wch(0, min(len(buff) + len(msg), self.w - 1))
|
||||
key = ord(key)
|
||||
if key == 10: # return
|
||||
|
@ -592,6 +591,8 @@ def parse_content(content: Dict[str, Any]) -> str:
|
|||
duration=msg.duration,
|
||||
listened=format_bool(msg.is_listened),
|
||||
viewed=format_bool(msg.is_viewed),
|
||||
animated=msg.is_animated,
|
||||
emoji=msg.sticker_emoji,
|
||||
)
|
||||
info = ", ".join(f"{k}={v}" for k, v in fields.items() if v)
|
||||
|
||||
|
|
Loading…
Reference in a new issue