telekit 2.5.0rc1__tar.gz → 2.5.2__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.
Files changed (87) hide show
  1. {telekit-2.5.0rc1 → telekit-2.5.2}/PKG-INFO +31 -22
  2. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/mixin.py +13 -3
  3. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_version.py +1 -1
  4. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/hotel.py +2 -1
  5. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/on_text.py +1 -1
  6. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/traits/calendar_pick.py +180 -195
  7. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/utils.py +176 -111
  8. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit.egg-info/PKG-INFO +31 -22
  9. {telekit-2.5.0rc1 → telekit-2.5.2}/LICENSE +0 -0
  10. {telekit-2.5.0rc1 → telekit-2.5.2}/README.md +0 -0
  11. {telekit-2.5.0rc1 → telekit-2.5.2}/setup.cfg +0 -0
  12. {telekit-2.5.0rc1 → telekit-2.5.2}/setup.py +0 -0
  13. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/__init__.py +0 -0
  14. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_buildtext/__init__.py +0 -0
  15. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_buildtext/formatter.py +0 -0
  16. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_buildtext/styles.py +0 -0
  17. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_callback_query_handler.py +0 -0
  18. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chain.py +0 -0
  19. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chain_base.py +0 -0
  20. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chain_entry_logic.py +0 -0
  21. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chain_inline_keyboards_logic.py +0 -0
  22. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chapters/__init__.py +0 -0
  23. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_chapters/chapters.py +0 -0
  24. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_handler.py +0 -0
  25. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_init.py +0 -0
  26. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_inline_buttons.py +0 -0
  27. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_inline_keyboard.py +0 -0
  28. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_input_handler.py +0 -0
  29. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_logger.py +0 -0
  30. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_on.py +0 -0
  31. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_reply_keyboard.py +0 -0
  32. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_snapvault/__init__.py +0 -0
  33. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_snapvault/snapcode.py +0 -0
  34. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_snapvault/snapvault.py +0 -0
  35. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_state.py +0 -0
  36. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/__init__.py +0 -0
  37. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/__init__.py +0 -0
  38. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/builder.py +0 -0
  39. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/canvas_parser.py +0 -0
  40. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/lexer.py +0 -0
  41. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/nodes.py +0 -0
  42. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/parser.py +0 -0
  43. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/parser/token.py +0 -0
  44. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/telekit_dsl.py +0 -0
  45. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_telekit_dsl/telekit_orm.py +0 -0
  46. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_text_builder.py +0 -0
  47. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_timeout.py +0 -0
  48. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_trait.py +0 -0
  49. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/_user.py +0 -0
  50. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/chat.py +0 -0
  51. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/debug.py +0 -0
  52. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/dices.py +0 -0
  53. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/__init__.py +0 -0
  54. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/__init__.py +0 -0
  55. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/article.py +0 -0
  56. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/calendar.py +0 -0
  57. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/complete_hotel.py +0 -0
  58. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/counter.py +0 -0
  59. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/dsl.py +0 -0
  60. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/entry.py +0 -0
  61. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/faq.py +0 -0
  62. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/pages.py +0 -0
  63. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/pyapi.py +0 -0
  64. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/qr.py +0 -0
  65. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/quiz.py +0 -0
  66. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/spells.py +0 -0
  67. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/start.py +0 -0
  68. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/style.py +0 -0
  69. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_handlers/text_document.py +0 -0
  70. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/example/example_server.py +0 -0
  71. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/html_text.py +0 -0
  72. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/inline_buttons.py +0 -0
  73. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/parameters.py +0 -0
  74. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/reply_buttons.py +0 -0
  75. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/scheduler.py +0 -0
  76. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/senders.py +0 -0
  77. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/server.py +0 -0
  78. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/styles.py +0 -0
  79. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/traits/__init__.py +0 -0
  80. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/traits/paginated_choice.py +0 -0
  81. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/traits/paginated_text.py +0 -0
  82. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/traits/track_handoff_origin.py +0 -0
  83. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit/types.py +0 -0
  84. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit.egg-info/SOURCES.txt +0 -0
  85. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit.egg-info/dependency_links.txt +0 -0
  86. {telekit-2.5.0rc1 → telekit-2.5.2}/telekit.egg-info/requires.txt +0 -0
  87. {telekit-2.5.0rc1 → telekit-2.5.2}/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.5.0rc1
3
+ Version: 2.5.2
4
4
  Summary: Declarative, developer-friendly library for building Telegram bots
5
5
  Home-page: https://github.com/Romashkaa/telekit
6
6
  Author: romashka
@@ -477,30 +477,16 @@ It tries to make Telegram bot development easier.
477
477
 
478
478
  ---
479
479
 
480
- # Changes in version 2.5.0rc1
480
+ # Changes in version 2.5.2
481
481
 
482
- ### v2.5.0`b0`
483
- - Added support for t-strings (PEP 750, Python 3.14+) in `TextEntity`.
482
+ ### v2.5.2
483
+ - Add `random_` variable prefix in `DSLHandler` — resolves to a random choice from a `list`/`tuple`/`str` static variable
484
484
 
485
- ### v2.5.0`b1`
486
- - Added `Sender.send_message` method.
487
- - Added `utils.make_mention` utility for generating `tg://user?id=` mention links.
488
- - Added new inline button types to `inline_buttons`:
489
- - `ContactButton` — mentions a user by Telegram ID via `tg://user?id=`.
490
- - `UserLinkButton` — opens a user profile by username; supports pre-filled message text.
491
- - `BotLinkButton` — opens a bot by username; supports deep-link `?start=` payload.
492
- - Added new methods to `InlineKeyboard`:
493
- - `add_contact` — adds a `ContactButton`.
494
- - `add_user_link` — adds a `UserLinkButton`.
495
- - `add_bot_link` — adds a `BotLinkButton`.
485
+ ### v2.5.1 `(bug-fix)`
486
+ - Implement `TelegramMarkdownV2Sanitizer` for improved `MarkdownV2` handling
496
487
 
497
- ### v2.5.0`b2`
498
- - Added the `escape` parameter to `telekit.utils.*`:
499
- - `make_user_link`
500
- - `make_bot_link`
501
- - `Handler.handlers_dict` now excludes private handlers (classes whose names start with `_`).
502
- - Added `Debug.duplicate_handler_warnings` to warn about duplicate handler names during initialization.
503
- - Added `Handler.chat` object (BETA)
488
+ ### v2.5.0 `(final)`
489
+ - Refactor `CalendarPick` trait to use `set_keyboard`
504
490
 
505
491
  ### v2.5.0`b3`
506
492
  - Added `utils.Markers` class
@@ -513,3 +499,26 @@ It tries to make Telegram bot development easier.
513
499
  - Added styles to `telekit.types`
514
500
  - Added `utils.CyclicList`
515
501
  - Fixed `_answer_callback_query` to always call `bot.answer_callback_query()`, even without a popup text
502
+
503
+ ### v2.5.0`b2`
504
+ - Added the `escape` parameter to `telekit.utils.*`:
505
+ - `make_user_link`
506
+ - `make_bot_link`
507
+ - `Handler.handlers_dict` now excludes private handlers (classes whose names start with `_`).
508
+ - Added `Debug.duplicate_handler_warnings` to warn about duplicate handler names during initialization.
509
+ - Added `Handler.chat` object (BETA)
510
+
511
+ ### v2.5.0`b1`
512
+ - Added `Sender.send_message` method.
513
+ - Added `utils.make_mention` utility for generating `tg://user?id=` mention links.
514
+ - Added new inline button types to `inline_buttons`:
515
+ - `ContactButton` — mentions a user by Telegram ID via `tg://user?id=`.
516
+ - `UserLinkButton` — opens a user profile by username; supports pre-filled message text.
517
+ - `BotLinkButton` — opens a bot by username; supports deep-link `?start=` payload.
518
+ - Added new methods to `InlineKeyboard`:
519
+ - `add_contact` — adds a `ContactButton`.
520
+ - `add_user_link` — adds a `UserLinkButton`.
521
+ - `add_bot_link` — adds a `BotLinkButton`.
522
+
523
+ ### v2.5.0`b0`
524
+ - Added support for t-strings (PEP 750, Python 3.14+) in `TextEntity`.
@@ -18,7 +18,7 @@
18
18
  #
19
19
 
20
20
  import jinja2
21
- import re, json, copy
21
+ import re, json, copy, random
22
22
  from typing import NoReturn, Callable, Any, Literal
23
23
 
24
24
  import telekit
@@ -715,10 +715,20 @@ class DSLHandler(telekit.Handler):
715
715
 
716
716
  if isinstance(value, str):
717
717
  return value
718
+
719
+ GET_RANDOM_PREFIX = "random_"
718
720
 
719
721
  def _get_static_var(self, name: str) -> str | None:
720
- value = self.script_data.static_vars.get(name)
721
- return None if value is None else str(value)
722
+ if name.startswith(self.GET_RANDOM_PREFIX):
723
+ name = name[len(self.GET_RANDOM_PREFIX):]
724
+ seq = self.script_data.static_vars.get(name)
725
+ if isinstance(seq, (str, list, tuple)):
726
+ return str(random.choice(seq))
727
+ else:
728
+ return str(seq)
729
+ else:
730
+ value = self.script_data.static_vars.get(name)
731
+ return None if value is None else str(value)
722
732
 
723
733
  def _get_default_var(self, name: str):
724
734
  match name:
@@ -3,4 +3,4 @@
3
3
  # PyPI history: https://pypi.org/project/telekit/#history
4
4
  # ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
5
5
 
6
- __version__ = "2.5.0rc1"
6
+ __version__ = "2.5.2"
@@ -58,10 +58,11 @@ script = """
58
58
  $ vars {
59
59
  ECONOM_PRICE = 50
60
60
  COMFORT_PRICE = 120
61
+ NAME = ["Telekit", "Budapest", "Theft"]
61
62
  }
62
63
 
63
64
  @ main {
64
- title = "🏨 Grand Telekit Hotel"
65
+ title = "🏨 Grand {{random_NAME}} Hotel"
65
66
  message = "Welcome, {{first_name}}! Choose your experience and explore our rooms."
66
67
 
67
68
  buttons (2) {
@@ -37,7 +37,7 @@ class OnTextHandler(telekit.Handler):
37
37
  if not age:
38
38
  age = "An unknown number of"
39
39
 
40
- self.chain.sender.set_title(Group("Hello, ", Italic(name), "!"))
40
+ self.chain.sender.set_title("👋 Hello, ", Italic(name), "!")
41
41
  self.chain.sender.set_message(Italic(age), " years is a wonderful stage of life!")
42
42
  self.chain.disable_timeout_warnings()
43
43
  self.chain.send()