Display caption (when doc sent with text) (#97)

This commit is contained in:
Nameless 2020-06-30 22:47:58 +08:00 committed by GitHub
parent 9c155811f5
commit 7ec5742a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -189,3 +189,10 @@ class MsgProxy:
@property
def forward(self) -> Optional[Dict[str, Any]]:
return self.msg.get("forward_info")
@property
def caption(self) -> Optional[str]:
caption = self.msg["content"].get("caption")
if not caption:
return None
return caption["text"]

View file

@ -344,6 +344,8 @@ class MsgView:
) -> str:
msg = self._parse_msg(msg_proxy)
msg = msg.replace("\n", " ")
if caption := msg_proxy.caption:
msg += "\n" + caption.replace("\n", " ")
msg += self._format_url(msg_proxy)
if reply_to := msg_proxy.reply_msg_id:
msg = self._format_reply_msg(