@innovatorssoft/innovators-bot2 2.0.6 → 2.0.7

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.
@@ -0,0 +1,4 @@
1
+ # GitHub Funding Configuration
2
+ # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository
3
+
4
+ patreon: innovatorssoft7
package/README.md CHANGED
@@ -1,27 +1,46 @@
1
1
  # INNOVATORS SOFT WhatsApp Bot 2
2
2
 
3
+ <div align="center">
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/innovators-bot2?style=for-the-badge&logo=npm&color=CB3837)](https://www.npmjs.com/package/innovators-bot2)
6
+ [![NPM Downloads](https://img.shields.io/npm/dm/innovators-bot2?style=for-the-badge&logo=npm&color=3399CC)](https://www.npmjs.com/package/innovators-bot2)
7
+ [![Node.js Compatibility](https://img.shields.io/node/v/innovators-bot2?style=for-the-badge&logo=node.js&color=6cc24a)](https://nodejs.org/)
8
+ [![License](https://img.shields.io/npm/l/innovators-bot2?style=for-the-badge&color=00c2a8)](https://github.com/innovatorssoft/innovators-bot2/blob/main/LICENSE)
9
+ [![Discord Support](https://img.shields.io/badge/Discord-Join%20Chat-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/G3RfM6FDHS)
10
+
3
11
  A powerful WhatsApp client library that provides seamless integration between Baileys and WhatsApp-web.js style APIs. This library makes it easy to create WhatsApp bots and automation tools with a familiar interface.
4
12
 
13
+ ---
14
+
15
+ ### šŸ“Š Client Metrics & Feature Matrix
16
+
17
+ | šŸš€ ENGINE & CORE | šŸ” PRIVACY & SECURITY | šŸŽ›ļø USER INTERACTION |
18
+ | :--- | :--- | :--- |
19
+ | • **Baileys v7.x.x (Multi-Device)** | • **Auto LID-to-PN Resolution** | • **Interactive Buttons V2** |
20
+ | • **Agnostic Session Storage** | • **Built-in Anti-Delete Protection** | • **List and Carousel Cards** |
21
+ | • **Automatic Auto-Reconnection** | • **Presence (Typing/Recording)** | • **Persistent Message Store** |
22
+ | • **Text / Media Mention Arrays** | • **Privacy Management Controls** | • **Rich AI formatting (LaTeX/Tables)** |
23
+
24
+ </div>
25
+
5
26
  ## Community
6
27
 
7
- > Join our Discord server for support, updates, and discussions:
8
- > https://discord.gg/G3RfM6FDHS
28
+ # Join our **[Discord Server](https://discord.gg/G3RfM6FDHS)** for support, updates, and discussions
9
29
 
10
30
  ## Features
11
31
 
12
- - šŸš€ Easy to use, familiar WhatsApp-web.js style API
13
- - šŸ“± Multi-device support (Baileys v7.x.x)
14
- - šŸ’¬ Send and receive messages
15
- - ļæ½ Message reactions (add/remove emoji reactions)
16
- - ļæ½šŸ“ø Media handling (images, videos, documents)
17
- - ļæ½ Mentions support in text and media messages
18
- - ļæ½šŸ‘„ Group management
19
- - šŸ’¾ Message history and chat management
20
- - šŸ”„ Auto-reconnect functionality
21
- - šŸ“ Read receipts
22
- - šŸ” LID (Local Identifier) support for enhanced privacy
23
- - šŸ—‚ļø Signal repository store for LID/PN mapping
24
- - 🧩 Interactive buttons support for both text and media (URL or local file)
32
+ * šŸš€ **Familiar API** — Easy to use, WhatsApp-web.js style high-level interface.
33
+ * šŸ“± **Multi-Device Engine** — Powered by the robust Baileys v7.x.x library.
34
+ * šŸ’¬ **Messaging Suite** — Full send, receive, reply, and read receipt controls.
35
+ * šŸŽ­ **Message Reactions** — Add or remove emoji reactions in real-time.
36
+ * šŸ“ø **Media Handling** — Native support for images, videos, audio, documents, and stickers.
37
+ * šŸ‘„ **Group Management** — Invite links, participant roles (promote/demote), settings, and join requests.
38
+ * šŸ’¾ **Message Store Cache** — Auto-saved local store with Time-to-Live (TTL) configuration.
39
+ * šŸ”„ **Auto-Reconnect** — Automated back-off connection handler.
40
+ * šŸ” **LID System Support** — Fully resolves Local Identifiers to Phone Numbers post-decryption.
41
+ * šŸ“Š **Decrypted Poll Votes** — Real-time aggregation and vote event tracking.
42
+ * 🧩 **Interactive Messages** — V2 buttons, lists, copy-code, and combined Call-to-Action templates.
43
+ * šŸ¤– **Rich AI Formatting** — Meta AI-style tables, code snippets, and pre-rendered LaTeX albums.
25
44
 
26
45
  ## Installation
27
46
 
@@ -199,7 +218,44 @@ client.on('message-deleted', async (data) => {
199
218
  });
200
219
  ```
201
220
 
202
- ### 5. Group Management
221
+ ### 5. Poll Votes Decryption
222
+
223
+ Listen for real-time updates when users cast or change their votes on a poll you created. The votes are automatically decrypted, aggregated, and their internal LID JIDs are resolved to Phone Number JIDs!
224
+
225
+ ```javascript
226
+ client.on('poll-votes-update', async (data) => {
227
+ console.log(`\nšŸ“Š Poll Votes Updated in ${data.jid}!`);
228
+ console.log('Voter who cast/updated the vote:', data.voter);
229
+
230
+ // 1. Get original poll creation details (Question, Options, etc.)
231
+ const pollCreation = data.pollCreationMessage;
232
+ if (pollCreation && pollCreation.message) {
233
+ const pollMessage = pollCreation.message.pollCreationMessage ||
234
+ pollCreation.message.pollCreationMessageV2 ||
235
+ pollCreation.message.pollCreationMessageV3;
236
+
237
+ if (pollMessage) {
238
+ console.log('Question:', pollMessage.name);
239
+ console.log('Options:', pollMessage.options?.map(o => o.optionName) || []);
240
+ }
241
+ }
242
+
243
+ // 2. View accumulated vote breakdown & totals
244
+ let totalVotesCount = 0;
245
+ data.pollUpdate.forEach((option) => {
246
+ console.log(`- ${option.name}: ${option.voters.length} vote(s) ${JSON.stringify(option.voters)}`);
247
+ totalVotesCount += option.voters.length;
248
+ });
249
+ console.log('Total Votes Cast:', totalVotesCount);
250
+
251
+ // 3. Find the winning option
252
+ const winner = data.pollUpdate.reduce((prev, current) =>
253
+ prev.voters.length > current.voters.length ? prev : current);
254
+ console.log(`Winning Option: ${winner.name} with ${winner.voters.length} vote(s)`);
255
+ });
256
+ ```
257
+
258
+ ### 6. Group Management
203
259
 
204
260
  ```javascript
205
261
  // Get all groups
@@ -292,7 +348,7 @@ await client.toggleGroupEphemeral(groupId, 86400)
292
348
  await client.changeGroupAddMode(groupId, 'admin_add')
293
349
  ```
294
350
 
295
- ### 6. Privacy Management
351
+ ### 7. Privacy Management
296
352
 
297
353
  ```javascript
298
354
  // Block a user
@@ -344,7 +400,7 @@ await client.updateProfileStatus('Hello World!')
344
400
  await client.updateProfileName('My name')
345
401
  ```
346
402
 
347
- ### 7. Interactive Messages
403
+ ### 8. Interactive Messages
348
404
 
349
405
  #### Buttons
350
406
  ```javascript
@@ -540,7 +596,121 @@ await client.sendListV2(jid, {
540
596
  });
541
597
  ```
542
598
 
543
- ### 8. Typing & Presence Control
599
+ ### 9. Rich AI Messaging
600
+
601
+ Send Meta AI-style formatted responses like tables, lists, syntax-highlighted code blocks, and LaTeX expressions.
602
+
603
+ #### Send a Table
604
+ ```javascript
605
+ await client.sendTable(
606
+ jid,
607
+ 'Price List',
608
+ ['Item', 'Qty', 'Price'],
609
+ [
610
+ ['Apple', '3', '$1.50'],
611
+ ['Banana', '6', '$0.90']
612
+ ],
613
+ msg.raw, // quoted message
614
+ { headerText: 'Order Summary:', footer: 'Thank you!' }
615
+ );
616
+ ```
617
+
618
+ #### Send a Rich List
619
+ ```javascript
620
+ await client.sendRichList(
621
+ jid,
622
+ 'Available Commands',
623
+ ['!help', '!ping', '!menu', '!info'],
624
+ msg.raw, // quoted message
625
+ { headerText: 'Bot commands:', footer: 'Type any command' }
626
+ );
627
+ ```
628
+
629
+ #### Send a Code Block
630
+ ```javascript
631
+ await client.sendCodeBlock(
632
+ jid,
633
+ `console.log("Hello World");`,
634
+ msg.raw, // quoted message
635
+ { title: 'Example Code', language: 'javascript' }
636
+ );
637
+ ```
638
+
639
+ #### Send LaTeX Text
640
+ ```javascript
641
+ // Note: WhatsApp clients require a pre-rendered image URL to display LaTeX graphically.
642
+ // This method sends the raw LaTeX text which may be invisible without an image url.
643
+ // The quoted message parameter can be omitted by passing the options directly.
644
+ await client.sendLatex(
645
+ jid,
646
+ { text: 'Quadratic formula:', expressions: [{ latexExpression: 'x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}' }] }
647
+ );
648
+ ```
649
+
650
+ #### Send LaTeX with Image Rendering
651
+
652
+ Render a LaTeX expression to a PNG image using the online CodeCogs API, upload, and send.
653
+
654
+ ```javascript
655
+ // Send a LaTeX expression as an image with no caption
656
+ await client.sendLatexImage(jid, 'E=mc^2');
657
+
658
+ // Send a LaTeX expression with a custom caption (omitting quoted message)
659
+ await client.sendLatexImage(jid, {
660
+ formula: 'E=mc^2',
661
+ caption: 'Mass-Energy Equivalence'
662
+ });
663
+ ```
664
+
665
+ #### Send LaTeX Inline Images (Album)
666
+
667
+ Render multiple LaTeX expressions as an album message.
668
+
669
+ ```javascript
670
+ // Send LaTeX images as an album with the formula strings as captions (omitting quoted message)
671
+ await client.sendLatexInlineImage(jid, {
672
+ expressions: [
673
+ { latexExpression: '\\nabla \\cdot \\mathbf{E} = \\frac{\\rho}{\\varepsilon_0}' },
674
+ { latexExpression: '\\nabla \\times \\mathbf{B} = \\mu_0 \\mathbf{J} + \\mu_0\\varepsilon_0 \\frac{\\partial \\mathbf{E}}{\\partial t}' }
675
+ ],
676
+ caption: true // true: formula text as caption; string: overall custom caption; false/omit: no captions
677
+ });
678
+ ```
679
+
680
+ #### Fully Custom Rich AI Message
681
+ ```javascript
682
+ await client.sendRichMessage(
683
+ jid,
684
+ [
685
+ { messageType: 2, messageText: 'šŸ¤– *AI Response*' },
686
+ { messageType: 5, codeMetadata: { codeLanguage: 'python', codeBlocks: [{ highlightType: 1, codeContent: 'print("Hello")' }] } }
687
+ ],
688
+ msg.raw // quoted message
689
+ );
690
+ ```
691
+
692
+ #### Send Markdown
693
+ ```javascript
694
+ await client.sendMarkdown(
695
+ jid,
696
+ '# H1\n## H2\n==Highlighted==\n_Italics_ and **Bold**!',
697
+ msg.raw // quoted message (or null)
698
+ );
699
+ ```
700
+
701
+ #### Send Rich Response using sendMessage
702
+ ```javascript
703
+ // Text + syntax-highlighted code block
704
+ await client.sendMessage(jid, {
705
+ richResponse: {
706
+ text: 'Here is a JavaScript example:',
707
+ code: `const greet = (name) => {\n console.log('Hello, ' + name)\n}\ngreet('World')`,
708
+ language: 'javascript' // 'javascript' | 'typescript' | 'python' | 'js' | 'ts' | 'py'
709
+ }
710
+ });
711
+ ```
712
+
713
+ ### 10. Typing & Presence Control
544
714
 
545
715
  Use `createPresenceController` for manual or standalone typing/recording presence control — without needing the auto-reply system.
546
716
 
@@ -565,7 +735,7 @@ await typing.startRecording(jid, { duration: 3000 });
565
735
  await typing.stopAll();
566
736
  ```
567
737
 
568
- ### 9. Message History (Store)
738
+ ### 11. Message History (Store)
569
739
 
570
740
  The library includes a robust message store to keep track of chat history, even across reloads.
571
741
 
@@ -632,7 +802,7 @@ client.on('store-loaded', (info) => {
632
802
  });
633
803
  ```
634
804
 
635
- ### 10. Status / Story Posting
805
+ ### 12. Status / Story Posting
636
806
 
637
807
  Post text, image, video, and voice note statuses easily using the `sendStatus` method.
638
808
 
@@ -966,8 +1136,6 @@ try {
966
1136
  }
967
1137
  ```
968
1138
 
969
- ## Baileys v7.x.x LID Store Implementation
970
-
971
1139
  ### Overview
972
1140
 
973
1141
  This library fully supports Baileys v7.x.x LID (Local Identifier) system for enhanced privacy and WhatsApp's transition to username-based identification.
@@ -1249,12 +1417,15 @@ This project is licensed under the MIT License - see the LICENSE file for detail
1249
1417
 
1250
1418
  ## Credits
1251
1419
 
1252
- Developed by [Innovators Soft](https://facebook.com/innovatorssoft). Based on the [@itsukichan/baileys](https://github.com/itsukichann/baileys) library.
1420
+ Developed by [Innovators Soft](https://github.com/innovatorssoft). Based on the [@innovatorssoft/baileys](https://github.com/innovatorssoft/Baileys) library.
1253
1421
 
1254
1422
  # Special Thanks
1255
1423
  - [@whiskeysockets/baileys](https://github.com/whiskeysockets/Baileys)
1256
- - [@itsukichan](https://github.com/itsukichann)
1424
+ - [@innovatorssoft](https://github.com/innovatorssoft)
1257
1425
  - [All Contributors](https://github.com/innovatorssoft/Baileys/)
1258
1426
  - [@ZenboBot](https://discordbot.innovatorssoftpk.com/) - AI Powered Baileys Bot
1259
- # Sponsor Me
1260
- Buy me a coffee - [Innovators Soft](https://facebook.com/innovatorssoft)
1427
+ ## Support the Project
1428
+
1429
+ This project is completely free and open-source. If it saved you time or helped your business, consider supporting us!
1430
+
1431
+ [![Support on Patreon](https://img.shields.io/badge/Support-Patreon-FF424D?style=for-the-badge&logo=patreon&logoColor=white)](https://patreon.com/innovatorssoft7)
package/example.js CHANGED
@@ -1,4 +1,11 @@
1
- const { WhatsAppClient, STATUS_BACKGROUNDS, STATUS_FONTS } = require('./index')
1
+ const { WhatsAppClient,
2
+ STATUS_BACKGROUNDS,
3
+ STATUS_FONTS,
4
+ renderLatexToPng,
5
+ uploadUnencryptedToWA,
6
+ RichSubMessageType
7
+ } = require('./index')
8
+
2
9
  const qrcode = require('qrcode-terminal')
3
10
  const fs = require('fs');
4
11
  const readline = require('readline');
@@ -48,6 +55,7 @@ async function start() {
48
55
  sessionName: sessionDir,
49
56
  authmethod: authMethod,
50
57
  pairingPhoneNumber: pairingPhoneNumber,
58
+ ai: true, // Enable/Disable AI flag for outgoing messages (default: true)
51
59
  // Message store persistence configuration
52
60
  messageStoreFilePath: path.join(sessionDir, 'message-store.json'),
53
61
  autoSaveInterval: 5 * 60 * 1000, // Auto-save every 5 minutes
@@ -124,6 +132,37 @@ async function start() {
124
132
  console.log('Is Removed:', reaction.isRemoved)
125
133
  console.log('Message ID:', reaction.messageKey.id)
126
134
  })
135
+ client.on('poll-votes-update', async (data) => {
136
+ console.log('\nšŸ“Š Poll Votes Updated!');
137
+ console.log('Chat:', data.jid);
138
+ console.log('Voter:', data.voter);
139
+
140
+ // 1. Extract Poll Creation Message (Question, Options, etc.)
141
+ const pollCreation = data.pollCreationMessage;
142
+ if (pollCreation && pollCreation.message) {
143
+ const pollMessage = pollCreation.message.pollCreationMessage ||
144
+ pollCreation.message.pollCreationMessageV2 ||
145
+ pollCreation.message.pollCreationMessageV3;
146
+
147
+ if (pollMessage) {
148
+ console.log('\nšŸ“ Poll Creation Details:');
149
+ console.log('Question:', pollMessage.name);
150
+ console.log('Options:', pollMessage.options?.map(o => o.optionName) || []);
151
+ }
152
+ }
153
+
154
+ // 2. Extract voters array from pollUpdate
155
+ console.log('\nšŸ—³ļø Vote Breakdown:');
156
+ let totalVotesCount = 0;
157
+ data.pollUpdate.forEach((option) => {
158
+ console.log(`--> ${option.name}: ${option.voters.length} vote(s) ${JSON.stringify(option.voters)}`);
159
+ totalVotesCount += option.voters.length;
160
+ });
161
+ console.log(`--> Total Votes Cast: ${totalVotesCount}`);
162
+ const winner = data.pollUpdate.reduce((prev, current) =>
163
+ prev.voters.length > current.voters.length ? prev : current);
164
+ console.log(`--> The Winner Is ${winner.name} With ${winner.voters.length} votes`);
165
+ });
127
166
 
128
167
  client.on('call', (call) => {
129
168
  const callData = call[0]; // Get the first call object from the array
@@ -200,13 +239,23 @@ async function start() {
200
239
  // Mark the message as read
201
240
  await client.readMessage(msg.raw.key)
202
241
 
203
- const command = msg.body.toLowerCase().split(' ')[0]
204
- const args = msg.body.toLowerCase().split(' ').slice(1).join(' ')
242
+ const command = msg.body.split(' ')[0].toLowerCase()
243
+ const args = msg.body.split(' ').slice(1).join(' ')
205
244
 
206
245
  switch (command) {
207
246
  case '!ping':
208
247
  await client.sendMessage(msgFrom, 'Hello Pong! šŸŽŠ')
209
248
  break
249
+ case '!poll':
250
+ await client.sendMessage(msgFrom, '', {
251
+ poll: {
252
+ name: 'Which programming language do you like most?',
253
+ options: ['JavaScript', 'Python', 'C++', 'Java'],
254
+ selectableOptionsCount: 1,
255
+ messageId: 'poll1'
256
+ }
257
+ });
258
+ break
210
259
  case '!echo':
211
260
  if (args) {
212
261
  await client.sendMessage(msgFrom, args)
@@ -274,6 +323,18 @@ async function start() {
274
323
  }
275
324
  break
276
325
 
326
+ case '!urlimage':
327
+ try {
328
+ const integrationFormula = '\\dpi{900}\\int\\frac{1}{x}dx=\\ln\\left|x\\right|+C';
329
+ const mediaurl = `https://latex.codecogs.com/png.image?${encodeURIComponent(integrationFormula)}`;
330
+ await client.sendMedia(msgFrom, mediaurl, {
331
+ caption: 'Check out this image!'
332
+ })
333
+ } catch (error) {
334
+ await client.sendMessage(msgFrom, `Failed to send image from URL: ${error.message}`)
335
+ }
336
+ break
337
+
277
338
  case '!doc':
278
339
  if (fs.existsSync('./example.pdf')) {
279
340
  await client.sendDocument(msgFrom, './example.pdf', 'Check out this document!')
@@ -666,6 +727,17 @@ async function start() {
666
727
  `• !updatestatus <text> - Update profile status\n` +
667
728
  `• !updatename <text> - Update profile name\n\n` +
668
729
 
730
+ `*šŸ¤– Rich AI Messaging*\n` +
731
+ `• !table - Send a formatted table\n` +
732
+ `• !richlist - Send a bulleted list\n` +
733
+ `• !codeblock - Send a syntax-highlighted code snippet\n` +
734
+ `• !latex - Send LaTeX text\n` +
735
+ `• !lateximage - Send LaTeX image\n` +
736
+ `• !latexinlineimage - Send LaTeX inline image\n` +
737
+ `• !rich - Send demo rich message\n` +
738
+ `• !markdown - Send native markdown message\n` +
739
+ `• !richresponse - Send rich text with code block\n\n` +
740
+
669
741
  `*šŸŽ›ļø Templates & Buttons*\n` +
670
742
  `• !buttons - Button template\n` +
671
743
  `• !list - Scrollable list\n\n` +
@@ -718,6 +790,176 @@ async function start() {
718
790
  await client.sendMessage(msgFrom, help)
719
791
  break
720
792
 
793
+ case '!table':
794
+ await client.sendTable(
795
+ msgFrom,
796
+ 'Price List',
797
+ ['Item', 'Qty', 'Price'],
798
+ [
799
+ ['Apple', '3', '$1.50'],
800
+ ['Banana', '6', '$0.90'],
801
+ ['Cherry', '1', '$3.00']
802
+ ],
803
+ msg.raw,
804
+ { headerText: 'Here is your order summary:', footer: 'Thank you!' }
805
+ );
806
+ break;
807
+
808
+ case '!richlist':
809
+ await client.sendRichList(
810
+ msgFrom,
811
+ 'Available Commands',
812
+ ['!help', '!ping', '!menu', '!info'],
813
+ msg.raw,
814
+ { headerText: 'Bot commands:', footer: 'Type any command to use it.' }
815
+ );
816
+ break;
817
+
818
+ case '!codeblock':
819
+ await client.sendCodeBlock(
820
+ msgFrom,
821
+ `async function fetchData(url) {\n const res = await fetch(url)\n return res.json()\n}`,
822
+ msg.raw,
823
+ { title: 'šŸ“¦ Example – fetch helper', language: 'javascript', footer: 'Copy and paste into your project.' }
824
+ );
825
+ break;
826
+
827
+ case '!latex':
828
+ await client.sendLatex(
829
+ msgFrom,
830
+ { text: 'Quadratic formula:', expressions: [{ latexExpression: 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}' }] }
831
+ );
832
+ break;
833
+
834
+ case '!lateximage':
835
+ try {
836
+ await client.sendLatexImage(
837
+ msgFrom,
838
+ {
839
+ formula: 'E=mc^2',
840
+ caption: 'Mass-Energy Equivalence (DPI 600)'
841
+ }
842
+ );
843
+ } catch (error) {
844
+ return (error)
845
+ }
846
+ break;
847
+
848
+ case '!latexinlineimage':
849
+ try {
850
+ await client.sendLatexInlineImage(
851
+ msgFrom,
852
+ {
853
+ expressions: [
854
+ { latexExpression: 'e^{i\\pi} + 1 = 0' },
855
+ { latexExpression: '\\int_a^b x^2 \\, dx = \\frac{b^3 - a^3}{3}' },
856
+ { latexExpression: 'f(x) = \\sum_{n=0}^{\\infty} \\frac{f^{(n)}(a)}{n!} (x-a)^n' }
857
+ ],
858
+ caption: true // Use each LaTeX expression as the caption for its respective image in the album
859
+ }
860
+ );
861
+ } catch (error) {
862
+ return (error)
863
+ }
864
+ break;
865
+
866
+ case '!rich':
867
+ const richLatexExpr = 'E = mc^2';
868
+ const richPngBuf = await renderLatexToPng(richLatexExpr);
869
+ const richImageUrl = (await uploadUnencryptedToWA(richPngBuf.buffer, client.sock.waUploadToServer)).url;
870
+
871
+ await client.sendRichMessage(msgFrom, [
872
+ {
873
+ messageType: RichSubMessageType.TEXT,
874
+ messageText: '# H1\n## H2\n### H3\n#### H4\n##### H5\n###### H6\n\n___\n\n> To use a horizontal line, you need to have two "\\n" above and below the "___"\n==Highlighted text==\n# By the way, ^you^ can _mix_ ==multiple markdowns== for a **richer response**\n###### Try different combinations...'
875
+ },
876
+ {
877
+ messageType: RichSubMessageType.TABLE,
878
+ tableMetadata: {
879
+ title: 'Product Prices',
880
+ rows: [
881
+ { items: ['Product', 'Price', 'Stock'], isHeading: true },
882
+ { items: ['Innovators Baileys Pro', '$49.99', 'In Stock'] },
883
+ { items: ['Rust WASM Plugin', '$19.99', 'Low Stock'] }
884
+ ]
885
+ }
886
+ },
887
+ {
888
+ messageType: RichSubMessageType.TEXT,
889
+ messageText: 'LaTeX Formula:'
890
+ },
891
+ {
892
+ messageType: RichSubMessageType.INLINE_IMAGE,
893
+ imageMetadata: {
894
+ imageUrl: {
895
+ imagePreviewUrl: richImageUrl,
896
+ imageHighResUrl: richImageUrl
897
+ },
898
+ imageText: richLatexExpr,
899
+ alignment: 2
900
+ }
901
+ },
902
+ {
903
+ messageType: RichSubMessageType.CODE,
904
+ codeMetadata: {
905
+ codeLanguage: 'javascript',
906
+ codeBlocks: [
907
+ { highlightType: 1, codeContent: 'const ' },
908
+ { highlightType: 0, codeContent: 'price = ' },
909
+ { highlightType: 4, codeContent: '49.99' },
910
+ { highlightType: 0, codeContent: ';\n' },
911
+ { highlightType: 1, codeContent: 'if ' },
912
+ { highlightType: 0, codeContent: '(price > ' },
913
+ { highlightType: 4, codeContent: '20' },
914
+ { highlightType: 0, codeContent: ') {\n console.log(' },
915
+ { highlightType: 3, codeContent: '"Premium tier"' },
916
+ { highlightType: 0, codeContent: ');\n}' }
917
+ ]
918
+ }
919
+ }
920
+ ], null, { useMarkdown: true });
921
+ break;
922
+
923
+ case '!markdown':
924
+ await client.sendMarkdown(
925
+ msgFrom,
926
+ '# Markdown Demo\n## Headers work\n==Highlighted text==\n_Italics_ and **Bold** are supported!',
927
+ msg.raw
928
+ );
929
+ break;
930
+
931
+ case '!richresponse':
932
+ // Demonstrate that sendMessage can now natively accept an array of rich submessages
933
+ await client.sendMessage(msgFrom, {
934
+ richResponse: [
935
+ {
936
+ messageType: 2,
937
+ messageText: '# H1\n## H2\n### H3\n#### H4\n##### H5\n###### H6\n\n___\n\n> To use a horizontal line, you need to have two "\\n" above and below the "___"\n==Highlighted text==\n# By the way, ^you^ can _mix_ ==multiple markdowns== for a **richer response**\n###### Try different combinations...'
938
+ },
939
+ {
940
+ messageType: 2,
941
+ messageText: 'And here is a syntax-highlighted code block natively passed:'
942
+ },
943
+ {
944
+ messageType: 5,
945
+ codeMetadata: {
946
+ codeLanguage: 'javascript',
947
+ codeBlocks: [
948
+ { highlightType: 1, codeContent: 'const ' },
949
+ { highlightType: 0, codeContent: 'greet = (name) => {\n console.log(' },
950
+ { highlightType: 3, codeContent: '"Hello, "' },
951
+ { highlightType: 0, codeContent: ' + name)\n}\n' },
952
+ { highlightType: 0, codeContent: 'greet(' },
953
+ { highlightType: 3, codeContent: '"World"' },
954
+ { highlightType: 0, codeContent: ')' }
955
+ ]
956
+ }
957
+ }
958
+ ]
959
+ },
960
+ { markdown: true });
961
+ break;
962
+
721
963
  case '!groups':
722
964
  try {
723
965
  const groups = await client.getAllGroups()