telekit 2.5.4__tar.gz → 2.6.0a2__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.
- {telekit-2.5.4/telekit.egg-info → telekit-2.6.0a2}/PKG-INFO +47 -92
- {telekit-2.5.4 → telekit-2.6.0a2}/README.md +36 -42
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_on.py +154 -26
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_version.py +1 -1
- telekit-2.6.0a2/telekit/example/example_handlers/__init__.py +23 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/complete_hotel.py +1 -1
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/hotel.py +1 -1
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/qr.py +1 -1
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/senders.py +22 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/utils.py +492 -56
- {telekit-2.5.4 → telekit-2.6.0a2/telekit.egg-info}/PKG-INFO +47 -92
- telekit-2.5.4/telekit/example/example_handlers/__init__.py +0 -19
- {telekit-2.5.4 → telekit-2.6.0a2}/LICENSE +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/setup.cfg +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/setup.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_buildtext/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_buildtext/formatter.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_buildtext/styles.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_callback_query_handler.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chain.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chain_base.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chain_entry_logic.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chain_inline_keyboards_logic.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chapters/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_chapters/chapters.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_handler.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_init.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_inline_buttons.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_inline_keyboard.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_input_handler.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_logger.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_reply_keyboard.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_snapvault/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_snapvault/snapcode.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_snapvault/snapvault.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_state.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/mixin.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/builder.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/canvas_parser.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/lexer.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/nodes.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/parser.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/parser/token.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/telekit_dsl.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_telekit_dsl/telekit_orm.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_text_builder.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_timeout.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_trait.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/_user.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/chat.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/debug.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/dices.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/article.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/calendar.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/counter.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/dsl.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/entry.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/faq.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/on_text.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/pages.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/pyapi.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/quiz.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/spells.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/start.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/style.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_handlers/text_document.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/example/example_server.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/html_text.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/inline_buttons.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/parameters.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/reply_buttons.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/scheduler.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/server.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/styles.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/traits/__init__.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/traits/calendar_pick.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/traits/paginated_choice.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/traits/paginated_text.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/traits/track_handoff_origin.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit/types.py +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit.egg-info/SOURCES.txt +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit.egg-info/dependency_links.txt +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit.egg-info/requires.txt +0 -0
- {telekit-2.5.4 → telekit-2.6.0a2}/telekit.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telekit
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.6.0a2
|
|
4
4
|
Summary: Declarative, developer-friendly library for building Telegram bots
|
|
5
5
|
Home-page: https://github.com/Romashkaa/telekit
|
|
6
6
|
Author: romashka
|
|
@@ -77,17 +77,16 @@ Telekit comes with a [built-in DSL](https://github.com/Romashkaa/telekit/blob/ma
|
|
|
77
77
|
|
|
78
78
|
> See the [full example](https://github.com/Romashkaa/telekit/blob/main/docs/examples/complete_hotel.md)
|
|
79
79
|
|
|
80
|
-
Even in its beta stage, Telekit accelerates bot development, offering typed **command parameters**, **text styling** via `Bold()`, `Italic()`, a built-in declarative **calendar picker
|
|
80
|
+
Even in its beta stage, Telekit accelerates bot development, offering typed **command parameters**, **text styling** via `Bold()`, `Italic()`, a built-in declarative **calendar picker** (!), emoji **game results** for `🎲 🎯 🏀 ⚽ 🎳 🎰`, and much more out of the box. Its declarative design makes bots easier to read, maintain, and extend.
|
|
81
81
|
|
|
82
82
|
**Key features:**
|
|
83
|
-
-
|
|
84
|
-
- [Ready-to-use DSL](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial/11_telekit_dsl.md) for FAQs and
|
|
85
|
-
- Automatic
|
|
86
|
-
- **Deep Linking**
|
|
87
|
-
- Built-in **Permission** and **Logging** system
|
|
88
|
-
- Reusable **Traits**
|
|
89
|
-
-
|
|
90
|
-
- Fast to develop and easy-to-extend code
|
|
83
|
+
- **Chains** handle complex conversations without state machines
|
|
84
|
+
- [Ready-to-use DSL](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial/11_telekit_dsl.md) for FAQs and interactive scripts
|
|
85
|
+
- Automatic [message formatting](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/6_styles.md) via [Sender](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/5_senders.md) and **callback routing**
|
|
86
|
+
- **Deep Linking** with type-checked [Command Parameters](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/command_trigger_parameters.md)
|
|
87
|
+
- Built-in **Permission** and **Logging** system
|
|
88
|
+
- Reusable **Traits** for pluggable behavior modules
|
|
89
|
+
- Works with [pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI)
|
|
91
90
|
|
|
92
91
|
[GitHub](https://github.com/Romashkaa/telekit)
|
|
93
92
|
[PyPI](https://pypi.org/project/telekit/)
|
|
@@ -108,9 +107,7 @@ Even in its beta stage, Telekit accelerates bot development, offering typed **co
|
|
|
108
107
|
|
|
109
108
|
## Overview
|
|
110
109
|
|
|
111
|
-
**Telekit
|
|
112
|
-
|
|
113
|
-
The idea is simple: you point to the next step — Telekit calls it when the user replies.
|
|
110
|
+
In **Telekit**, dialogs read like normal method calls. You point to the next step. Telekit calls it when the user replies.
|
|
114
111
|
|
|
115
112
|
### Entries
|
|
116
113
|
|
|
@@ -127,13 +124,13 @@ def handle_name(self, name: str):
|
|
|
127
124
|
self.chain.send()
|
|
128
125
|
```
|
|
129
126
|
|
|
130
|
-
|
|
127
|
+
`handle` sends a message and registers `handle_name` as the next step with `set_entry_text`. When the user replies, Telekit calls `handle_name` and passes the reply as a plain `str`.
|
|
131
128
|
|
|
132
129
|
> That's it. No enums. No manual state tracking. No boilerplate.
|
|
133
130
|
|
|
134
131
|
### Inline Keyboards
|
|
135
132
|
|
|
136
|
-
The fastest way to add buttons to a message. Pass a
|
|
133
|
+
The fastest way to add buttons to a message. Pass a `dict` where each key is the button label and each value is the callback to run when pressed:
|
|
137
134
|
|
|
138
135
|
```python
|
|
139
136
|
self.chain.set_inline_keyboard(
|
|
@@ -167,9 +164,7 @@ self.chain.set_inline_keyboard(
|
|
|
167
164
|
╰─────────────┴──────────────────╯
|
|
168
165
|
```
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
When you need precise row layout or conditional buttons, use `InlineKeyboard` — a fluent builder that composes keyboards step by step:
|
|
167
|
+
For precise row layout or conditional buttons, use `InlineKeyboard`, a builder you compose step by step:
|
|
173
168
|
|
|
174
169
|
```python
|
|
175
170
|
self.chain.set_keyboard(
|
|
@@ -206,7 +201,7 @@ self.chain.set_keyboard(
|
|
|
206
201
|
|
|
207
202
|
### Reply Keyboards
|
|
208
203
|
|
|
209
|
-
|
|
204
|
+
Reply keyboards replace the system keyboard with buttons at the bottom of the chat. Tapping one sends its text as a message, or triggers a system action like sharing a phone number or location.
|
|
210
205
|
|
|
211
206
|
```python
|
|
212
207
|
self.chain.set_keyboard(
|
|
@@ -239,7 +234,7 @@ class GreetHandler(telekit.Handler):
|
|
|
239
234
|
self.chain.send()
|
|
240
235
|
```
|
|
241
236
|
|
|
242
|
-
Now `/greet
|
|
237
|
+
Now `/greet 128 Dracula` or even `/greet 64 "Alice Reingold"` are parsed automatically.
|
|
243
238
|
|
|
244
239
|
> [!NOTE]
|
|
245
240
|
> If arguments are invalid or missing, you simply receive `None` and decide how to respond.
|
|
@@ -276,17 +271,17 @@ class DialogueHandler(telekit.Handler):
|
|
|
276
271
|
|
|
277
272
|
How it works:
|
|
278
273
|
|
|
279
|
-
- The handler reacts to "hello"
|
|
280
|
-
- `handle_hello` asks for the user's name
|
|
274
|
+
- The handler reacts to `"hello"`, `"hi"`, or `"hey"` in any case.
|
|
275
|
+
- `handle_hello` asks for the user's name.ч
|
|
281
276
|
- `set_entry_suggestions` attaches the user's Telegram `first_name` as a suggestion button.
|
|
282
277
|
- `handle_name` stores the name in `self.user_name`.
|
|
283
|
-
- `handle_feeling`
|
|
278
|
+
- `handle_feeling` closes the flow and adds a "↺ Restart" button that routes back to the start.
|
|
284
279
|
|
|
285
|
-
It
|
|
280
|
+
It reads like regular Python because it is regular Python.
|
|
286
281
|
|
|
287
282
|
### Sender
|
|
288
283
|
|
|
289
|
-
Want to
|
|
284
|
+
Want to attach an image, document or add an effect in a single line?
|
|
290
285
|
|
|
291
286
|
```python
|
|
292
287
|
self.chain.sender.set_effect(Effect.HEART) # Add effect to message. Use enum or string
|
|
@@ -297,11 +292,11 @@ self.chain.sender.send_chat_action(ChatAction.TYPING) # Send chat action. Use en
|
|
|
297
292
|
```
|
|
298
293
|
|
|
299
294
|
> [!NOTE]
|
|
300
|
-
> Telekit
|
|
295
|
+
> Telekit picks `bot.send_message` or `bot.send_photo` based on the content you attach.
|
|
301
296
|
|
|
302
297
|
### Styles
|
|
303
298
|
|
|
304
|
-
|
|
299
|
+
Describe formatting as objects instead of writing raw HTML or Markdown.
|
|
305
300
|
|
|
306
301
|
```py
|
|
307
302
|
from telekit.styles import *
|
|
@@ -322,7 +317,7 @@ def handle(self) -> None:
|
|
|
322
317
|
self.chain.send()
|
|
323
318
|
```
|
|
324
319
|
|
|
325
|
-
You describe structure. Telekit
|
|
320
|
+
You describe structure. Telekit turns that structure into HTML or MarkdownV2:
|
|
326
321
|
|
|
327
322
|
```html
|
|
328
323
|
<b>Text style examples:</b>
|
|
@@ -334,11 +329,11 @@ You describe structure. Telekit generates HTML or MarkdownV2 automatically:
|
|
|
334
329
|
- 5. <a href="https://t.me/MyBot?start=promo_42">Deep link</a>
|
|
335
330
|
```
|
|
336
331
|
|
|
337
|
-
|
|
332
|
+
You skip manual escaping and the broken formatting one stray character causes.
|
|
338
333
|
|
|
339
334
|
### Telekit DSL
|
|
340
335
|
|
|
341
|
-
|
|
336
|
+
Prefer not to write dialog logic in Python? Use the built-in DSL with Jinja support.
|
|
342
337
|
|
|
343
338
|
```py
|
|
344
339
|
import telekit
|
|
@@ -413,7 +408,7 @@ telekit.Server(BOT_TOKEN).polling()
|
|
|
413
408
|
|
|
414
409
|
Traits are reusable behavior modules you can mix into any handler.
|
|
415
410
|
|
|
416
|
-
|
|
411
|
+
Here's the built-in `CalendarPick` trait: a user picks a date from an inline calendar, and a callback handles the result.
|
|
417
412
|
|
|
418
413
|
```py
|
|
419
414
|
from telekit.traits import CalendarPick
|
|
@@ -447,7 +442,7 @@ class CalendarHandler(CalendarPick, telekit.Handler):
|
|
|
447
442
|
|
|
448
443
|
### Example Bot
|
|
449
444
|
|
|
450
|
-
|
|
445
|
+
Run this to launch an example bot:
|
|
451
446
|
|
|
452
447
|
```py
|
|
453
448
|
import telekit
|
|
@@ -459,70 +454,30 @@ It includes example commands, dialogs, keyboards, and style usage.
|
|
|
459
454
|
|
|
460
455
|
## Why Telekit
|
|
461
456
|
|
|
462
|
-
-
|
|
457
|
+
- Chains instead of an FSM.
|
|
463
458
|
- Declarative, behavior-focused bot logic with minimal boilerplate.
|
|
464
|
-
- Automatic
|
|
465
|
-
-
|
|
466
|
-
- Deep linking and
|
|
467
|
-
-
|
|
468
|
-
- Reusable
|
|
469
|
-
-
|
|
470
|
-
-
|
|
459
|
+
- Automatic callback routing and input handling.
|
|
460
|
+
- A Styles API for rich text (`Bold`, `Italic`, links) with automatic escaping.
|
|
461
|
+
- Deep linking and typed command parameters.
|
|
462
|
+
- A built-in DSL for menus, FAQs, and simple bots.
|
|
463
|
+
- Reusable Traits for composable behavior, including a built-in calendar picker.
|
|
464
|
+
- Zero-code mode [Obsidian Canvas](https://github.com/Romashkaa/telekit/blob/main/docs/examples/canvas_faq.md) mode.
|
|
465
|
+
- Works with `pyTelegramBotAPI`.
|
|
471
466
|
|
|
472
|
-
Telekit
|
|
473
|
-
It tries to make Telegram bot development easier.
|
|
467
|
+
Telekit focuses on one job: making Telegram bot development easier.
|
|
474
468
|
|
|
475
469
|
> [!TIP]
|
|
476
|
-
>
|
|
470
|
+
> Interested? Start with the [Tutorial](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/0_tutorial.md).
|
|
477
471
|
|
|
478
472
|
---
|
|
479
473
|
|
|
480
|
-
# Changes in version 2.
|
|
481
|
-
|
|
482
|
-
### v2.
|
|
483
|
-
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
- Implement `TelegramMarkdownV2Sanitizer` for improved `MarkdownV2` handling
|
|
491
|
-
|
|
492
|
-
### v2.5.0 `(final)`
|
|
493
|
-
- Refactor `CalendarPick` trait to use `set_keyboard`
|
|
494
|
-
|
|
495
|
-
### v2.5.0`b3`
|
|
496
|
-
- Added `utils.Markers` class
|
|
497
|
-
- Added `HTMLText` class for handling Telegram HTML strings with tag-aware indexing and slicing.
|
|
498
|
-
- Added `PaginatedText` trait for displaying long HTML text in a paginated format, supporting navigation and smart splitting.
|
|
499
|
-
- Added `__radd__` to `TextEntity`: `"Regular" + Bold(" and Bold")`
|
|
500
|
-
- Added `__mul__` to `TextEntity`: `Bold("Text") * 3`
|
|
501
|
-
- Added `enabled=` parameter to `TextEntity`: `Bold("bold text", enabled=is_text_bold)`
|
|
502
|
-
- Added `TextBuilder` class – a fluent message composition API mirroring `InlineKeyboard`'s builder pattern
|
|
503
|
-
- Added styles to `telekit.types`
|
|
504
|
-
- Added `utils.CyclicList`
|
|
505
|
-
- Fixed `_answer_callback_query` to always call `bot.answer_callback_query()`, even without a popup text
|
|
506
|
-
|
|
507
|
-
### v2.5.0`b2`
|
|
508
|
-
- Added the `escape` parameter to `telekit.utils.*`:
|
|
509
|
-
- `make_user_link`
|
|
510
|
-
- `make_bot_link`
|
|
511
|
-
- `Handler.handlers_dict` now excludes private handlers (classes whose names start with `_`).
|
|
512
|
-
- Added `Debug.duplicate_handler_warnings` to warn about duplicate handler names during initialization.
|
|
513
|
-
- Added `Handler.chat` object (BETA)
|
|
514
|
-
|
|
515
|
-
### v2.5.0`b1`
|
|
516
|
-
- Added `Sender.send_message` method.
|
|
517
|
-
- Added `utils.make_mention` utility for generating `tg://user?id=` mention links.
|
|
518
|
-
- Added new inline button types to `inline_buttons`:
|
|
519
|
-
- `ContactButton` — mentions a user by Telegram ID via `tg://user?id=`.
|
|
520
|
-
- `UserLinkButton` — opens a user profile by username; supports pre-filled message text.
|
|
521
|
-
- `BotLinkButton` — opens a bot by username; supports deep-link `?start=` payload.
|
|
522
|
-
- Added new methods to `InlineKeyboard`:
|
|
523
|
-
- `add_contact` — adds a `ContactButton`.
|
|
524
|
-
- `add_user_link` — adds a `UserLinkButton`.
|
|
525
|
-
- `add_bot_link` — adds a `BotLinkButton`.
|
|
526
|
-
|
|
527
|
-
### v2.5.0`b0`
|
|
528
|
-
- Added support for t-strings (PEP 750, Python 3.14+) in `TextEntity`.
|
|
474
|
+
# Changes in version 2.6.0a2
|
|
475
|
+
|
|
476
|
+
### v2.6.0 `a2`
|
|
477
|
+
- Reworked `.env` and token/canvas file reading in `utils`: full `.env` syntax support (comments, `export`, quotes and escapes, multi-line values, `$VAR` interpolation), a `cache` parameter (default `True`) with `clear_cache()`, detailed errors with fix suggestions and creation commands, and new `Env*Error` exceptions; `load_env` now raises `EnvFileNotFoundError` for a missing file instead of returning `{}`
|
|
478
|
+
|
|
479
|
+
### v2.6.0 `a1`
|
|
480
|
+
- Added a module-loading utility in `utils`
|
|
481
|
+
|
|
482
|
+
### v2.6.0 `a0`
|
|
483
|
+
- Improved formatting in `_on.py`
|
|
@@ -41,17 +41,16 @@ Telekit comes with a [built-in DSL](https://github.com/Romashkaa/telekit/blob/ma
|
|
|
41
41
|
|
|
42
42
|
> See the [full example](https://github.com/Romashkaa/telekit/blob/main/docs/examples/complete_hotel.md)
|
|
43
43
|
|
|
44
|
-
Even in its beta stage, Telekit accelerates bot development, offering typed **command parameters**, **text styling** via `Bold()`, `Italic()`, a built-in declarative **calendar picker
|
|
44
|
+
Even in its beta stage, Telekit accelerates bot development, offering typed **command parameters**, **text styling** via `Bold()`, `Italic()`, a built-in declarative **calendar picker** (!), emoji **game results** for `🎲 🎯 🏀 ⚽ 🎳 🎰`, and much more out of the box. Its declarative design makes bots easier to read, maintain, and extend.
|
|
45
45
|
|
|
46
46
|
**Key features:**
|
|
47
|
-
-
|
|
48
|
-
- [Ready-to-use DSL](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial/11_telekit_dsl.md) for FAQs and
|
|
49
|
-
- Automatic
|
|
50
|
-
- **Deep Linking**
|
|
51
|
-
- Built-in **Permission** and **Logging** system
|
|
52
|
-
- Reusable **Traits**
|
|
53
|
-
-
|
|
54
|
-
- Fast to develop and easy-to-extend code
|
|
47
|
+
- **Chains** handle complex conversations without state machines
|
|
48
|
+
- [Ready-to-use DSL](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial/11_telekit_dsl.md) for FAQs and interactive scripts
|
|
49
|
+
- Automatic [message formatting](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/6_styles.md) via [Sender](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/5_senders.md) and **callback routing**
|
|
50
|
+
- **Deep Linking** with type-checked [Command Parameters](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/command_trigger_parameters.md)
|
|
51
|
+
- Built-in **Permission** and **Logging** system
|
|
52
|
+
- Reusable **Traits** for pluggable behavior modules
|
|
53
|
+
- Works with [pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI)
|
|
55
54
|
|
|
56
55
|
[GitHub](https://github.com/Romashkaa/telekit)
|
|
57
56
|
[PyPI](https://pypi.org/project/telekit/)
|
|
@@ -72,9 +71,7 @@ Even in its beta stage, Telekit accelerates bot development, offering typed **co
|
|
|
72
71
|
|
|
73
72
|
## Overview
|
|
74
73
|
|
|
75
|
-
**Telekit
|
|
76
|
-
|
|
77
|
-
The idea is simple: you point to the next step — Telekit calls it when the user replies.
|
|
74
|
+
In **Telekit**, dialogs read like normal method calls. You point to the next step. Telekit calls it when the user replies.
|
|
78
75
|
|
|
79
76
|
### Entries
|
|
80
77
|
|
|
@@ -91,13 +88,13 @@ def handle_name(self, name: str):
|
|
|
91
88
|
self.chain.send()
|
|
92
89
|
```
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
`handle` sends a message and registers `handle_name` as the next step with `set_entry_text`. When the user replies, Telekit calls `handle_name` and passes the reply as a plain `str`.
|
|
95
92
|
|
|
96
93
|
> That's it. No enums. No manual state tracking. No boilerplate.
|
|
97
94
|
|
|
98
95
|
### Inline Keyboards
|
|
99
96
|
|
|
100
|
-
The fastest way to add buttons to a message. Pass a
|
|
97
|
+
The fastest way to add buttons to a message. Pass a `dict` where each key is the button label and each value is the callback to run when pressed:
|
|
101
98
|
|
|
102
99
|
```python
|
|
103
100
|
self.chain.set_inline_keyboard(
|
|
@@ -131,9 +128,7 @@ self.chain.set_inline_keyboard(
|
|
|
131
128
|
╰─────────────┴──────────────────╯
|
|
132
129
|
```
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
When you need precise row layout or conditional buttons, use `InlineKeyboard` — a fluent builder that composes keyboards step by step:
|
|
131
|
+
For precise row layout or conditional buttons, use `InlineKeyboard`, a builder you compose step by step:
|
|
137
132
|
|
|
138
133
|
```python
|
|
139
134
|
self.chain.set_keyboard(
|
|
@@ -170,7 +165,7 @@ self.chain.set_keyboard(
|
|
|
170
165
|
|
|
171
166
|
### Reply Keyboards
|
|
172
167
|
|
|
173
|
-
|
|
168
|
+
Reply keyboards replace the system keyboard with buttons at the bottom of the chat. Tapping one sends its text as a message, or triggers a system action like sharing a phone number or location.
|
|
174
169
|
|
|
175
170
|
```python
|
|
176
171
|
self.chain.set_keyboard(
|
|
@@ -203,7 +198,7 @@ class GreetHandler(telekit.Handler):
|
|
|
203
198
|
self.chain.send()
|
|
204
199
|
```
|
|
205
200
|
|
|
206
|
-
Now `/greet
|
|
201
|
+
Now `/greet 128 Dracula` or even `/greet 64 "Alice Reingold"` are parsed automatically.
|
|
207
202
|
|
|
208
203
|
> [!NOTE]
|
|
209
204
|
> If arguments are invalid or missing, you simply receive `None` and decide how to respond.
|
|
@@ -240,17 +235,17 @@ class DialogueHandler(telekit.Handler):
|
|
|
240
235
|
|
|
241
236
|
How it works:
|
|
242
237
|
|
|
243
|
-
- The handler reacts to "hello"
|
|
244
|
-
- `handle_hello` asks for the user's name
|
|
238
|
+
- The handler reacts to `"hello"`, `"hi"`, or `"hey"` in any case.
|
|
239
|
+
- `handle_hello` asks for the user's name.ч
|
|
245
240
|
- `set_entry_suggestions` attaches the user's Telegram `first_name` as a suggestion button.
|
|
246
241
|
- `handle_name` stores the name in `self.user_name`.
|
|
247
|
-
- `handle_feeling`
|
|
242
|
+
- `handle_feeling` closes the flow and adds a "↺ Restart" button that routes back to the start.
|
|
248
243
|
|
|
249
|
-
It
|
|
244
|
+
It reads like regular Python because it is regular Python.
|
|
250
245
|
|
|
251
246
|
### Sender
|
|
252
247
|
|
|
253
|
-
Want to
|
|
248
|
+
Want to attach an image, document or add an effect in a single line?
|
|
254
249
|
|
|
255
250
|
```python
|
|
256
251
|
self.chain.sender.set_effect(Effect.HEART) # Add effect to message. Use enum or string
|
|
@@ -261,11 +256,11 @@ self.chain.sender.send_chat_action(ChatAction.TYPING) # Send chat action. Use en
|
|
|
261
256
|
```
|
|
262
257
|
|
|
263
258
|
> [!NOTE]
|
|
264
|
-
> Telekit
|
|
259
|
+
> Telekit picks `bot.send_message` or `bot.send_photo` based on the content you attach.
|
|
265
260
|
|
|
266
261
|
### Styles
|
|
267
262
|
|
|
268
|
-
|
|
263
|
+
Describe formatting as objects instead of writing raw HTML or Markdown.
|
|
269
264
|
|
|
270
265
|
```py
|
|
271
266
|
from telekit.styles import *
|
|
@@ -286,7 +281,7 @@ def handle(self) -> None:
|
|
|
286
281
|
self.chain.send()
|
|
287
282
|
```
|
|
288
283
|
|
|
289
|
-
You describe structure. Telekit
|
|
284
|
+
You describe structure. Telekit turns that structure into HTML or MarkdownV2:
|
|
290
285
|
|
|
291
286
|
```html
|
|
292
287
|
<b>Text style examples:</b>
|
|
@@ -298,11 +293,11 @@ You describe structure. Telekit generates HTML or MarkdownV2 automatically:
|
|
|
298
293
|
- 5. <a href="https://t.me/MyBot?start=promo_42">Deep link</a>
|
|
299
294
|
```
|
|
300
295
|
|
|
301
|
-
|
|
296
|
+
You skip manual escaping and the broken formatting one stray character causes.
|
|
302
297
|
|
|
303
298
|
### Telekit DSL
|
|
304
299
|
|
|
305
|
-
|
|
300
|
+
Prefer not to write dialog logic in Python? Use the built-in DSL with Jinja support.
|
|
306
301
|
|
|
307
302
|
```py
|
|
308
303
|
import telekit
|
|
@@ -377,7 +372,7 @@ telekit.Server(BOT_TOKEN).polling()
|
|
|
377
372
|
|
|
378
373
|
Traits are reusable behavior modules you can mix into any handler.
|
|
379
374
|
|
|
380
|
-
|
|
375
|
+
Here's the built-in `CalendarPick` trait: a user picks a date from an inline calendar, and a callback handles the result.
|
|
381
376
|
|
|
382
377
|
```py
|
|
383
378
|
from telekit.traits import CalendarPick
|
|
@@ -411,7 +406,7 @@ class CalendarHandler(CalendarPick, telekit.Handler):
|
|
|
411
406
|
|
|
412
407
|
### Example Bot
|
|
413
408
|
|
|
414
|
-
|
|
409
|
+
Run this to launch an example bot:
|
|
415
410
|
|
|
416
411
|
```py
|
|
417
412
|
import telekit
|
|
@@ -423,18 +418,17 @@ It includes example commands, dialogs, keyboards, and style usage.
|
|
|
423
418
|
|
|
424
419
|
## Why Telekit
|
|
425
420
|
|
|
426
|
-
-
|
|
421
|
+
- Chains instead of an FSM.
|
|
427
422
|
- Declarative, behavior-focused bot logic with minimal boilerplate.
|
|
428
|
-
- Automatic
|
|
429
|
-
-
|
|
430
|
-
- Deep linking and
|
|
431
|
-
-
|
|
432
|
-
- Reusable
|
|
433
|
-
-
|
|
434
|
-
-
|
|
423
|
+
- Automatic callback routing and input handling.
|
|
424
|
+
- A Styles API for rich text (`Bold`, `Italic`, links) with automatic escaping.
|
|
425
|
+
- Deep linking and typed command parameters.
|
|
426
|
+
- A built-in DSL for menus, FAQs, and simple bots.
|
|
427
|
+
- Reusable Traits for composable behavior, including a built-in calendar picker.
|
|
428
|
+
- Zero-code mode [Obsidian Canvas](https://github.com/Romashkaa/telekit/blob/main/docs/examples/canvas_faq.md) mode.
|
|
429
|
+
- Works with `pyTelegramBotAPI`.
|
|
435
430
|
|
|
436
|
-
Telekit
|
|
437
|
-
It tries to make Telegram bot development easier.
|
|
431
|
+
Telekit focuses on one job: making Telegram bot development easier.
|
|
438
432
|
|
|
439
433
|
> [!TIP]
|
|
440
|
-
>
|
|
434
|
+
> Interested? Start with the [Tutorial](https://github.com/Romashkaa/telekit/blob/main/docs/tutorial2/0_tutorial.md).
|