telegix 1.1.2 โ†’ 1.1.3

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)
@@ -85,6 +102,7 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
85
102
  - [Automatic Chat Action (`chatActionMiddleware`)](#automatic-chat-action-chatactionmiddleware)
86
103
  - [Inline Query Pagination (`paginateInlineQuery`)](#inline-query-pagination-paginateinlinequery)
87
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)
88
106
  - [๐ŸŸฆ TypeScript Support](#-typescript-support)
89
107
  - [๐Ÿงช Running Tests](#-running-tests)
90
108
  - [๐Ÿ“„ License](#-license)
@@ -95,8 +113,10 @@ Telegix is a high-performance, developer-friendly Telegram Bot API library built
95
113
 
96
114
  - **Pure JavaScript & Zero Runtime Dependencies**: Built entirely on native Web standards (`fetch`, `FormData`, `Blob`) with zero binary compilation and zero third-party packages.
97
115
  - **Dual Module Architecture**: Full, native compatibility with modern **ESM (`import`)** and **CommonJS (`require`)**.
98
- - **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`).
99
- - **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.
100
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.
101
121
  - **Asynchronous Inline Prompts**: Await user answers step-by-step with `const answer = await ctx.prompt('What is your name?')`.
102
122
  - **Multi-Step Wizard Scenes**: Structured conversation flows with `WizardScene` and `Stage` for complex interactive state machines.
@@ -457,6 +477,12 @@ await ctx.replyWithCollapsibleQuote('Full debug stack trace...', 'โš ๏ธ <b>Syst
457
477
  // Reply with button launching a Telegram Mini App
458
478
  await ctx.replyWithWebApp('Launch Dashboard:', 'https://app.example.com', '๐Ÿš€ Open App');
459
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
+
460
486
  // Save a prepared inline message for Mini App sharing (Bot API 8.0+)
461
487
  const prepared = await ctx.savePreparedInlineMessage({
462
488
  type: 'article',
@@ -513,6 +539,13 @@ await ctx.replyWithMediaGroup([
513
539
  { type: 'photo', media: 'https://example.com/photo2.jpg' },
514
540
  { type: 'video', media: 'https://example.com/video1.mp4' },
515
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
+ );
516
549
  ```
517
550
 
518
551
  ---
@@ -672,17 +705,28 @@ await ctx.unpinAllForumTopicMessages(ctx.topicId);
672
705
 
673
706
  ---
674
707
 
675
- ### 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)
676
709
 
677
710
  ```javascript
678
- import { RichMessage, Markup } from 'telegix';
711
+ import { RichMessage, Markup, ReplyParameters } from 'telegix';
712
+
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
+ );
679
719
 
680
- // 1. Send Rich Message (structured layout blocks with automatic fallback)
720
+ // 2. Send Rich Message (structured layout blocks with automatic fallback)
681
721
  const card = RichMessage.card('โšก Server Health Check', 'All systems operational.')
682
722
  .header('Cluster Status', '๐ŸŸข')
683
723
  .badge('CPU Load', '14%')
684
724
  .badge('Memory', '1.2 GB / 8.0 GB')
685
- .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
+ ])
686
730
  .expandableQuote('Rich messages provide structured block layouts.')
687
731
  .row(
688
732
  Markup.button.callback('๐Ÿ”„ Refresh', 'refresh_stats'),
@@ -691,23 +735,32 @@ const card = RichMessage.card('โšก Server Health Check', 'All systems operationa
691
735
 
692
736
  await ctx.replyWithRichMessage(card);
693
737
 
694
- // 2. Edit existing message with Rich Message
738
+ // 3. Edit existing message with Rich Message
695
739
  await ctx.editRichMessageText(card);
696
740
 
697
- // 3. Send Rich Message Draft
741
+ // 4. Send Rich Message Draft
698
742
  await ctx.sendRichMessageDraft(card);
699
743
 
700
- // 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)
701
745
  await ctx.sendMessageDraft('Bot is currently preparing your report...');
702
746
 
703
- // 5. Send Ephemeral Message (Message with automated lifetime)
747
+ // 6. Send Ephemeral Message (Message with automated lifetime)
704
748
  await ctx.sendEphemeralMessage('This message will automatically vanish in 15 seconds.', 15);
705
749
 
706
- // 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)
707
760
  const accessSettings = await ctx.getManagedBotAccessSettings(adminUserId);
708
761
  await ctx.setManagedBotAccessSettings({ allow_admin_override: true }, adminUserId);
709
762
 
710
- // 7. Get User Personal Chat Messages
763
+ // 9. Get User Personal Chat Messages
711
764
  const messages = await ctx.getUserPersonalChatMessages(targetUserId);
712
765
  ```
713
766
 
@@ -733,8 +786,20 @@ The `RichMessage` class allows you to construct modern, structured card layouts,
733
786
  | `.mention(text, userId)` | Adds an inline mention link for a Telegram user ID. |
734
787
  | `.list(items, bullet?)` | Formats an array of strings into a bulleted list. |
735
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=...`). |
736
800
  | `.badge(label, value, icon?)` | Adds a key-value metric badge item. |
737
801
  | `.divider()` | Inserts a clean visual separator line. |
802
+ | `.buttons(matrix)` | Appends a matrix of inline keyboard buttons as a block. |
738
803
  | `.row(...buttons)` | Appends a row of inline keyboard buttons. |
739
804
  | `.callback(text, data)` | Appends an inline callback query button. |
740
805
  | `.url(text, url)` | Appends an external URL link button. |
@@ -745,6 +810,55 @@ The `RichMessage` class allows you to construct modern, structured card layouts,
745
810
  | `.send(ctx)` | Sends the rich message using the active context. |
746
811
  | `.edit(ctx)` | Edits an existing message with this rich message. |
747
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
+
748
862
  ### Static Factory Methods
749
863
 
750
864
  ```javascript
@@ -763,6 +877,18 @@ const draft = RichMessage.draft('Drafting text...', 12345);
763
877
 
764
878
  // Create an Ephemeral Message
765
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
+ ]);
766
892
  ```
767
893
 
768
894
  ### Complete Interactive Rich Card Example
@@ -803,6 +929,442 @@ bot.command('dashboard', async (ctx) => {
803
929
 
804
930
  ---
805
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. `@seventynn`) 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: '@seventynn',
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}` : '@seventynn',
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
+
806
1368
  ## ๐Ÿšฆ Composer & Router Engine
807
1369
 
808
1370
  `Composer` powers the routing and middleware pipeline in Telegix.
@@ -1867,6 +2429,7 @@ The `Telegram` client exposes every official method of the Telegram Bot API:
1867
2429
  - `forwardMessage(chatId, fromChatId, messageId, extra?)` / `forwardMessages(chatId, fromChatId, messageIds, extra?)`
1868
2430
  - `copyMessage(chatId, fromChatId, messageId, extra?)` / `copyMessages(chatId, fromChatId, messageIds, extra?)`
1869
2431
  - `sendPhoto(chatId, photo, extra?)`
2432
+ - `sendLivePhoto(chatId, photo, video, extra?)` โ€” Send dynamic interactive Live Photo (**Bot API 10.2+**).
1870
2433
  - `sendAudio(chatId, audio, extra?)`
1871
2434
  - `sendDocument(chatId, document, extra?)`
1872
2435
  - `sendVideo(chatId, video, extra?)`
@@ -1981,6 +2544,32 @@ The `Telegram` client exposes every official method of the Telegram Bot API:
1981
2544
 
1982
2545
  ---
1983
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
+ ```
2570
+
2571
+ ---
2572
+
1984
2573
  ## ๐ŸŸฆ TypeScript Support
1985
2574
 
1986
2575
  Telegix comes with zero-config TypeScript type declarations included in `index.d.ts`:
@@ -2007,4 +2596,16 @@ bot.command('count', async (ctx) => {
2007
2596
 
2008
2597
  ---
2009
2598
 
2010
- ---
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.