richpyro 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
richpyro-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 devgagan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include src/richpyro py.typed
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: richpyro
3
+ Version: 1.0.0
4
+ Summary: A complete, easy-to-call wrapper for Pyrogram Rich Messages (Bot API 10.1+) — every block, every text style, every button type, with bot/user-account fallback and chat_id safety built in.
5
+ Author: devgagan
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/devgaganin/richpyro
8
+ Project-URL: Repository, https://github.com/devgaganin/richpyro
9
+ Project-URL: Issues, https://github.com/devgaganin/richpyro/issues
10
+ Keywords: telegram,pyrogram,kurigram,telegram-bot,bot-api,rich-message,rich-messages,telegram-api
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Communications :: Chat
21
+ Classifier: Topic :: Internet
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: Kurigram>=2.2.26
28
+ Dynamic: license-file
29
+
30
+ # richpyro
31
+
32
+ A complete, easy-to-call wrapper around [kurigram](https://github.com/kurimuzon/kurigram)'s
33
+ **Rich Messages** (Telegram Bot API 10.1+ `InputRichMessage` / `InputRichBlock*` /
34
+ `RichText*`, plus `Client.send_rich_message`, `Message.edit_text(rich_message=...)`
35
+ and `Message.reply_rich`).
36
+
37
+ Every block type, every text style, every button type — one flat, documented
38
+ function per thing, plus a safe `send()` / `edit()` / `reply()` call surface
39
+ that handles two real Telegram/kurigram footguns automatically so you never
40
+ have to think about them.
41
+
42
+ ```bash
43
+ pip install richpyro
44
+ ```
45
+
46
+ ## Why
47
+
48
+ Rich Messages are powerful but the raw API is deep (~50 constructor types)
49
+ and has two sharp edges that fail silently in production:
50
+
51
+ 1. **Rich Messages only render for bot accounts.** Send `rich_message=...`
52
+ from a real user/userbot client (a logged-in session, not a bot token)
53
+ and Telegram silently drops or rejects it — no visible error, your
54
+ progress bar / status card just stops updating.
55
+ 2. **A numeric-string `chat_id` looks like a phone number to kurigram.**
56
+ `Client.resolve_peer()` strips `+()-` and whitespace from any string
57
+ `chat_id`; if what's left is all digits, it assumes it's a phone number
58
+ and calls `contacts.ResolvePhone` — a method **bot accounts cannot call
59
+ at all** (`[400 BOT_METHOD_INVALID]`), and which fails with
60
+ `PHONE_NOT_OCCUPIED` for user accounts too unless that string happens to
61
+ be someone's real registered phone number. This bites silently any time
62
+ a chat id is passed as `str(chat.id)` instead of `int` — an extremely
63
+ easy mistake, since chat ids get stringified for DB keys/dict lookups
64
+ all over a typical bot codebase and then get reused as-is for an API call.
65
+
66
+ `richpyro.send()` / `.edit()` / `.reply()` check `client.me.is_bot` and
67
+ auto-degrade to an equivalent plain-text message for user-account senders,
68
+ and auto-int-ify any numeric-string `chat_id` before it reaches kurigram
69
+ (`@usernames` pass through untouched). You get both fixes for free just by
70
+ using this library's call surface instead of the raw kurigram methods.
71
+
72
+ ## Quick start
73
+
74
+ ```python
75
+ import richpyro as rp
76
+
77
+ # simplest possible call — one line, works from a bot OR a user client:
78
+ await rp.quick(client, chat_id, "Processing your request...")
79
+
80
+ # a structured card with formatting + buttons:
81
+ card = rp.message(
82
+ rp.para("Hello ", rp.bold(name), "! Choose a plan:"),
83
+ rp.divider(),
84
+ rp.para("● ", rp.bold("Day Plan"), " — ₹20 (24 hours)"),
85
+ rp.buttons(
86
+ rp.btn("Day Plan ₹20", "pay_day"),
87
+ rp.url_btn("Learn more", "https://example.com"),
88
+ ),
89
+ )
90
+ sent = await rp.send(client, chat_id, card)
91
+ ...
92
+ await rp.edit(client, chat_id, sent.id, rp.text("Payment confirmed."))
93
+
94
+ # replying directly to an incoming message (uses its own client):
95
+ await rp.reply(message, card)
96
+ ```
97
+
98
+ Every builder returns a plain kurigram object — you can always drop down to
99
+ raw `types.InputRichMessage(...)` etc. for anything this library doesn't
100
+ wrap yet. richpyro objects and raw kurigram objects mix freely; nothing here
101
+ subclasses kurigram, it only constructs.
102
+
103
+ ## What's covered
104
+
105
+ **Text formatting** — `bold`, `italic`, `underline`, `strike`, `spoiler`,
106
+ `code`, `link`, `user_mention`, `mention`, `custom_emoji`, `hashtag`,
107
+ `bot_command`, `phone_number`, `email`, `cashtag`, `bank_card`, `date_time`,
108
+ `subscript`, `superscript`, `anchor_target`, `anchor_link`, `footnote_ref`,
109
+ `footnote_link`, `marked`, `math_inline`, `inline_button`.
110
+
111
+ **Buttons** — `btn` (callback), `url_btn`, `webapp_btn`, `login_btn`,
112
+ `switch_inline_btn`, `switch_inline_here_btn`, `switch_inline_chosen_btn`,
113
+ `copy_btn`, `disabled_btn`, plus `buttons(...)` to lay out a row and
114
+ `Style` (`DEFAULT` / `PRIMARY` / `DANGER` / `SUCCESS` / `LINK`).
115
+
116
+ **Blocks** — `para`, `heading`, `divider`, `footer`, `anchor_block`,
117
+ `photo_block`, `video_block`, `animation_block`, `audio_block`,
118
+ `document_block`, `voice_block` (with matching `*_media` input helpers and
119
+ `caption(...)`), `collage`, `slideshow`, `list_item` / `bullet_list`,
120
+ `table_cell` / `table`, `details`, `blockquote`, `expandable_quote`,
121
+ `pull_quote`, `preformatted`, `map_block`, `math_block`, `thinking`.
122
+
123
+ **Message assembly** — `message(*blocks)` (the main entry point),
124
+ `html_message`, `markdown_message`, `text(...)` (the single-line shortcut
125
+ for the common case).
126
+
127
+ **Safe send surface** — `send`, `edit`, `reply`, `quick`, `quick_edit`,
128
+ `is_bot_client`, and `flatten_message` (the plain-text renderer used
129
+ automatically for the bot → user-account fallback, also handy standalone
130
+ for logs/previews).
131
+
132
+ ## Requirements
133
+
134
+ - Python 3.9+
135
+ - [Kurigram](https://pypi.org/project/Kurigram/) 2.2.26+ (the actively
136
+ maintained Pyrogram fork with Rich Messages support — still `import pyrogram`)
137
+
138
+ ## License
139
+
140
+ MIT — see [LICENSE](LICENSE).
141
+
142
+ ## Author
143
+
144
+ coded by **devgagan** — [github.com/devgaganin](https://github.com/devgaganin)
@@ -0,0 +1,115 @@
1
+ # richpyro
2
+
3
+ A complete, easy-to-call wrapper around [kurigram](https://github.com/kurimuzon/kurigram)'s
4
+ **Rich Messages** (Telegram Bot API 10.1+ `InputRichMessage` / `InputRichBlock*` /
5
+ `RichText*`, plus `Client.send_rich_message`, `Message.edit_text(rich_message=...)`
6
+ and `Message.reply_rich`).
7
+
8
+ Every block type, every text style, every button type — one flat, documented
9
+ function per thing, plus a safe `send()` / `edit()` / `reply()` call surface
10
+ that handles two real Telegram/kurigram footguns automatically so you never
11
+ have to think about them.
12
+
13
+ ```bash
14
+ pip install richpyro
15
+ ```
16
+
17
+ ## Why
18
+
19
+ Rich Messages are powerful but the raw API is deep (~50 constructor types)
20
+ and has two sharp edges that fail silently in production:
21
+
22
+ 1. **Rich Messages only render for bot accounts.** Send `rich_message=...`
23
+ from a real user/userbot client (a logged-in session, not a bot token)
24
+ and Telegram silently drops or rejects it — no visible error, your
25
+ progress bar / status card just stops updating.
26
+ 2. **A numeric-string `chat_id` looks like a phone number to kurigram.**
27
+ `Client.resolve_peer()` strips `+()-` and whitespace from any string
28
+ `chat_id`; if what's left is all digits, it assumes it's a phone number
29
+ and calls `contacts.ResolvePhone` — a method **bot accounts cannot call
30
+ at all** (`[400 BOT_METHOD_INVALID]`), and which fails with
31
+ `PHONE_NOT_OCCUPIED` for user accounts too unless that string happens to
32
+ be someone's real registered phone number. This bites silently any time
33
+ a chat id is passed as `str(chat.id)` instead of `int` — an extremely
34
+ easy mistake, since chat ids get stringified for DB keys/dict lookups
35
+ all over a typical bot codebase and then get reused as-is for an API call.
36
+
37
+ `richpyro.send()` / `.edit()` / `.reply()` check `client.me.is_bot` and
38
+ auto-degrade to an equivalent plain-text message for user-account senders,
39
+ and auto-int-ify any numeric-string `chat_id` before it reaches kurigram
40
+ (`@usernames` pass through untouched). You get both fixes for free just by
41
+ using this library's call surface instead of the raw kurigram methods.
42
+
43
+ ## Quick start
44
+
45
+ ```python
46
+ import richpyro as rp
47
+
48
+ # simplest possible call — one line, works from a bot OR a user client:
49
+ await rp.quick(client, chat_id, "Processing your request...")
50
+
51
+ # a structured card with formatting + buttons:
52
+ card = rp.message(
53
+ rp.para("Hello ", rp.bold(name), "! Choose a plan:"),
54
+ rp.divider(),
55
+ rp.para("● ", rp.bold("Day Plan"), " — ₹20 (24 hours)"),
56
+ rp.buttons(
57
+ rp.btn("Day Plan ₹20", "pay_day"),
58
+ rp.url_btn("Learn more", "https://example.com"),
59
+ ),
60
+ )
61
+ sent = await rp.send(client, chat_id, card)
62
+ ...
63
+ await rp.edit(client, chat_id, sent.id, rp.text("Payment confirmed."))
64
+
65
+ # replying directly to an incoming message (uses its own client):
66
+ await rp.reply(message, card)
67
+ ```
68
+
69
+ Every builder returns a plain kurigram object — you can always drop down to
70
+ raw `types.InputRichMessage(...)` etc. for anything this library doesn't
71
+ wrap yet. richpyro objects and raw kurigram objects mix freely; nothing here
72
+ subclasses kurigram, it only constructs.
73
+
74
+ ## What's covered
75
+
76
+ **Text formatting** — `bold`, `italic`, `underline`, `strike`, `spoiler`,
77
+ `code`, `link`, `user_mention`, `mention`, `custom_emoji`, `hashtag`,
78
+ `bot_command`, `phone_number`, `email`, `cashtag`, `bank_card`, `date_time`,
79
+ `subscript`, `superscript`, `anchor_target`, `anchor_link`, `footnote_ref`,
80
+ `footnote_link`, `marked`, `math_inline`, `inline_button`.
81
+
82
+ **Buttons** — `btn` (callback), `url_btn`, `webapp_btn`, `login_btn`,
83
+ `switch_inline_btn`, `switch_inline_here_btn`, `switch_inline_chosen_btn`,
84
+ `copy_btn`, `disabled_btn`, plus `buttons(...)` to lay out a row and
85
+ `Style` (`DEFAULT` / `PRIMARY` / `DANGER` / `SUCCESS` / `LINK`).
86
+
87
+ **Blocks** — `para`, `heading`, `divider`, `footer`, `anchor_block`,
88
+ `photo_block`, `video_block`, `animation_block`, `audio_block`,
89
+ `document_block`, `voice_block` (with matching `*_media` input helpers and
90
+ `caption(...)`), `collage`, `slideshow`, `list_item` / `bullet_list`,
91
+ `table_cell` / `table`, `details`, `blockquote`, `expandable_quote`,
92
+ `pull_quote`, `preformatted`, `map_block`, `math_block`, `thinking`.
93
+
94
+ **Message assembly** — `message(*blocks)` (the main entry point),
95
+ `html_message`, `markdown_message`, `text(...)` (the single-line shortcut
96
+ for the common case).
97
+
98
+ **Safe send surface** — `send`, `edit`, `reply`, `quick`, `quick_edit`,
99
+ `is_bot_client`, and `flatten_message` (the plain-text renderer used
100
+ automatically for the bot → user-account fallback, also handy standalone
101
+ for logs/previews).
102
+
103
+ ## Requirements
104
+
105
+ - Python 3.9+
106
+ - [Kurigram](https://pypi.org/project/Kurigram/) 2.2.26+ (the actively
107
+ maintained Pyrogram fork with Rich Messages support — still `import pyrogram`)
108
+
109
+ ## License
110
+
111
+ MIT — see [LICENSE](LICENSE).
112
+
113
+ ## Author
114
+
115
+ coded by **devgagan** — [github.com/devgaganin](https://github.com/devgaganin)
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "richpyro"
7
+ version = "1.0.0"
8
+ description = "A complete, easy-to-call wrapper for Pyrogram Rich Messages (Bot API 10.1+) — every block, every text style, every button type, with bot/user-account fallback and chat_id safety built in."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "devgagan" },
15
+ ]
16
+ keywords = [
17
+ "telegram", "pyrogram", "kurigram", "telegram-bot", "bot-api",
18
+ "rich-message", "rich-messages", "telegram-api",
19
+ ]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Developers",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Topic :: Communications :: Chat",
31
+ "Topic :: Internet",
32
+ "Topic :: Software Development :: Libraries :: Python Modules",
33
+ "Typing :: Typed",
34
+ ]
35
+ dependencies = [
36
+ "Kurigram>=2.2.26",
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/devgaganin/richpyro"
41
+ Repository = "https://github.com/devgaganin/richpyro"
42
+ Issues = "https://github.com/devgaganin/richpyro/issues"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+
47
+ [tool.setuptools.package-data]
48
+ richpyro = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+