Commit 12730a5
committed
feat(telegram): inbound rich-message parsing (chat@4.31 4662309 — TG3/4)
Port the 4.31 inbound parse path for Bot API 10.1 rich messages.
parse_telegram_message:
- Render an inbound `rich_message` to markdown (rich_message_to_markdown)
and plain text (rich_message_to_text) via the TG2 renderer.
- Faithful ?/??/|| precedence:
- rich_markdown: presence (truthy) check on raw.rich_message
- plain_text: `?? raw.text ?? raw.caption ?? (rich ? richMessageToText : "")`
-- nullish chain ported as `is not None` (empty string short-circuits)
- text: `content?.text ? content.text : applyTelegramEntities(...)`
-- TRUTHY `?`, empty content.text falls through to entities
- formatted: `content?.formatted ?? toAst(richMarkdown || text)`
-- nullish for the supplied AST, TRUTHY-OR for richMarkdown || text
- New optional `content` arg (TelegramParsedContent) wires the outbound
pre-rendered AST/text reuse; inbound callers pass None.
extract_attachments:
- Append media extracted from rich_message via rich_message_media,
mapping each RichMedia onto Attachment (mimeType -> mime_type boundary),
appended after the top-level photo/video/audio/voice/document/video_note.
Tests (tests/test_telegram_webhook.py): inbound rich text+AST, caption
precedence, rich-markdown-driven formatted, nested collage media (photo
largest size, video name/mime), animation image-vs-video by mime,
voice_note -> audio, list-block recursion, append ordering.1 parent 01e5e6e commit 12730a5
2 files changed
Lines changed: 390 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
159 | 178 | | |
160 | 179 | | |
161 | 180 | | |
| |||
1975 | 1994 | | |
1976 | 1995 | | |
1977 | 1996 | | |
| 1997 | + | |
1978 | 1998 | | |
1979 | 1999 | | |
1980 | | - | |
1981 | | - | |
1982 | | - | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
1983 | 2028 | | |
1984 | 2029 | | |
1985 | 2030 | | |
| |||
2004 | 2049 | | |
2005 | 2050 | | |
2006 | 2051 | | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
2007 | 2060 | | |
2008 | 2061 | | |
2009 | 2062 | | |
2010 | 2063 | | |
2011 | | - | |
| 2064 | + | |
2012 | 2065 | | |
2013 | 2066 | | |
2014 | 2067 | | |
| |||
2104 | 2157 | | |
2105 | 2158 | | |
2106 | 2159 | | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
2107 | 2180 | | |
2108 | 2181 | | |
2109 | 2182 | | |
| |||
0 commit comments