telegix 1.1.1 โ†’ 1.1.3-a1

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.
package/README.md CHANGED
@@ -35,11 +35,28 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
35
35
  - [Message Editing, Deleting, Forwarding, Copying, & Pinning](#message-editing-deleting-forwarding-copying--pinning)
36
36
  - [Chat Administration & Member Moderation](#chat-administration--member-moderation)
37
37
  - [Forum Supergroups & Topics Management](#forum-supergroups--topics-management)
38
- - [Bot API 10.3 Methods (Rich Messages, Drafts, Ephemeral Messages, Managed Access)](#bot-api-103-methods-rich-messages-drafts-ephemeral-messages-managed-access)
38
+ - [Bot API 10.2 & 10.3 Methods (Live Photos, Rich Messages, Drafts, Ephemeral Messages, Managed Access)](#bot-api-102--103-methods-live-photos-rich-messages-drafts-ephemeral-messages-managed-access)
39
39
  - [๐ŸŽจ Rich Message & Layout Builder Suite (`RichMessage`)](#-rich-message--layout-builder-suite-richmessage)
40
40
  - [Fluent Block Builder API](#fluent-block-builder-api)
41
+ - [Interactive Checklist Blocks (Bot API 10.2+)](#interactive-checklist-blocks-bot-api-102)
42
+ - [AI Thinking Indicator & Media Layouts (Collage, Slideshow)](#ai-thinking-indicator--media-layouts-collage-slideshow)
41
43
  - [Static Factory Methods](#static-factory-methods)
42
44
  - [Complete Interactive Rich Card Example](#complete-interactive-rich-card-example)
45
+ - [๐Ÿ“Š Table & Grid Formatting Suite (`Table` & `InputRichBlockTable`)](#-table--grid-formatting-suite-table--inputrichblocktable)
46
+ - [๐Ÿ“ฑ Telegram Bot Card Tables (Rounded Card with Grid Dividers)](#-telegram-bot-card-tables-rounded-card-with-grid-dividers)
47
+ - [๐Ÿค– Pre-Configured & Fully Customizable System & User Profile Cards](#-pre-configured--fully-customizable-system--user-profile-cards)
48
+ - [๐Ÿ’Ž Multi-Card Stacking (`Table.multiCardSvg` & `ctx.replyWithCardTables`)](#-multi-card-stacking-tablemulticardsvg--ctxreplywithcardtables)
49
+ - [Monospaced Text Tables (Box, ASCII, Compact, Markdown)](#monospaced-text-tables-box-ascii-compact-markdown)
50
+ - [Direct Context Table Replies (`ctx.replyWithTable`)](#direct-context-table-replies-ctxreplywithtable)
51
+ - [Generating Tables from Objects (`Table.fromObjects`)](#generating-tables-from-objects-tablefromobjects)
52
+ - [Bot API 10.3 Native Rich Table Blocks](#bot-api-103-native-rich-table-blocks)
53
+ - [๐Ÿ“ธ Live Photos Suite (Bot API 10.2+)](#-live-photos-suite-bot-api-102)
54
+ - [โ†ฉ๏ธ Extended Reply Parameters & Ephemeral Commands (Bot API 10.2+)](#-extended-reply-parameters--ephemeral-commands-bot-api-102)
55
+ - [๐Ÿ”ต Blue Text & Telegram Protocol Links (`tg://`, `documentLink`, `userLink`)](#-blue-text--telegram-protocol-links-tg-documentlink-userlink)
56
+ - [Blue Document Links (`tg://document?id=...`)](#blue-document-links-tgdocumentid)
57
+ - [Blue User Mention Links (`tg://user?id=...`)](#blue-user-mention-links-tguserid)
58
+ - [Blue Primary Buttons & Colored Buttons](#blue-primary-buttons--colored-buttons)
59
+ - [โฑ๏ธ Ephemeral Messages & Auto-Disappearing Lifetimes (`EphemeralMessageParameters`)](#๏ธ-ephemeral-messages--auto-disappearing-lifetimes-ephemeralmessageparameters)
43
60
  - [๐Ÿšฆ Composer & Router Engine](#-composer--router-engine)
44
61
  - [Event Filtering (`bot.on`)](#event-filtering-boton)
45
62
  - [Slash Commands (`bot.command`)](#slash-commands-botcommand)
@@ -51,7 +68,12 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
51
68
  - [Custom Reply Keyboards](#custom-reply-keyboards)
52
69
  - [Inline Keyboards](#inline-keyboards)
53
70
  - [Complete Button Builder Reference](#complete-button-builder-reference)
71
+ - [๐ŸŽจ Colored Buttons for Bots (Bot API 9.4+)](#-colored-buttons-for-bots-bot-api-94)
54
72
  - [Removing Keyboards & Force Reply](#removing-keyboards--force-reply)
73
+ - [๐ŸŒŠ Streaming Text for Bots (`streamText` & `streamDraft`)](#-streaming-text-for-bots-streamtext--streamdraft)
74
+ - [Real-Time Message Edit Streaming](#real-time-message-edit-streaming)
75
+ - [Live Draft Streaming (Bot API 10.3+)](#live-draft-streaming-bot-api-103)
76
+ - [Streaming AI & LLM Responses (Gemini, OpenAI, Generators)](#streaming-ai--llm-responses-gemini-openai-generators)
55
77
  - [๐Ÿ’ฌ Asynchronous Conversations & Wizard Scenes](#-asynchronous-conversations--wizard-scenes)
56
78
  - [Interactive Inline Prompts (`await ctx.prompt`)](#interactive-inline-prompts-await-ctxprompt)
57
79
  - [Multi-Step Wizard Scenes (`WizardScene` & `Stage`)](#multi-step-wizard-scenes-wizardscene--stage)
@@ -63,8 +85,15 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
63
85
  - [โœ’๏ธ Message Formatting (`fmt`, `html`, `mdv2`)](#๏ธ-message-formatting-fmt-html-mdv2)
64
86
  - [XSS-Safe HTML Builder (`fmt` & `html`)](#xss-safe-html-builder-fmt--html)
65
87
  - [MarkdownV2 Escaping Helpers (`mdv2`)](#markdownv2-escaping-helpers-mdv2)
88
+ - [๐Ÿ“œ Collapsible Quotes (`fmt`, `mdv2`, `RichMessage`)](#-collapsible-quotes-fmt-mdv2-richmessage)
89
+ - [๐Ÿ”— Adjustable Link Previews (`LinkPreview`)](#-adjustable-link-previews-linkpreview)
66
90
  - [๐Ÿ’ณ Payments, Invoices & Telegram Stars (`InvoiceBuilder`)](#-payments-invoices--telegram-stars-invoicebuilder)
67
- - [๐Ÿ“ฑ Telegram Mini Apps / WebApps (`validateWebAppInitData`)](#-telegram-mini-apps--webapps-validatewebappinitdata)
91
+ - [๐Ÿ“ฑ Telegram Mini Apps Suite (`MiniApp` & Utilities)](#-telegram-mini-apps-suite-miniapp--utilities)
92
+ - [Mini App Authentication (`validateWebAppInitData`)](#mini-app-authentication-validatewebappinitdata)
93
+ - [Full-Screen Mode](#full-screen-mode)
94
+ - [Device Motion Tracking (Accelerometer, Orientation, Gyroscope)](#device-motion-tracking-accelerometer-orientation-gyroscope)
95
+ - [Custom Loading Screen Generator (`MiniAppLoadingScreen`)](#custom-loading-screen-generator-miniapploadingscreen)
96
+ - [Home Screen & Prepared Inline Messages](#home-screen--prepared-inline-messages)
68
97
  - [๐Ÿค– Multi-Bot Process Manager (`TelegixManager`)](#-multi-bot-process-manager-telegixmanager)
69
98
  - [โšก Advanced Built-in Middlewares](#-advanced-built-in-middlewares)
70
99
  - [Rate Limiter Middleware (`rateLimit`)](#rate-limiter-middleware-ratelimit)
@@ -73,6 +102,7 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
73
102
  - [Automatic Chat Action (`chatActionMiddleware`)](#automatic-chat-action-chatactionmiddleware)
74
103
  - [Inline Query Pagination (`paginateInlineQuery`)](#inline-query-pagination-paginateinlinequery)
75
104
  - [๐Ÿ“š Complete Telegram API Client Method Reference (`bot.telegram` / `bot.api`)](#-complete-telegram-api-client-method-reference-bottelegram--botapi)
105
+ - [๐Ÿ’ก Example Scripts & Demos](#-example-scripts--demos)
76
106
  - [๐ŸŸฆ TypeScript Support](#-typescript-support)
77
107
  - [๐Ÿงช Running Tests](#-running-tests)
78
108
  - [๐Ÿ“„ License](#-license)
@@ -83,8 +113,10 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
83
113
 
84
114
  - **Pure JavaScript & Zero Runtime Dependencies**: Built entirely on native Web standards (`fetch`, `FormData`, `Blob`) with zero binary compilation and zero third-party packages.
85
115
  - **Dual Module Architecture**: Full, native compatibility with modern **ESM (`import`)** and **CommonJS (`require`)**.
86
- - **Complete Telegram Bot API 10.3 Compliance**: Built-in support for message drafts (`sendMessageDraft`, `sendRichMessageDraft`), ephemeral messages (`sendEphemeralMessage`), managed bot access settings (`getManagedBotAccessSettings`, `setManagedBotAccessSettings`), disabled buttons (`Markup.button.disabled`), and Telegram Stars (`XTR`).
87
- - **Rich Message Builder Suite**: Fluent `RichMessage` API with structured blocks, headers, badges, quotes, code blocks, and automatic HTML fallback compilation.
116
+ - **Complete Telegram Bot API 10.2 & 10.3 Compliance**: Built-in support for Live Photos (`sendLivePhoto`, `replyWithLivePhoto`), message drafts (`sendMessageDraft`, `sendRichMessageDraft`), ephemeral messages (`sendEphemeralMessage`), extended reply parameters (`checklist_task_id`, `poll_option_id`, `is_ephemeral`), ephemeral commands (`BotCommand.is_ephemeral`), managed bot access settings (`getManagedBotAccessSettings`), disabled buttons (`Markup.button.disabled`), and Telegram Stars (`XTR`).
117
+ - **Rich Message Builder Suite**: Fluent `RichMessage` API with structured blocks, headers, badges, quotes, code blocks, interactive checklists (`.checklist()`), AI reasoning indicators (`.thinking()`), media layouts (`.collage()`, `.slideshow()`), and automatic HTML fallback compilation.
118
+ - **Table & Card Formatting Engine**: Generate monospaced tables (`box`, `ascii`, `compact`, `markdown`), native Bot API 10.3 `InputRichBlockTable` blocks, and sleek Telegram Bot dark status cards with arbitrary dynamic fields (`ctx.replyWithSystemStatus`, `ctx.replyWithUserProfile`).
119
+ - **Blue Text & Telegram Protocol Links**: Native helpers for `tg://document?id=...` and `tg://user?id=...` to display blue clickable links in chat without external web routing.
88
120
  - **Seamless Keyboard Normalization**: Pass `Markup.keyboard()` or `Markup.inlineKeyboard()` directly as the 2nd argument to `ctx.reply()` without manual JSON wrapping or extra payloads.
89
121
  - **Asynchronous Inline Prompts**: Await user answers step-by-step with `const answer = await ctx.prompt('What is your name?')`.
90
122
  - **Multi-Step Wizard Scenes**: Structured conversation flows with `WizardScene` and `Stage` for complex interactive state machines.
@@ -429,6 +461,38 @@ await ctx.reply('Choose an option:', {
429
461
  [Markup.button.callback('Option 1', 'opt_1')],
430
462
  ]),
431
463
  });
464
+
465
+ // Stream real-time tokens/text with automated throttle control
466
+ await ctx.streamText(tokenGenerator(), { initialMessage: 'โณ Thinking...' });
467
+
468
+ // Stream real-time draft into chat input bar (Bot API 10.3)
469
+ await ctx.streamDraft(tokenGenerator());
470
+
471
+ // Reply with customized link preview (small/large, above/below, disabled)
472
+ await ctx.replyWithLinkPreview('Visit Docs:', LinkPreview.large('https://telegix.dev'));
473
+
474
+ // Reply with expandable/collapsible blockquote
475
+ await ctx.replyWithCollapsibleQuote('Full debug stack trace...', 'โš ๏ธ <b>System Warning</b>');
476
+
477
+ // Reply with button launching a Telegram Mini App
478
+ await ctx.replyWithWebApp('Launch Dashboard:', 'https://app.example.com', '๐Ÿš€ Open App');
479
+
480
+ // Reply with formatted monospaced table (Box, Compact, ASCII, Markdown)
481
+ await ctx.replyWithTable(['Item', 'Price'], [['Pro Plan', '$29'], ['Addon', '$5']], { style: 'box' });
482
+
483
+ // Reply with auto-disappearing ephemeral message (Bot API 10.3)
484
+ await ctx.replyEphemeral('This message will disappear in 15 seconds.', 15);
485
+
486
+ // Save a prepared inline message for Mini App sharing (Bot API 8.0+)
487
+ const prepared = await ctx.savePreparedInlineMessage({
488
+ type: 'article',
489
+ id: 'share_1',
490
+ title: 'Share Score',
491
+ input_message_content: { message_text: 'I reached Level 10!' },
492
+ });
493
+
494
+ // Retrieve bot user identity
495
+ const me = await ctx.getMe();
432
496
  ```
433
497
 
434
498
  ---
@@ -475,6 +539,13 @@ await ctx.replyWithMediaGroup([
475
539
  { type: 'photo', media: 'https://example.com/photo2.jpg' },
476
540
  { type: 'video', media: 'https://example.com/video1.mp4' },
477
541
  ]);
542
+
543
+ // 9. Send Live Photo (Bot API 10.2+)
544
+ await ctx.replyWithLivePhoto(
545
+ 'https://example.com/cover.jpg',
546
+ 'https://example.com/motion.mp4',
547
+ { caption: '๐Ÿ“ธ Dynamic Live Photo' }
548
+ );
478
549
  ```
479
550
 
480
551
  ---
@@ -634,17 +705,28 @@ await ctx.unpinAllForumTopicMessages(ctx.topicId);
634
705
 
635
706
  ---
636
707
 
637
- ### Bot API 10.3 Methods (Rich Messages, Drafts, Ephemeral Messages, Managed Access)
708
+ ### Bot API 10.2 & 10.3 Methods (Live Photos, Rich Messages, Drafts, Ephemeral Messages, Managed Access)
638
709
 
639
710
  ```javascript
640
- import { RichMessage, Markup } from 'telegix';
711
+ import { RichMessage, Markup, ReplyParameters } from 'telegix';
641
712
 
642
- // 1. Send Rich Message (structured layout blocks with automatic fallback)
713
+ // 1. Send Live Photo (Bot API 10.2+)
714
+ await ctx.replyWithLivePhoto(
715
+ 'https://example.com/photo.jpg',
716
+ 'https://example.com/video.mp4',
717
+ { caption: 'โœจ Interactive Live Photo' }
718
+ );
719
+
720
+ // 2. Send Rich Message (structured layout blocks with automatic fallback)
643
721
  const card = RichMessage.card('โšก Server Health Check', 'All systems operational.')
644
722
  .header('Cluster Status', '๐ŸŸข')
645
723
  .badge('CPU Load', '14%')
646
724
  .badge('Memory', '1.2 GB / 8.0 GB')
647
- .list(['Node 1: Online', 'Node 2: Online', 'Node 3: Standby'])
725
+ .checklist([
726
+ { text: 'Database connectivity', is_checked: true },
727
+ { text: 'Redis cache synchronization', is_checked: true },
728
+ { text: 'Worker nodes online', is_checked: false },
729
+ ])
648
730
  .expandableQuote('Rich messages provide structured block layouts.')
649
731
  .row(
650
732
  Markup.button.callback('๐Ÿ”„ Refresh', 'refresh_stats'),
@@ -653,23 +735,32 @@ const card = RichMessage.card('โšก Server Health Check', 'All systems operationa
653
735
 
654
736
  await ctx.replyWithRichMessage(card);
655
737
 
656
- // 2. Edit existing message with Rich Message
738
+ // 3. Edit existing message with Rich Message
657
739
  await ctx.editRichMessageText(card);
658
740
 
659
- // 3. Send Rich Message Draft
741
+ // 4. Send Rich Message Draft
660
742
  await ctx.sendRichMessageDraft(card);
661
743
 
662
- // 4. Send Message Draft (Real-time draft displayed directly in user client)
744
+ // 5. Send Message Draft (Real-time draft displayed directly in user client)
663
745
  await ctx.sendMessageDraft('Bot is currently preparing your report...');
664
746
 
665
- // 5. Send Ephemeral Message (Message with automated lifetime)
747
+ // 6. Send Ephemeral Message (Message with automated lifetime)
666
748
  await ctx.sendEphemeralMessage('This message will automatically vanish in 15 seconds.', 15);
667
749
 
668
- // 6. Managed Bot Access Settings (Bot API 10.3)
750
+ // 7. Extended ReplyParameters (Bot API 10.2+)
751
+ await ctx.reply('Replying to specific checklist task:', {
752
+ reply_parameters: {
753
+ message_id: ctx.message?.message_id,
754
+ checklist_task_id: 2,
755
+ allow_sending_without_reply: true,
756
+ },
757
+ });
758
+
759
+ // 8. Managed Bot Access Settings (Bot API 10.3)
669
760
  const accessSettings = await ctx.getManagedBotAccessSettings(adminUserId);
670
761
  await ctx.setManagedBotAccessSettings({ allow_admin_override: true }, adminUserId);
671
762
 
672
- // 7. Get User Personal Chat Messages
763
+ // 9. Get User Personal Chat Messages
673
764
  const messages = await ctx.getUserPersonalChatMessages(targetUserId);
674
765
  ```
675
766
 
@@ -695,8 +786,20 @@ The `RichMessage` class allows you to construct modern, structured card layouts,
695
786
  | `.mention(text, userId)` | Adds an inline mention link for a Telegram user ID. |
696
787
  | `.list(items, bullet?)` | Formats an array of strings into a bulleted list. |
697
788
  | `.numberedList(items)` | Formats an array of strings into a numbered list (1., 2., 3.). |
789
+ | `.checklist(items, options?)` | Adds an interactive task checklist block with checkbox states (`is_checked: boolean`) (**Bot API 10.2+**). |
790
+ | `.thinking(text)` | Adds an AI reasoning/thinking status indicator block. |
791
+ | `.sectionHeading(text, level?)` | Adds a section heading block with semantic level 1-3. |
792
+ | `.collage(photos, options?)` | Arranges multiple photos into a cohesive photo grid collage. |
793
+ | `.slideshow(photos, options?)` | Arranges media into a sequential interactive slideshow. |
794
+ | `.isRtl(boolean)` | Sets Right-to-Left script direction (Arabic, Hebrew, Persian). |
795
+ | `.addMedia(media, options?)` / `.media(...)` | Attaches a media object (photo, video, audio) to the rich message. |
796
+ | `.table(headers, rows, options?)` | Adds a structured table block (Bot API 10.3 Native Block or HTML pre-formatted fallback). |
797
+ | `.compactTable(headers, rows, options?)` | Adds a compact table block with minimal padding for mobile. |
798
+ | `.document(document, caption?, options?)` | Adds a rich document block attachment. |
799
+ | `.documentLink(documentId, text?)` | Adds an inline blue document download link (`tg://document?id=...`). |
698
800
  | `.badge(label, value, icon?)` | Adds a key-value metric badge item. |
699
801
  | `.divider()` | Inserts a clean visual separator line. |
802
+ | `.buttons(matrix)` | Appends a matrix of inline keyboard buttons as a block. |
700
803
  | `.row(...buttons)` | Appends a row of inline keyboard buttons. |
701
804
  | `.callback(text, data)` | Appends an inline callback query button. |
702
805
  | `.url(text, url)` | Appends an external URL link button. |
@@ -707,6 +810,55 @@ The `RichMessage` class allows you to construct modern, structured card layouts,
707
810
  | `.send(ctx)` | Sends the rich message using the active context. |
708
811
  | `.edit(ctx)` | Edits an existing message with this rich message. |
709
812
 
813
+ ### Interactive Checklist Blocks (Bot API 10.2+)
814
+
815
+ Telegram Bot API 10.2 introduced interactive checklist blocks (`InputRichBlockChecklist`). Telegix provides first-class support for defining tasks with dynamic completion states:
816
+
817
+ ```javascript
818
+ import { RichMessage, Markup } from 'telegix';
819
+
820
+ bot.command('tasks', async (ctx) => {
821
+ const msg = RichMessage.create('๐Ÿ“‹ <b>Sprint Tasks</b>')
822
+ .sectionHeading('Milestone 1 Deliverables', 2)
823
+ .checklist([
824
+ { text: 'Complete Bot API 10.2 Live Photo integration', is_checked: true },
825
+ { text: 'Implement Checklist rich blocks', is_checked: true },
826
+ { text: 'Ship documentation and example suite', is_checked: false },
827
+ ])
828
+ .divider()
829
+ .row(
830
+ Markup.button.success('Mark All Done', 'tasks_complete_all'),
831
+ Markup.button.primary('Refresh', 'tasks_refresh')
832
+ );
833
+
834
+ await ctx.replyWithRichMessage(msg);
835
+ });
836
+ ```
837
+
838
+ ### AI Thinking Indicator & Media Layouts (Collage, Slideshow)
839
+
840
+ Modern AI assistants can indicate active reasoning and thinking stages before displaying output:
841
+
842
+ ```javascript
843
+ bot.command('ai_diagnose', async (ctx) => {
844
+ const report = RichMessage.create('๐Ÿค– <b>System Diagnosis</b>')
845
+ .thinking('Analyzing latency metrics across distributed clusters...')
846
+ .sectionHeading('Cluster Health Evaluation', 2)
847
+ .badge('Status', 'Nominal', '๐ŸŸข')
848
+ .badge('Load Average', '0.42', 'โšก')
849
+ .collage([
850
+ 'https://example.com/chart1.png',
851
+ 'https://example.com/chart2.png',
852
+ ])
853
+ .slideshow([
854
+ 'https://example.com/slide1.png',
855
+ 'https://example.com/slide2.png',
856
+ ]);
857
+
858
+ await ctx.replyWithRichMessage(report);
859
+ });
860
+ ```
861
+
710
862
  ### Static Factory Methods
711
863
 
712
864
  ```javascript
@@ -725,6 +877,18 @@ const draft = RichMessage.draft('Drafting text...', 12345);
725
877
 
726
878
  // Create an Ephemeral Message
727
879
  const expiring = RichMessage.ephemeral('Expiring note', 30);
880
+
881
+ // Create a Table Rich Message
882
+ const tableCard = RichMessage.table(['ID', 'Item', 'Price'], [
883
+ ['#1', 'Server Pro', '$49/mo'],
884
+ ['#2', 'Database Addon', '$19/mo'],
885
+ ]);
886
+
887
+ // Create a Compact Table Rich Message (Optimized for Mobile)
888
+ const compactCard = RichMessage.compactTable(['Crypto', 'Change'], [
889
+ ['BTC', '+5.4%'],
890
+ ['ETH', '+2.1%'],
891
+ ]);
728
892
  ```
729
893
 
730
894
  ### Complete Interactive Rich Card Example
@@ -765,6 +929,442 @@ bot.command('dashboard', async (ctx) => {
765
929
 
766
930
  ---
767
931
 
932
+ ## ๐Ÿ“Š Table & Grid Formatting Suite (`Table` & `InputRichBlockTable`)
933
+
934
+ Telegram does not have a native HTML `<table>` tag, meaning standard HTML tables fail to render. Telegix solves this by providing a comprehensive, zero-dependency **`Table`** formatting suite and native **Bot API 10.3 `InputRichBlockTable`** support.
935
+
936
+ Whether you need modern Telegram Bot card tables with rounded borders and column dividers, Unicode box borders, minimal compact lines for mobile screens, or markdown tables, Telegix formats and renders them seamlessly.
937
+
938
+ ### ๐Ÿ“ฑ Telegram Bot Card Tables (Rounded Card with Grid Dividers)
939
+
940
+ Modern Telegram bots frequently display dashboard and status metrics as **sleek card tables** featuring:
941
+ - ๐Ÿ”ฒ **Rounded Card Container** (`rx="12"`, `#18222d` background, `#2b3d4f` border)
942
+ - ๐Ÿ“ **Vertical Column Divider Line** cleanly separating labels (left) and values (right)
943
+ - โž– **Horizontal Row Divider Lines** between every item
944
+ - ๐Ÿท๏ธ **Header Banner** with distinct background (`#1c2836`) and bold title
945
+ - ๐Ÿ”ต **Telegram Blue Links** for handles (e.g. `@username`) and protocol URLs
946
+
947
+ ```javascript
948
+ import { Telegix, Table } from 'telegix';
949
+
950
+ const bot = new Telegix(process.env.BOT_TOKEN);
951
+
952
+ // Create a custom card table
953
+ const cardTable = Table.card(
954
+ ['๐Ÿ“ฆ SYSTEM', 'Status'],
955
+ [
956
+ ['Engine', 'Telegix'],
957
+ ['Runtime', '0h 19m 32s'],
958
+ ['Node', 'v23.11'],
959
+ ['Features', 514],
960
+ ['Groups', 168],
961
+ ['Users', 9528],
962
+ ]
963
+ );
964
+
965
+ // Method 1: Send directly with ctx helper
966
+ bot.command('status', async (ctx) => {
967
+ await ctx.replyWithTableCard(cardTable);
968
+ });
969
+
970
+ // Method 2: Send as vector card image
971
+ bot.command('card_img', async (ctx) => {
972
+ await ctx.replyWithTableCard(cardTable, [], { asImage: true });
973
+ });
974
+ ```
975
+
976
+ ### ๐Ÿค– Pre-Configured & Fully Customizable System & User Profile Cards
977
+
978
+ Telegix provides built-in card factories and context helpers for status monitoring and user profile displays with **full customization support**:
979
+
980
+ #### 1. Arbitrary Dynamic Fields
981
+ Pass any custom key-value pairs; Telegix automatically formats human-readable labels from keys (e.g. `ram_usage` -> `Ram Usage`, `db_cluster` -> `Db Cluster`):
982
+
983
+ ```javascript
984
+ // System Status with custom metrics
985
+ await ctx.replyWithSystemStatus({
986
+ engine: 'Telegix',
987
+ runtime: '3d 14h 28m',
988
+ node: process.version,
989
+ features: 514,
990
+ groups: 168,
991
+ users: 9528,
992
+ ram_usage: '142 MB / 1024 MB',
993
+ database: 'PostgreSQL 17',
994
+ active_cluster: 'Singapore-Node-1',
995
+ ping: '14ms',
996
+ });
997
+
998
+ // User Profile with custom fields
999
+ await ctx.replyWithUserProfile({
1000
+ username: '@alice_dev',
1001
+ status: 'VIP Elite Member',
1002
+ balance: '$250.00 USD',
1003
+ reward_points: 14500,
1004
+ api_quota: 'Unlimited',
1005
+ registered: 'September 2026',
1006
+ });
1007
+ ```
1008
+
1009
+ #### 2. Custom Header Title & Subtitle
1010
+ Customize the card header banner text:
1011
+
1012
+ ```javascript
1013
+ await ctx.replyWithSystemStatus({
1014
+ title: '๐Ÿ–ฅ๏ธ CLUSTER MONITOR',
1015
+ subtitle: 'Region Asia-Southeast1',
1016
+ engine: 'Telegix Engine',
1017
+ runtime: '12h 45m',
1018
+ memory_load: '32%',
1019
+ });
1020
+
1021
+ await ctx.replyWithUserProfile({
1022
+ title: '๐Ÿ‘‘ VIP MEMBERSHIP',
1023
+ subtitle: 'Tier 3 Account',
1024
+ username: '@username',
1025
+ status: 'Verified Developer',
1026
+ });
1027
+ ```
1028
+
1029
+ #### 3. Raw Structured 2D Array Matrix
1030
+ Supply exact rows without key formatting:
1031
+
1032
+ ```javascript
1033
+ await ctx.replyWithSystemStatus({
1034
+ title: '๐Ÿ“Š TELEMETRY',
1035
+ rows: [
1036
+ ['Cluster Pod', 'k8s-sg-node-01'],
1037
+ ['CPU Throttling', '0.00%'],
1038
+ ['Memory Pressure', 'Normal'],
1039
+ ],
1040
+ });
1041
+ ```
1042
+
1043
+ ### ๐Ÿ’Ž Multi-Card Stacking (`Table.multiCardSvg` & `ctx.replyWithCardTables`)
1044
+
1045
+ Stack multiple cards (such as SYSTEM and PROFILE) in a single message or render them unified:
1046
+
1047
+ ```javascript
1048
+ bot.command('dashboard', async (ctx) => {
1049
+ const sysCard = Table.systemStatus();
1050
+ const profileCard = Table.userProfile({
1051
+ username: ctx.from?.username ? `@${ctx.from.username}` : '@username',
1052
+ });
1053
+
1054
+ // Sends both cards stacked together cleanly in chat
1055
+ await ctx.replyWithCardTables([sysCard, profileCard]);
1056
+
1057
+ // Or send as a single unified high-definition graphic:
1058
+ // await ctx.replyWithCardTables([sysCard, profileCard], { asImage: true });
1059
+ });
1060
+ ```
1061
+
1062
+ ### Monospaced Text Tables (Box, ASCII, Compact, Markdown)
1063
+
1064
+ ```javascript
1065
+ import { Table } from 'telegix';
1066
+
1067
+ const headers = ['Symbol', 'Asset', 'Price', '24h'];
1068
+ const rows = [
1069
+ ['BTC', 'Bitcoin', '$64,250', '+3.2%'],
1070
+ ['ETH', 'Ethereum', '$3,480', '+1.8%'],
1071
+ ['SOL', 'Solana', '$142.50', '+5.9%'],
1072
+ ['TON', 'Toncoin', '$5.60', '+8.1%'],
1073
+ ];
1074
+
1075
+ // 1. Box Style (Unicode border: โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”)
1076
+ const boxTable = Table.box(headers, rows, {
1077
+ title: '๐Ÿ“ˆ Market Leaders',
1078
+ alignments: ['left', 'left', 'right', 'right'],
1079
+ });
1080
+
1081
+ // 2. Compact Style (Minimal divider, optimized for small mobile phone screens)
1082
+ const compactTable = Table.compact(headers, rows);
1083
+
1084
+ // 3. ASCII Style (Classic terminal style: +---+---+)
1085
+ const asciiTable = Table.ascii(headers, rows);
1086
+
1087
+ // 4. Markdown Style (GitHub flavored markdown table)
1088
+ const mdTable = Table.markdown(headers, rows);
1089
+
1090
+ // 5. HTML Pre-Formatted Helper (Wraps table in <pre> tags for ctx.reply)
1091
+ const htmlTable = new Table(headers, rows).toHtml({
1092
+ style: 'box',
1093
+ title: 'Cryptocurrency Rates',
1094
+ });
1095
+ ```
1096
+
1097
+ ### Direct Context Table Replies (`ctx.replyWithTable`)
1098
+
1099
+ Send beautiful formatted tables with a single function call:
1100
+
1101
+ ```javascript
1102
+ bot.command('rates', async (ctx) => {
1103
+ const headers = ['Plan', 'Storage', 'Price'];
1104
+ const rows = [
1105
+ ['Starter', '10 GB', '$5/mo'],
1106
+ ['Pro', '100 GB', '$15/mo'],
1107
+ ['Enterprise', '1 TB', '$49/mo'],
1108
+ ];
1109
+
1110
+ // Dispatches an HTML pre-formatted table wrapped in <pre>
1111
+ await ctx.replyWithTable(headers, rows, {
1112
+ style: 'box', // 'box' | 'compact' | 'ascii' | 'markdown'
1113
+ title: '๐Ÿ’พ Cloud Storage Plans',
1114
+ alignments: ['left', 'center', 'right'],
1115
+ });
1116
+ });
1117
+ ```
1118
+
1119
+ ### Generating Tables from Objects (`Table.fromObjects`)
1120
+
1121
+ Turn arbitrary JavaScript arrays of objects directly into tables without manual data mapping:
1122
+
1123
+ ```javascript
1124
+ const users = [
1125
+ { id: 101, name: 'Alice', role: 'Admin', score: 98 },
1126
+ { id: 102, name: 'Bob', role: 'Editor', score: 85 },
1127
+ { id: 103, name: 'Charlie', role: 'Viewer', score: 72 },
1128
+ ];
1129
+
1130
+ // Automatically extracts column names and values:
1131
+ const table = Table.fromObjects(users, ['id', 'name', 'role', 'score'], {
1132
+ style: 'compact',
1133
+ title: '๐Ÿ‘ฅ Team Directory',
1134
+ });
1135
+
1136
+ await ctx.reply(table.toHtml(), { parse_mode: 'HTML' });
1137
+ ```
1138
+
1139
+ ### Bot API 10.3 Native Rich Table Blocks
1140
+
1141
+ For clients supporting **Bot API 10.3** structured blocks, use `RichMessage.table()` or `InputRichBlockTable` directly:
1142
+
1143
+ ```javascript
1144
+ import { RichMessage, Markup } from 'telegix';
1145
+
1146
+ bot.command('leaderboard', async (ctx) => {
1147
+ const card = RichMessage.card('๐Ÿ† Tournament Standings', 'Season 4 Grand Finalists')
1148
+ .header('Top Scorers', '๐Ÿฅ‡')
1149
+ .table(
1150
+ ['Rank', 'Player', 'Score'],
1151
+ [
1152
+ ['1st', 'Alex', '4,850'],
1153
+ ['2nd', 'Beatrix', '4,720'],
1154
+ ['3rd', 'Carlos', '4,210'],
1155
+ ],
1156
+ { is_compact: true } // Bot API 10.3 is_compact flag
1157
+ )
1158
+ .divider()
1159
+ .row(
1160
+ Markup.button.primary('๐Ÿ”„ Refresh Standings', 'refresh_leaderboard'),
1161
+ Markup.button.url('๐ŸŒ Full Web Table', 'https://example.com/tournament')
1162
+ );
1163
+
1164
+ await ctx.replyWithRichMessage(card);
1165
+ });
1166
+ ```
1167
+
1168
+ ---
1169
+
1170
+ ## ๐Ÿ“ธ Live Photos Suite (Bot API 10.2+)
1171
+
1172
+ Telegram Bot API 10.2 introduced support for sending **Live Photos**โ€”interactive photos paired with micro-videos that animate when tapped and held in Telegram clients.
1173
+
1174
+ Telegix provides both context helper methods (`ctx.replyWithLivePhoto`) and low-level API client methods (`bot.telegram.sendLivePhoto`):
1175
+
1176
+ ```javascript
1177
+ import { Telegix } from 'telegix';
1178
+
1179
+ const bot = new Telegix(process.env.BOT_TOKEN);
1180
+
1181
+ // 1. Context Reply Shortcut: ctx.replyWithLivePhoto(photo, video, extra?)
1182
+ bot.command('livephoto', async (ctx) => {
1183
+ await ctx.replyWithLivePhoto(
1184
+ 'https://example.com/photo.jpg',
1185
+ 'https://example.com/live_motion.mp4',
1186
+ {
1187
+ caption: '๐Ÿ“ธ <b>Interactive Live Photo</b>\n<i>Tap and hold to play animation!</i>',
1188
+ parse_mode: 'HTML',
1189
+ }
1190
+ );
1191
+ });
1192
+
1193
+ // 2. Telegram API Client: bot.telegram.sendLivePhoto(chatId, photo, video, extra?)
1194
+ await bot.telegram.sendLivePhoto(
1195
+ chatId,
1196
+ 'https://example.com/photo.jpg',
1197
+ 'https://example.com/live_motion.mp4',
1198
+ { caption: 'Captured Live Moment' }
1199
+ );
1200
+ ```
1201
+
1202
+ ---
1203
+
1204
+ ## โ†ฉ๏ธ Extended Reply Parameters & Ephemeral Commands (Bot API 10.2+)
1205
+
1206
+ Telegram Bot API 10.2 expanded `ReplyParameters` and bot command configurations with specialized fields for fine-grained reply targets and message visibility.
1207
+
1208
+ ### 1. Extended ReplyParameters (`checklist_task_id`, `poll_option_id`, `is_ephemeral`)
1209
+
1210
+ You can now target specific checklist tasks, poll options, or designate replies as ephemeral:
1211
+
1212
+ ```javascript
1213
+ import { ReplyParameters } from 'telegix';
1214
+
1215
+ // Target a specific task item inside an interactive checklist
1216
+ bot.command('check_done', async (ctx) => {
1217
+ await ctx.reply('โœ… Task #2 marked completed!', {
1218
+ reply_parameters: {
1219
+ message_id: ctx.message?.message_id,
1220
+ checklist_task_id: 2, // Bot API 10.2+
1221
+ allow_sending_without_reply: true,
1222
+ },
1223
+ });
1224
+ });
1225
+
1226
+ // Target a specific option within a poll
1227
+ bot.command('poll_comment', async (ctx) => {
1228
+ await ctx.reply('Insightful vote on option #1!', {
1229
+ reply_parameters: new ReplyParameters({
1230
+ message_id: targetPollMessageId,
1231
+ poll_option_id: 'opt_1', // Bot API 10.2+
1232
+ }),
1233
+ });
1234
+ });
1235
+ ```
1236
+
1237
+ ### 2. Ephemeral Bot Commands (`BotCommand.is_ephemeral`)
1238
+
1239
+ Mark specific bot commands as ephemeral so their responses are only visible to the user who invoked them, keeping group conversations clean:
1240
+
1241
+ ```javascript
1242
+ import { BotCommand } from 'telegix';
1243
+
1244
+ const commands = [
1245
+ new BotCommand('start', 'Open main menu'),
1246
+ new BotCommand('help', 'Show help information'),
1247
+ new BotCommand('mybalance', 'Check personal balance privately', {
1248
+ is_ephemeral: true, // Bot API 10.2+
1249
+ }),
1250
+ ];
1251
+
1252
+ await bot.telegram.setMyCommands(commands);
1253
+ ```
1254
+
1255
+ ---
1256
+
1257
+ ## ๐Ÿ”ต Blue Text & Telegram Protocol Links (`tg://`, `documentLink`, `userLink`)
1258
+
1259
+ In Telegram chats, clickable links and protocol handlers are rendered in Telegram's signature **blue text color**. Telegix provides first-class helpers to generate these links cleanly across HTML, Markdown, and template literals:
1260
+
1261
+ ### Blue Document Links (`tg://document?id=...`)
1262
+
1263
+ Generate blue clickable download links pointing directly to Telegram document file IDs or catalog items without external web servers:
1264
+
1265
+ ```javascript
1266
+ import { fmt, html, markdown } from 'telegix';
1267
+
1268
+ // 1. Using HTML helper: html.documentLink(documentId, text)
1269
+ const docLinkHtml = html.documentLink('10987654321', '๐Ÿ“„ Download Financial Q3 Report (Blue Text)');
1270
+ // -> <a href="tg://document?id=10987654321">๐Ÿ“„ Download Financial Q3 Report (Blue Text)</a>
1271
+
1272
+ // 2. Using Markdown helper: markdown.documentLink(documentId, text)
1273
+ const docLinkMd = markdown.documentLink('10987654321', 'Download Specification');
1274
+ // -> [Download Specification](tg://document?id=10987654321)
1275
+
1276
+ // 3. Using Tagged Template Literal: fmt.documentLink
1277
+ bot.command('specs', async (ctx) => {
1278
+ await ctx.reply(
1279
+ fmt`
1280
+ ๐Ÿ“‹ <b>Project Specifications</b>
1281
+
1282
+ Click the blue document link below to open the file:
1283
+ ${fmt.documentLink('987654321', '๐Ÿ“„ View Architecture Blueprint')}
1284
+ `,
1285
+ { parse_mode: 'HTML' }
1286
+ );
1287
+ });
1288
+ ```
1289
+
1290
+ ### Blue User Mention Links (`tg://user?id=...`)
1291
+
1292
+ Generate blue profile links that open a user's Telegram profile card when tapped:
1293
+
1294
+ ```javascript
1295
+ import { html, fmt } from 'telegix';
1296
+
1297
+ bot.command('moderator', async (ctx) => {
1298
+ const modId = 123456789;
1299
+ const modName = 'Support Admin';
1300
+
1301
+ await ctx.reply(
1302
+ fmt`Need assistance? Contact our on-duty moderator: ${html.userLink(modId, modName)}`,
1303
+ { parse_mode: 'HTML' }
1304
+ );
1305
+ });
1306
+ ```
1307
+
1308
+ ### Blue Primary Buttons & Colored Buttons
1309
+
1310
+ Telegram Bot API 9.4+ introduced colored inline buttons. Use `Markup.button.primary()` to render prominent blue action buttons that match Telegram's blue link aesthetic:
1311
+
1312
+ ```javascript
1313
+ import { Markup } from 'telegix';
1314
+
1315
+ const blueKeyboard = Markup.inlineKeyboard([
1316
+ [
1317
+ Markup.button.primary('๐Ÿ”ต Primary Action (Blue)', 'btn_primary_click'),
1318
+ Markup.button.url('๐ŸŒ Blue Web Link', 'https://telegix.dev'),
1319
+ ],
1320
+ [
1321
+ Markup.button.colored('๐Ÿ“„ Document Protocol', 'primary', 'tg://document?id=12345'),
1322
+ ],
1323
+ ]);
1324
+
1325
+ await ctx.reply('Select an action:', blueKeyboard);
1326
+ ```
1327
+
1328
+ ---
1329
+
1330
+ ## โฑ๏ธ Ephemeral Messages & Auto-Disappearing Lifetimes (`EphemeralMessageParameters`)
1331
+
1332
+ Telegram Bot API 10.3 introduced **Ephemeral Messages** โ€” temporary messages configured with an automatic lifetime that vanish after the specified duration expires.
1333
+
1334
+ Telegix provides the `EphemeralMessageParameters` builder and native `ctx.replyEphemeral()` shortcut:
1335
+
1336
+ ```javascript
1337
+ import { EphemeralMessageParameters } from 'telegix';
1338
+
1339
+ // 1. Direct Context shortcut with duration in seconds:
1340
+ bot.command('secret', async (ctx) => {
1341
+ // Automatically self-destructs in 15 seconds
1342
+ await ctx.replyEphemeral('๐Ÿคซ This secret passcode will disappear in 15 seconds: 884-219', 15);
1343
+ });
1344
+
1345
+ // 2. Fluent EphemeralMessageParameters builder:
1346
+ bot.action('show_token', async (ctx) => {
1347
+ await ctx.answerCallbackQuery();
1348
+
1349
+ const params = EphemeralMessageParameters.create(30)
1350
+ .receiver(ctx.from.id) // Target specific user ID
1351
+ .callbackQuery(ctx.callbackQuery.id) // Bind to callback query
1352
+ .replaceCallbackQueryMessage(true); // Replace origin message
1353
+
1354
+ await ctx.replyEphemeral(
1355
+ '๐Ÿ”‘ <b>Single-Use Access Token:</b> <code>tok_99182a8bf3</code>\n<i>Disappears in 30s.</i>',
1356
+ params,
1357
+ { parse_mode: 'HTML' }
1358
+ );
1359
+ });
1360
+
1361
+ // 3. Edit or delete ephemeral messages:
1362
+ await ctx.editEphemeralMessageText('Updated ephemeral text');
1363
+ await ctx.deleteEphemeralMessage();
1364
+ ```
1365
+
1366
+ ---
1367
+
768
1368
  ## ๐Ÿšฆ Composer & Router Engine
769
1369
 
770
1370
  `Composer` powers the routing and middleware pipeline in Telegix.
@@ -958,6 +1558,10 @@ await ctx.reply('Interactive Post:', inline);
958
1558
  | `Markup.button.text(text)` | Standard reply keyboard text button. |
959
1559
  | `Markup.button.callback(text, data)` | Inline button triggering a callback query with `data`. |
960
1560
  | `Markup.button.url(text, url)` | Inline button opening an external URL. |
1561
+ | `Markup.button.primary(text, dataOrUrl)` | **Primary (Blue)** styled button for prominent calls to action (**Bot API 9.4+**). |
1562
+ | `Markup.button.danger(text, dataOrUrl)` | **Danger (Red)** styled button for destructive actions (**Bot API 9.4+**). |
1563
+ | `Markup.button.success(text, dataOrUrl)` | **Success (Green)** styled button for positive confirmations (**Bot API 9.4+**). |
1564
+ | `Markup.button.colored(text, style, dataOrUrl)` | Custom styled button with `'primary' \| 'danger' \| 'success'` style. |
961
1565
  | `Markup.button.webApp(text, url)` | Button launching a Telegram Mini App. |
962
1566
  | `Markup.button.copyText(text, textToCopy)` | Inline button that copies `textToCopy` to the clipboard. |
963
1567
  | `Markup.button.disabled(text)` | Disabled, non-clickable button (**Bot API 10.3**). |
@@ -975,6 +1579,50 @@ await ctx.reply('Interactive Post:', inline);
975
1579
 
976
1580
  ---
977
1581
 
1582
+ ### ๐ŸŽจ Colored Buttons for Bots (Bot API 9.4+)
1583
+
1584
+ Telegram Bot API 9.4 introduced native visual styling for inline buttons, allowing developers to emphasize specific actions with colors:
1585
+
1586
+ - `primary`: Emphasized primary button (accent/blue styling)
1587
+ - `danger`: Destructive actions such as account deletion, bans, or cancelations (red styling)
1588
+ - `success`: Confirmations, approvals, and checkout completions (green styling)
1589
+
1590
+ You can use colored buttons with callback queries or URLs via `Markup.button` or the `RichMessage` builder:
1591
+
1592
+ ```javascript
1593
+ import { Markup, RichMessage } from 'telegix';
1594
+
1595
+ // 1. Using Markup.inlineKeyboard
1596
+ bot.command('confirm_delete', async (ctx) => {
1597
+ const keyboard = Markup.inlineKeyboard([
1598
+ [
1599
+ Markup.button.danger('๐Ÿ—‘๏ธ Delete Account', 'action_confirm_delete'),
1600
+ Markup.button.primary('Keep Account', 'action_cancel'),
1601
+ ],
1602
+ [
1603
+ Markup.button.success('๐Ÿ’ณ Upgrade to Pro', 'https://example.com/checkout'),
1604
+ ],
1605
+ ]);
1606
+
1607
+ await ctx.reply('โš ๏ธ Are you sure you want to delete your account permanently?', keyboard);
1608
+ });
1609
+
1610
+ // 2. Using RichMessageBuilder
1611
+ bot.command('order_status', async (ctx) => {
1612
+ const message = RichMessage.card('๐Ÿ“ฆ Order #98124', 'Order ready for dispatch')
1613
+ .header('Delivery Status', '๐Ÿšš')
1614
+ .badge('Status', 'Pending Signature')
1615
+ .row(
1616
+ Markup.button.success('โœ… Approve & Sign', 'approve_98124'),
1617
+ Markup.button.danger('โŒ Reject Order', 'reject_98124')
1618
+ );
1619
+
1620
+ await ctx.replyWithRichMessage(message);
1621
+ });
1622
+ ```
1623
+
1624
+ ---
1625
+
978
1626
  ### Removing Keyboards & Force Reply
979
1627
 
980
1628
  ```javascript
@@ -987,6 +1635,102 @@ await ctx.reply('Please enter your email address:', Markup.forceReply());
987
1635
 
988
1636
  ---
989
1637
 
1638
+ ## ๐ŸŒŠ Streaming Text for Bots (`streamText` & `streamDraft`)
1639
+
1640
+ Real-time streaming is essential for modern AI-driven conversational bots (e.g. Gemini, OpenAI, Claude) and live progress updates. Telegix provides two powerful streaming modes:
1641
+
1642
+ 1. **Real-Time Message Edit Streaming**: Sends an initial placeholder message and progressively updates it with incoming chunks using an intelligent throttling buffer to safely prevent Telegram `429 Too Many Requests` errors.
1643
+ 2. **Live Draft Streaming (Bot API 10.3+)**: Broadcasts ephemeral text chunks into the chat input bar via `sendMessageDraft` as typing occurs, then sends the finalized message once the stream completes.
1644
+
1645
+ ### Real-Time Message Edit Streaming
1646
+
1647
+ ```javascript
1648
+ import { Telegix, toTextStream } from 'telegix';
1649
+
1650
+ const bot = new Telegix(process.env.BOT_TOKEN);
1651
+
1652
+ // Custom token generator simulation
1653
+ async function* generateResponseTokens() {
1654
+ const words = 'Telegix provides blazing fast, zero-dependency streaming for modern Telegram bots.'.split(' ');
1655
+ for (const word of words) {
1656
+ yield `${word} `;
1657
+ await new Promise((resolve) => setTimeout(resolve, 150));
1658
+ }
1659
+ }
1660
+
1661
+ bot.command('generate', async (ctx) => {
1662
+ // Directly stream onto chat via ctx.streamText
1663
+ const result = await ctx.streamText(generateResponseTokens(), {
1664
+ initialMessage: '๐Ÿ’ญ Generating your answer...',
1665
+ intervalMs: 800, // Buffer updates to edit at most once every 800ms
1666
+ minDeltaChars: 15, // Only edit if at least 15 new characters arrived
1667
+ parse_mode: 'HTML',
1668
+ });
1669
+
1670
+ console.log(`Stream complete! Final message ID: ${result.message_id}`);
1671
+ });
1672
+ ```
1673
+
1674
+ ### Live Draft Streaming (Bot API 10.3+)
1675
+
1676
+ Live drafts display real-time streamed text directly in the chat preview or input box without producing edit notifications:
1677
+
1678
+ ```javascript
1679
+ bot.command('stream_draft', async (ctx) => {
1680
+ async function* aiStream() {
1681
+ yield 'Searching knowledge base...\n';
1682
+ await new Promise((r) => setTimeout(r, 600));
1683
+ yield 'Synthesizing response:\n';
1684
+ await new Promise((r) => setTimeout(r, 600));
1685
+ yield 'Everything is configured and running at optimal speeds!';
1686
+ }
1687
+
1688
+ // Stream preview as draft, then send final message
1689
+ await ctx.streamDraft(aiStream(), {
1690
+ intervalMs: 600,
1691
+ minDeltaChars: 10,
1692
+ });
1693
+ });
1694
+ ```
1695
+
1696
+ ### Streaming AI & LLM Responses (Gemini, OpenAI, Generators)
1697
+
1698
+ Telegix automatically accepts any `AsyncIterable`, `ReadableStream`, Generator, Array, or String:
1699
+
1700
+ ```javascript
1701
+ import { GoogleGenAI } from '@google/genai';
1702
+
1703
+ const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
1704
+
1705
+ bot.command('ask', async (ctx) => {
1706
+ if (!ctx.payload) {
1707
+ return ctx.reply('Please provide a prompt! Example: /ask Explain quantum computing');
1708
+ }
1709
+
1710
+ // Create Gemini streaming response
1711
+ const responseStream = await ai.models.generateContentStream({
1712
+ model: 'gemini-2.5-flash',
1713
+ contents: ctx.payload,
1714
+ });
1715
+
1716
+ // Convert Gemini chunks to text stream
1717
+ async function* extractText(stream) {
1718
+ for await (const chunk of stream) {
1719
+ if (chunk.text) yield chunk.text;
1720
+ }
1721
+ }
1722
+
1723
+ await ctx.streamText(extractText(responseStream), {
1724
+ initialMessage: '๐Ÿค– Thinking...',
1725
+ intervalMs: 800,
1726
+ minDeltaChars: 20,
1727
+ parse_mode: 'HTML',
1728
+ });
1729
+ });
1730
+ ```
1731
+
1732
+ ---
1733
+
990
1734
  ## ๐Ÿ’ฌ Asynchronous Conversations & Wizard Scenes
991
1735
 
992
1736
  ### Interactive Inline Prompts (`await ctx.prompt`)
@@ -1225,6 +1969,110 @@ bot.command('md', async (ctx) => {
1225
1969
 
1226
1970
  ---
1227
1971
 
1972
+ ## ๐Ÿ“œ Collapsible Quotes (`fmt`, `mdv2`, `RichMessage`)
1973
+
1974
+ Telegram supports expandable/collapsible blockquotes (`<blockquote expandable>`), allowing users to tuck away long logs, detailed terms of service, technical stack traces, or FAQ answers behind a clean toggle.
1975
+
1976
+ Telegix provides first-class helpers across HTML, MarkdownV2, the `Context` object, and the `RichMessage` builder:
1977
+
1978
+ ### 1. HTML Formatting (`fmt.collapsibleQuote` / `html.expandableQuote`)
1979
+
1980
+ ```javascript
1981
+ import { fmt } from 'telegix';
1982
+
1983
+ bot.command('faq', async (ctx) => {
1984
+ const answer = fmt`
1985
+ <b>Frequently Asked Questions:</b>
1986
+
1987
+ ${fmt.collapsibleQuote('Here is a very long, comprehensive answer explaining step-by-step how to integrate Telegix with your custom backend infrastructure...')}
1988
+ `;
1989
+
1990
+ await ctx.reply(answer, { parse_mode: 'HTML' });
1991
+ });
1992
+ ```
1993
+
1994
+ ### 2. Context Shortcut (`ctx.replyWithCollapsibleQuote`)
1995
+
1996
+ ```javascript
1997
+ bot.command('terms', async (ctx) => {
1998
+ await ctx.replyWithCollapsibleQuote(
1999
+ '1. All user data is encrypted end-to-end.\n2. No telemetry is gathered without consent.\n3. Pure JavaScript runtime guarantees zero binary bloat.',
2000
+ '๐Ÿ“‹ <b>Terms of Service</b> (Tap to expand):'
2001
+ );
2002
+ });
2003
+ ```
2004
+
2005
+ ### 3. MarkdownV2 Formatting (`mdv2.collapsibleQuote`)
2006
+
2007
+ ```javascript
2008
+ import { mdv2 } from 'telegix';
2009
+
2010
+ bot.command('logs', async (ctx) => {
2011
+ const hiddenLogs = mdv2.collapsibleQuote('Error: Connection timed out at line 42 in server.ts');
2012
+ await ctx.reply(hiddenLogs, { parse_mode: 'MarkdownV2' });
2013
+ });
2014
+ ```
2015
+
2016
+ ### 4. RichMessage Builder (`collapsibleQuote` / `expandableQuote`)
2017
+
2018
+ ```javascript
2019
+ import { RichMessage } from 'telegix';
2020
+
2021
+ bot.command('patchnotes', async (ctx) => {
2022
+ const card = RichMessage.card('โšก Release v1.1.0', 'Modern Telegram Bot API updates')
2023
+ .header('Changelog Details', '๐Ÿš€')
2024
+ .collapsibleQuote('โ€ข Added Streaming Text engine\nโ€ข Added Colored Buttons\nโ€ข Added Mini App Fullscreen & Motion\nโ€ข Added Adjustable Link Previews');
2025
+
2026
+ await ctx.replyWithRichMessage(card);
2027
+ });
2028
+ ```
2029
+
2030
+ ---
2031
+
2032
+ ## ๐Ÿ”— Adjustable Link Previews (`LinkPreview`)
2033
+
2034
+ Telegram Bot API 7.0+ replaced the legacy `disable_web_page_preview` flag with the granular `link_preview_options` object.
2035
+
2036
+ Telegix provides the fluent `LinkPreview` builder to control whether media appears above or below text, display large image cards or compact thumbnails, or override preview URLs:
2037
+
2038
+ ```javascript
2039
+ import { LinkPreview } from 'telegix';
2040
+
2041
+ // 1. Fluent Builder pattern
2042
+ bot.command('preview_custom', async (ctx) => {
2043
+ const preview = LinkPreview.create('https://telegix.dev')
2044
+ .largeMedia() // Display large prominent card
2045
+ .aboveText() // Position preview above text
2046
+ .toJSON();
2047
+
2048
+ await ctx.reply('Check out the official documentation:', {
2049
+ link_preview_options: preview,
2050
+ });
2051
+ });
2052
+
2053
+ // 2. Direct Context Helper: ctx.replyWithLinkPreview
2054
+ bot.command('docs', async (ctx) => {
2055
+ await ctx.replyWithLinkPreview(
2056
+ 'Explore the Telegix GitHub repository:',
2057
+ LinkPreview.small('https://github.com/telegix/telegix', true) // Small thumbnail, above text
2058
+ );
2059
+ });
2060
+
2061
+ // 3. Static helper factories
2062
+ LinkPreview.disabled(); // Completely disables preview ({ is_disabled: true })
2063
+ LinkPreview.small('https://t.me'); // Shrinks media to small thumbnail
2064
+ LinkPreview.large('https://t.me'); // Expands media to large header card
2065
+ LinkPreview.above('https://t.me'); // Positions preview above message text
2066
+ LinkPreview.below('https://t.me'); // Positions preview below message text
2067
+
2068
+ // 4. Automatic normalization in all sendMessage / editMessageText calls
2069
+ await bot.telegram.sendMessage(chatId, 'https://example.com', {
2070
+ link_preview_options: LinkPreview.large('https://example.com'),
2071
+ });
2072
+ ```
2073
+
2074
+ ---
2075
+
1228
2076
  ## ๐Ÿ’ณ Payments, Invoices & Telegram Stars (`InvoiceBuilder`)
1229
2077
 
1230
2078
  Create and dispatch invoices for fiat currencies or **Telegram Stars (`XTR`)**:
@@ -1267,25 +2115,180 @@ bot.on('successful_payment', async (ctx) => {
1267
2115
 
1268
2116
  ---
1269
2117
 
1270
- ## ๐Ÿ“ฑ Telegram Mini Apps / WebApps (`validateWebAppInitData`)
2118
+ ## ๐Ÿ“ฑ Telegram Mini Apps Suite (`MiniApp` & Utilities)
2119
+
2120
+ Telegix provides a complete end-to-end toolkit for Telegram Mini Apps (TMAs), encompassing both **backend cryptographic validation / message preparation** and **client-side WebApp SDK bridging** for modern features like full-screen mode, 3D device motion tracking, and theme-adaptive loading screens.
1271
2121
 
1272
- Cryptographically verify Mini App authentication payloads using HMAC-SHA256:
2122
+ ### Mini App Authentication (`validateWebAppInitData`)
2123
+
2124
+ Verify incoming Mini App authentication requests securely on your server using Telegram's HMAC-SHA256 signature protocol:
1273
2125
 
1274
2126
  ```javascript
1275
2127
  import { validateWebAppInitData, parseWebAppInitData } from 'telegix';
1276
2128
 
1277
- // Inside your backend API route (e.g. Express / Fastify)
1278
- app.post('/api/auth/validate', (req, res) => {
2129
+ // Express / Fastify / Node.js HTTP backend route:
2130
+ app.post('/api/tma/auth', (req, res) => {
1279
2131
  const { initData } = req.body;
1280
- const isValid = validateWebAppInitData(initData, process.env.BOT_TOKEN, 86400); // 24h expiration
2132
+
2133
+ // Cryptographically verifies hash with your bot token
2134
+ const isValid = validateWebAppInitData(initData, process.env.BOT_TOKEN, {
2135
+ maxAgeSeconds: 86400, // Reject if older than 24 hours
2136
+ });
1281
2137
 
1282
2138
  if (!isValid) {
1283
- return res.status(401).json({ error: 'Invalid Telegram WebApp session' });
2139
+ return res.status(401).json({ error: 'Unauthorized Mini App session' });
1284
2140
  }
1285
2141
 
1286
- const parsed = parseWebAppInitData(initData);
1287
- return res.json({ success: true, user: parsed.user });
2142
+ // Parse user profile, auth_date, and query_id safely
2143
+ const session = parseWebAppInitData(initData);
2144
+ console.log(`Authenticated TMA User: ${session.user.first_name} (ID: ${session.user.id})`);
2145
+
2146
+ return res.json({ success: true, user: session.user });
2147
+ });
2148
+ ```
2149
+
2150
+ ### Launching Mini Apps from the Bot
2151
+
2152
+ ```javascript
2153
+ import { createMiniAppLaunchUrl, Markup } from 'telegix';
2154
+
2155
+ // 1. Generate Direct TMA Link
2156
+ const launchUrl = createMiniAppLaunchUrl('MyBot', 'shop', 'referrer_123');
2157
+ // -> https://t.me/MyBot/shop?startapp=referrer_123
2158
+
2159
+ // 2. Reply to users with a WebApp button directly
2160
+ bot.command('app', async (ctx) => {
2161
+ await ctx.replyWithWebApp(
2162
+ 'Welcome to our Mini App! Tap below to open:',
2163
+ 'https://my-app.example.com',
2164
+ '๐Ÿš€ Open WebApp'
2165
+ );
2166
+ });
2167
+ ```
2168
+
2169
+ ### Full-Screen Mode
2170
+
2171
+ Telegram Mini Apps can expand to occupy the complete display height, hiding Telegram's top chrome:
2172
+
2173
+ ```javascript
2174
+ import { MiniApp } from 'telegix';
2175
+
2176
+ // Inside your Mini App frontend (React, Vue, or Vanilla JS):
2177
+ if (MiniApp.isInsideTelegram()) {
2178
+ // Request full screen
2179
+ MiniApp.fullscreen.request();
2180
+
2181
+ // Listen for fullscreen state changes
2182
+ MiniApp.fullscreen.onChange((isFullscreen) => {
2183
+ console.log('Fullscreen active:', isFullscreen);
2184
+ });
2185
+
2186
+ // Handle failure / unsupported versions
2187
+ MiniApp.fullscreen.onFailed((err) => {
2188
+ console.warn('Fullscreen could not be enabled:', err);
2189
+ });
2190
+
2191
+ // Check current status
2192
+ console.log('Is currently fullscreen:', MiniApp.fullscreen.isActive());
2193
+ }
2194
+ ```
2195
+
2196
+ ### Device Motion Tracking (Accelerometer, Orientation, Gyroscope)
2197
+
2198
+ Build immersive 3D games, VR experiences, or tilt-controlled interfaces directly within Telegram Mini Apps:
2199
+
2200
+ ```javascript
2201
+ import { MiniApp } from 'telegix';
2202
+
2203
+ if (MiniApp.isInsideTelegram()) {
2204
+ // 1. Accelerometer (Linear acceleration in m/sยฒ)
2205
+ MiniApp.motion.startAccelerometer({ refresh_rate: 20 });
2206
+ MiniApp.motion.onAccelerometer(({ x, y, z }) => {
2207
+ console.log(`Acceleration -> X: ${x.toFixed(2)}, Y: ${y.toFixed(2)}, Z: ${z.toFixed(2)}`);
2208
+ });
2209
+
2210
+ // 2. Device Orientation (Rotation in degrees)
2211
+ MiniApp.motion.startDeviceOrientation({ need_absolute: true });
2212
+ MiniApp.motion.onOrientation(({ alpha, beta, gamma, absolute }) => {
2213
+ console.log(`Tilt -> Alpha: ${alpha}, Beta (Pitch): ${beta}, Gamma (Roll): ${gamma}`);
2214
+ });
2215
+
2216
+ // 3. Gyroscope (Angular velocity in rad/s)
2217
+ MiniApp.motion.startGyroscope();
2218
+ MiniApp.motion.onGyroscope(({ x, y, z }) => {
2219
+ console.log(`Gyro -> X: ${x}, Y: ${y}, Z: ${z}`);
2220
+ });
2221
+ }
2222
+ ```
2223
+
2224
+ ### Custom Loading Screen Generator (`MiniAppLoadingScreen`)
2225
+
2226
+ Deliver a polished, native launch experience while your frontend bundles load with theme-adaptive styles:
2227
+
2228
+ ```javascript
2229
+ import { MiniAppLoadingScreen, generateMiniAppLoadingScreen } from 'telegix';
2230
+
2231
+ // 1. Generate full HTML loading splash
2232
+ const loadingHtml = generateMiniAppLoadingScreen({
2233
+ title: 'My Telegram WebApp',
2234
+ icon: 'https://my-app.example.com/logo.png',
2235
+ lightColor: '#2481cc',
2236
+ darkColor: '#53a8ff',
2237
+ skeleton: true, // Includes placeholder skeleton cards
1288
2238
  });
2239
+
2240
+ // 2. Or configure using the fluent MiniAppLoadingScreen builder
2241
+ const screen = new MiniAppLoadingScreen({
2242
+ title: 'Loading SuperApp...',
2243
+ skeleton: true,
2244
+ })
2245
+ .setColors('#007AFF', '#0A84FF')
2246
+ .setIcon('https://example.com/app-icon.svg');
2247
+
2248
+ // Output raw CSS or full HTML splash
2249
+ const splashCss = screen.toCSS();
2250
+ const splashHtml = screen.toHTML();
2251
+ ```
2252
+
2253
+ ### Home Screen & Prepared Inline Messages
2254
+
2255
+ Enable users to install your Mini App onto their phone's home screen and share dynamic game achievements directly into Telegram chats:
2256
+
2257
+ ```javascript
2258
+ import { MiniApp } from 'telegix';
2259
+
2260
+ // 1. Add to Home Screen (PWA shortcut)
2261
+ MiniApp.homeScreen.addToHomeScreen();
2262
+ MiniApp.homeScreen.checkStatus((status) => {
2263
+ // 'unsupported' | 'unknown' | 'added' | 'missed'
2264
+ console.log('Home screen status:', status);
2265
+ });
2266
+
2267
+ // 2. Prepared Inline Messages (Bot API 8.0+)
2268
+ // In your bot backend:
2269
+ bot.command('share_score', async (ctx) => {
2270
+ const prepared = await ctx.savePreparedInlineMessage({
2271
+ type: 'article',
2272
+ id: 'score_1',
2273
+ title: '๐Ÿ† High Score: 1,450 pts!',
2274
+ input_message_content: {
2275
+ message_text: '๐ŸŽฎ I just scored <b>1,450 points</b> in SuperApp! Can you beat me?',
2276
+ parse_mode: 'HTML',
2277
+ },
2278
+ });
2279
+
2280
+ // Send the prepared message ID to the Mini App frontend
2281
+ await ctx.reply(`Prepared Message ID: ${prepared.id}`);
2282
+ });
2283
+
2284
+ // In your Mini App frontend:
2285
+ // Triggers Telegram native chat selector to send the prepared message!
2286
+ MiniApp.sharePreparedMessage(preparedMessageId);
2287
+
2288
+ // 3. Native File Downloads & Haptic Feedback
2289
+ MiniApp.downloadFile({ url: 'https://example.com/receipt.pdf', file_name: 'receipt.pdf' });
2290
+ MiniApp.haptics.impact('medium');
2291
+ MiniApp.haptics.notification('success');
1289
2292
  ```
1290
2293
 
1291
2294
  ---
@@ -1405,76 +2408,99 @@ bot.on('inline_query', async (ctx) => {
1405
2408
 
1406
2409
  The `Telegram` client exposes every official method of the Telegram Bot API:
1407
2410
 
2411
+ ### Updates & Webhooks
2412
+ - `getUpdates(options?)` โ€” Receive incoming updates using long polling.
2413
+ - `setWebhook(url, options?)` โ€” Specify a URL and receive incoming updates via outgoing webhook.
2414
+ - `deleteWebhook(options?)` โ€” Remove webhook integration.
2415
+ - `getWebhookInfo()` โ€” Get current webhook status.
2416
+
1408
2417
  ### Account & Identity
1409
- - `getMe()` โ€” Retrieve bot identity information.
2418
+ - `getMe()` โ€” Retrieve bot identity information (ID, username, can join groups, etc.).
1410
2419
  - `logOut()` / `close()` โ€” Log out from the cloud Bot API or close the local bot instance.
1411
- - `getMyName(extra)` / `setMyName(name, extra)` โ€” Get or set bot name.
1412
- - `getMyDescription(extra)` / `setMyDescription(description, extra)` โ€” Get or set bot description.
1413
- - `getMyShortDescription(extra)` / `setMyShortDescription(shortDescription, extra)` โ€” Get or set short description.
1414
- - `getMyCommands(extra)` / `setMyCommands(commands, extra)` / `deleteMyCommands(extra)` โ€” Manage bot command menu list.
1415
- - `getMyDefaultAdministratorRights(extra)` / `setMyDefaultAdministratorRights(rights, extra)` โ€” Manage administrator rights.
1416
- - `getChatMenuButton(extra)` / `setChatMenuButton(extra)` โ€” Manage the chat menu button.
2420
+ - `getMyName(extra?)` / `setMyName(name, extra?)` โ€” Get or set bot name.
2421
+ - `getMyDescription(extra?)` / `setMyDescription(description, extra?)` โ€” Get or set bot description.
2422
+ - `getMyShortDescription(extra?)` / `setMyShortDescription(shortDescription, extra?)` โ€” Get or set short description.
2423
+ - `getMyCommands(extra?)` / `setMyCommands(commands, extra?)` / `deleteMyCommands(extra?)` โ€” Manage bot command menu list.
2424
+ - `getMyDefaultAdministratorRights(extra?)` / `setMyDefaultAdministratorRights(rights, extra?)` โ€” Manage administrator rights.
2425
+ - `getChatMenuButton(extra?)` / `setChatMenuButton(extra?)` โ€” Manage the chat menu button.
1417
2426
 
1418
2427
  ### Messages & Media Sending
1419
- - `sendMessage(chatId, text, extra)`
1420
- - `forwardMessage(chatId, fromChatId, messageId, extra)` / `forwardMessages(chatId, fromChatId, messageIds, extra)`
1421
- - `copyMessage(chatId, fromChatId, messageId, extra)` / `copyMessages(chatId, fromChatId, messageIds, extra)`
1422
- - `sendPhoto(chatId, photo, extra)`
1423
- - `sendAudio(chatId, audio, extra)`
1424
- - `sendDocument(chatId, document, extra)`
1425
- - `sendVideo(chatId, video, extra)`
1426
- - `sendAnimation(chatId, animation, extra)`
1427
- - `sendVoice(chatId, voice, extra)`
1428
- - `sendVideoNote(chatId, videoNote, extra)`
1429
- - `sendPaidMedia(chatId, starCount, media, extra)`
1430
- - `sendMediaGroup(chatId, media, extra)`
1431
- - `sendLocation(chatId, latitude, longitude, extra)`
1432
- - `sendVenue(chatId, latitude, longitude, title, address, extra)`
1433
- - `sendContact(chatId, phoneNumber, firstName, extra)`
1434
- - `sendPoll(chatId, question, options, extra)`
1435
- - `sendDice(chatId, extra)`
1436
- - `sendChatAction(chatId, action, extra)`
1437
- - `setMessageReaction(chatId, messageId, reaction, extra)`
1438
- - `sendSticker(chatId, sticker, extra)`
1439
- - `sendGame(chatId, gameShortName, extra)`
1440
- - `sendInvoice(chatId, title, description, payload, currency, prices, extra)`
1441
- - `sendGift(userId, giftId, extra)`
1442
- - `sendEphemeralMessage(chatId, text, ephemeralParameters, extra)`
1443
- - `sendMessageDraft(chatId, text, extra)`
1444
- - `sendRichMessage(chatId, richMessage, extra)`
1445
- - `sendRichMessageDraft(chatId, draft, extra)`
2428
+ - `sendMessage(chatId, text, extra?)`
2429
+ - `forwardMessage(chatId, fromChatId, messageId, extra?)` / `forwardMessages(chatId, fromChatId, messageIds, extra?)`
2430
+ - `copyMessage(chatId, fromChatId, messageId, extra?)` / `copyMessages(chatId, fromChatId, messageIds, extra?)`
2431
+ - `sendPhoto(chatId, photo, extra?)`
2432
+ - `sendLivePhoto(chatId, photo, video, extra?)` โ€” Send dynamic interactive Live Photo (**Bot API 10.2+**).
2433
+ - `sendAudio(chatId, audio, extra?)`
2434
+ - `sendDocument(chatId, document, extra?)`
2435
+ - `sendVideo(chatId, video, extra?)`
2436
+ - `sendAnimation(chatId, animation, extra?)`
2437
+ - `sendVoice(chatId, voice, extra?)`
2438
+ - `sendVideoNote(chatId, videoNote, extra?)`
2439
+ - `sendPaidMedia(chatId, starCount, media, extra?)`
2440
+ - `sendMediaGroup(chatId, media, extra?)`
2441
+ - `sendLocation(chatId, latitude, longitude, extra?)`
2442
+ - `sendVenue(chatId, latitude, longitude, title, address, extra?)`
2443
+ - `sendContact(chatId, phoneNumber, firstName, extra?)`
2444
+ - `sendPoll(chatId, question, options, extra?)`
2445
+ - `sendDice(chatId, extra?)`
2446
+ - `sendChatAction(chatId, action, extra?)`
2447
+ - `setMessageReaction(chatId, messageId, reaction, extra?)`
2448
+ - `sendSticker(chatId, sticker, extra?)`
2449
+ - `sendGame(chatId, gameShortName, extra?)`
2450
+ - `sendInvoice(chatId, title, description, payload, currency, prices, extra?)`
2451
+ - `sendGift(userId, giftId, extra?)`
2452
+ - `sendEphemeralMessage(chatId, text, ephemeralParameters, extra?)`
2453
+ - `sendMessageDraft(chatId, text, extra?)`
2454
+ - `sendRichMessage(chatId, richMessage, extra?)`
2455
+ - `sendRichMessageDraft(chatId, draft, extra?)`
2456
+
2457
+ ### Streaming & Real-Time Engines
2458
+ - `streamText(chatId, textStream, options?)` โ€” Stream real-time tokens with adaptive edit throttling.
2459
+ - `streamDraft(chatId, textStream, options?)` โ€” Stream real-time message drafts into chat preview.
1446
2460
 
1447
2461
  ### Messages Editing & Deletion
1448
- - `editMessageText(chatId, messageId, inlineMessageId, text, extra)`
1449
- - `editMessageCaption(chatId, messageId, inlineMessageId, caption, extra)`
1450
- - `editMessageMedia(chatId, messageId, inlineMessageId, media, extra)`
1451
- - `editMessageReplyMarkup(chatId, messageId, inlineMessageId, replyMarkup, extra)`
1452
- - `editRichMessageText(chatId, messageId, richMessage, extra)`
1453
- - `editRichMessageCaption(chatId, messageId, caption, extra)`
2462
+ - `editMessageText(chatId, messageId, inlineMessageId, text, extra?)`
2463
+ - `editMessageCaption(chatId, messageId, inlineMessageId, caption, extra?)`
2464
+ - `editMessageMedia(chatId, messageId, inlineMessageId, media, extra?)`
2465
+ - `editMessageReplyMarkup(chatId, messageId, inlineMessageId, replyMarkup, extra?)`
2466
+ - `editRichMessageText(chatId, messageId, richMessage, extra?)`
2467
+ - `editRichMessageCaption(chatId, messageId, caption, extra?)`
1454
2468
  - `deleteMessage(chatId, messageId)`
1455
2469
  - `deleteMessages(chatId, messageIds)`
1456
- - `editMessageLiveLocation(latitude, longitude, extra)` / `stopMessageLiveLocation(extra)`
1457
- - `stopPoll(chatId, messageId, extra)`
2470
+ - `editMessageLiveLocation(latitude, longitude, extra?)` / `stopMessageLiveLocation(extra?)`
2471
+ - `stopPoll(chatId, messageId, extra?)`
2472
+
2473
+ ### Inline Mode & Mini Apps
2474
+ - `answerInlineQuery(inlineQueryId, results, extra?)`
2475
+ - `answerWebAppQuery(webAppQueryId, result)`
2476
+ - `savePreparedInlineMessage(userId, result, extra?)` โ€” Save prepared inline message for Mini App sharing (**Bot API 8.0+**).
2477
+
2478
+ ### Payments & Telegram Stars
2479
+ - `createInvoiceLink(title, description, payload, currency, prices, extra?)`
2480
+ - `answerShippingQuery(shippingQueryId, ok, extra?)`
2481
+ - `answerPreCheckoutQuery(preCheckoutQueryId, ok, extra?)`
2482
+ - `refundStarPayment(userId, telegramPaymentChargeId, extra?)`
2483
+ - `getStarTransactions(extra?)`
1458
2484
 
1459
2485
  ### Chat Moderation & Administration
1460
2486
  - `getChat(chatId)`
1461
2487
  - `getChatAdministrators(chatId)`
1462
2488
  - `getChatMemberCount(chatId)` / `getChatMembersCount(chatId)`
1463
2489
  - `getChatMember(chatId, userId)`
1464
- - `banChatMember(chatId, userId, extra)`
1465
- - `unbanChatMember(chatId, userId, extra)`
1466
- - `restrictChatMember(chatId, userId, permissions, extra)`
2490
+ - `banChatMember(chatId, userId, extra?)`
2491
+ - `unbanChatMember(chatId, userId, extra?)`
2492
+ - `restrictChatMember(chatId, userId, permissions, extra?)`
1467
2493
  - `promoteChatMember(chatId, userId, rights)`
1468
2494
  - `setChatAdministratorCustomTitle(chatId, userId, customTitle)`
1469
- - `setChatPermissions(chatId, permissions, extra)`
2495
+ - `setChatPermissions(chatId, permissions, extra?)`
1470
2496
  - `setChatTitle(chatId, title)`
1471
2497
  - `setChatDescription(chatId, description)`
1472
2498
  - `setChatPhoto(chatId, photo)` / `deleteChatPhoto(chatId)`
1473
- - `pinChatMessage(chatId, messageId, extra)` / `unpinChatMessage(chatId, messageId)` / `unpinAllChatMessages(chatId)`
2499
+ - `pinChatMessage(chatId, messageId, extra?)` / `unpinChatMessage(chatId, messageId)` / `unpinAllChatMessages(chatId)`
1474
2500
  - `leaveChat(chatId)`
1475
2501
  - `exportChatInviteLink(chatId)`
1476
- - `createChatInviteLink(chatId, extra)`
1477
- - `editChatInviteLink(chatId, inviteLink, extra)`
2502
+ - `createChatInviteLink(chatId, extra?)`
2503
+ - `editChatInviteLink(chatId, inviteLink, extra?)`
1478
2504
  - `revokeChatInviteLink(chatId, inviteLink)`
1479
2505
  - `approveChatJoinRequest(chatId, userId)`
1480
2506
  - `declineChatJoinRequest(chatId, userId)`
@@ -1485,9 +2511,22 @@ The `Telegram` client exposes every official method of the Telegram Bot API:
1485
2511
  - `getUserChatBoosts(chatId, userId)`
1486
2512
  - `getBusinessConnection(businessConnectionId)`
1487
2513
 
2514
+ ### Stickers & Custom Emojis
2515
+ - `getStickerSet(name)`
2516
+ - `getCustomEmojiStickers(customEmojiIds)`
2517
+ - `uploadStickerFile(userId, sticker, stickerFormat)`
2518
+ - `createNewStickerSet(userId, name, title, stickers, extra?)`
2519
+ - `addStickerToSet(userId, name, sticker)`
2520
+ - `setStickerPositionInSet(sticker, position)`
2521
+ - `deleteStickerFromSet(sticker)`
2522
+ - `setStickerSetThumbnail(name, userId, thumbnail, format)`
2523
+ - `setCustomEmojiStickerSetThumbnail(name, customEmojiId)`
2524
+ - `setStickerSetTitle(name, title)`
2525
+ - `deleteStickerSet(name)`
2526
+
1488
2527
  ### Forum Topics Management
1489
- - `createForumTopic(chatId, name, extra)`
1490
- - `editForumTopic(chatId, messageThreadId, extra)`
2528
+ - `createForumTopic(chatId, name, extra?)`
2529
+ - `editForumTopic(chatId, messageThreadId, extra?)`
1491
2530
  - `closeForumTopic(chatId, messageThreadId)`
1492
2531
  - `reopenForumTopic(chatId, messageThreadId)`
1493
2532
  - `deleteForumTopic(chatId, messageThreadId)`
@@ -1499,9 +2538,35 @@ The `Telegram` client exposes every official method of the Telegram Bot API:
1499
2538
  - `unhideGeneralForumTopic(chatId)`
1500
2539
 
1501
2540
  ### Managed Bot Access Settings (Bot API 10.3)
1502
- - `getManagedBotAccessSettings(userId, extra)`
1503
- - `setManagedBotAccessSettings(userId, settings, extra)`
1504
- - `getUserPersonalChatMessages(userId, extra)`
2541
+ - `getManagedBotAccessSettings(userId, extra?)`
2542
+ - `setManagedBotAccessSettings(userId, settings, extra?)`
2543
+ - `getUserPersonalChatMessages(userId, extra?)`
2544
+
2545
+ ---
2546
+
2547
+ ## ๐Ÿ’ก Example Scripts & Demos
2548
+
2549
+ The repository includes a rich collection of production-ready, executable examples in the [`examples/`](./examples) directory and in root `example.js`:
2550
+
2551
+ | Example File | Description |
2552
+ |---|---|
2553
+ | [`examples/18-live-photos-checklists-and-cards.js`](./examples/18-live-photos-checklists-and-cards.js) | **Bot API 10.2+ & Modern Features**: Live Photos (`replyWithLivePhoto`), interactive Checklists, AI thinking indicator, media collages & slideshows, custom status & user cards, and ephemeral commands. |
2554
+ | [`examples/17-tables-and-rich-messages.js`](./examples/17-tables-and-rich-messages.js) | **Tables, Blue Text & Bot API 10.3 Rich Messages**: Box/Compact/Markdown tables, `ctx.replyWithTable`, blue document & user links, and ephemeral messages. |
2555
+ | [`examples/14-bot-api-10.3-features.js`](./examples/14-bot-api-10.3-features.js) | **Bot API 10.3 Core Suite**: Rich messages, tables, drafts, managed bot settings, and disappearing messages. |
2556
+ | [`example.js`](./example.js) | **Comprehensive Interactive Test Suite**: Full-featured bot showcasing all capabilities with an interactive inline button menu. |
2557
+ | [`examples/01-basic-bot.js`](./examples/01-basic-bot.js) | Minimal starter bot with slash commands and text replies. |
2558
+ | [`examples/03-keyboard-markup.js`](./examples/03-keyboard-markup.js) | Custom reply keyboards, inline buttons, colored buttons, and WebApp buttons. |
2559
+ | [`examples/04-photo-media.js`](./examples/04-photo-media.js) | Sending photos, albums, audio, voice notes, and documents. |
2560
+ | [`examples/07-session-wizard.js`](./examples/07-session-wizard.js) | State persistence with memory & file session stores. |
2561
+ | [`examples/08-telegram-stars-payments.js`](./examples/08-telegram-stars-payments.js) | Invoices, digital goods, and Telegram Stars (`XTR`) payments. |
2562
+ | [`examples/12-scenes-wizard.js`](./examples/12-scenes-wizard.js) | Multi-step interactive conversation state machine (`WizardScene` & `Stage`). |
2563
+ | [`examples/13-formatting-fmt.js`](./examples/13-formatting-fmt.js) | XSS-safe tagged template literals (`fmt`), collapsible quotes, and entity escaping. |
2564
+ | [`examples/15-i18n-and-ratelimit.js`](./examples/15-i18n-and-ratelimit.js) | Multi-language localization and rolling-window rate limiting. |
2565
+
2566
+ To run any example:
2567
+ ```bash
2568
+ BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" node examples/17-tables-and-rich-messages.js
2569
+ ```
1505
2570
 
1506
2571
  ---
1507
2572
 
@@ -1531,4 +2596,16 @@ bot.command('count', async (ctx) => {
1531
2596
 
1532
2597
  ---
1533
2598
 
1534
- ---
2599
+ ## ๐Ÿงช Running Tests
2600
+
2601
+ Execute the automated test suite locally:
2602
+
2603
+ ```bash
2604
+ node test/test.js
2605
+ ```
2606
+
2607
+ ---
2608
+
2609
+ ## ๐Ÿ“„ License
2610
+
2611
+ MIT License ยฉ 2026 Michael Agam & Telegix Contributors.