soumyadeepdas/TbhRichBotPublic · Community Store Listing

Rich Message Demo [TBH]

ProfileTelegram
17 commands0 envUpdated 5d agoCreated Jul 16, 2026
Back to folder

commands/_richCode.js

javascript · 155 lines · click line # to share

1/**#command2name: /richCode3answer: 4keyboard: 5parse_mode: 6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12const html = `13<h1>Code & Preformatted Blocks</h1>14 15<p>This page demonstrates code formatting and preformatted blocks introduced in Bot API 10.1.</p>16 17<hr/>18 19<h3>Inline Code</h3>20<p>Use <code>sendRichMessage</code> to send rich messages and <code>sendRichMessageDraft</code> for streaming drafts.</p>21 22<hr/>23 24<h3>Basic Preformatted Block</h3>25<pre>26Line 127Line 228Line 329</pre>30 31<hr/>32 33<h3>JavaScript</h3>34<pre><code class="language-javascript">35function hello() {36  console.log('Hello World');37}38 39hello();40</code></pre>41 42<hr/>43 44<h3>Python</h3>45<pre><code class="language-python">46def greet(name):47    return f'Hello {name}'48 49print(greet('Telegram'))50</code></pre>51 52<hr/>53 54<h3>JSON</h3>55<pre><code class="language-json">56{57  "name": "Rich Messages",58  "version": "10.1",59  "enabled": true60}61</code></pre>62 63<hr/>64 65<h3>HTML</h3>66<pre><code class="language-html">67&lt;h1&gt;Hello World&lt;/h1&gt;68&lt;p&gt;Rich Message Example&lt;/p&gt;69</code></pre>70 71<hr/>72 73<h3>CSS</h3>74<pre><code class="language-css">75body {76  background: #ffffff;77  color: #000000;78}79</code></pre>80 81<hr/>82 83<h3>SQL</h3>84<pre><code class="language-sql">85SELECT *86FROM users87WHERE active = true;88</code></pre>89 90<hr/>91 92<h3>Code Inside Lists</h3>93<ol>94  <li>Call <code>sendRichMessageDraft</code></li>95  <li>Generate content</li>96  <li>Send <code>sendRichMessage</code></li>97</ol>98 99<hr/>100 101<h3>Code Inside Details</h3>102<details>103<summary>Expand Example</summary>104<pre><code class="language-javascript">105HTTP.post({106  url: api,107  body: payload108});109</code></pre>110</details>111 112<hr/>113 114<h3>Mixed Example</h3>115<p>Inline code like <code>chat.chatid</code> can be used together with large code blocks.</p>116<pre><code class="language-javascript">117var id = chat.chatid;118Bot.sendMessage(id.toString());119</code></pre>120 121<hr/>122 123<h3>Large Scrollable Code Block</h3>124<p>Very large code blocks automatically become horizontally scrollable when they exceed the available width.</p>125<pre><code class="language-javascript">126function sendRichMessageDemo() {127  const payload = { rich_message: { html: '&lt;h1&gt;Rich Message Demo&lt;/h1&gt;&lt;p&gt;This demonstrates extremely large code blocks that automatically become scrollable inside Telegram Rich Messages.&lt;/p&gt;' }, reply_markup: { inline_keyboard: [[{ text: 'Formatting', callback_data: '/richFormatting' }, { text: 'Math', callback_data: '/richMath' }, { text: 'Tables', callback_data: '/richTables' }, { text: 'Media', callback_data: '/richMedia' }, { text: 'Streaming', callback_data: '/richStreaming' }, { text: 'Complete Showcase', callback_data: '/richAll' }]] } };128 129  HTTP.post({130    url: 'https://api.telegram.org/botTOKEN/sendRichMessage',131    body: JSON.stringify(payload),132    headers: { 'Content-Type': 'application/json' }133  });134}135 136sendRichMessageDemo();137</code></pre>138 139<footer>Bot API 10.1 • Code & Preformatted Demo</footer>140`;141 142Api.call("editMessageText", {143  chat_id: chat.chatid,144  message_id: update.callback_query.message.message_id,145  rich_message: { html: html },146  reply_markup: {147    inline_keyboard: [148      [149        { text: "« Media", callback_data: "/richMedia" },150        { text: "Home", callback_data: "/start" },151        { text: "Large Docs »", callback_data: "/richBigDocs" }152      ]153    ]154  }155});