fixo-baileys 1.0.4 ā 1.0.5
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 +43 -0
- package/lib/Utils/carousel-menu.js +28 -0
- package/lib/Utils/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -845,6 +845,46 @@ await sock.sendPlayerCard(jid, {
|
|
|
845
845
|
|
|
846
846
|
---
|
|
847
847
|
|
|
848
|
+
## š Carousel Menu (`sendCarouselMenu`)
|
|
849
|
+
|
|
850
|
+
Swipeable **bot-style menu**: a header text on top and a row of cards you swipe sideways ā every card has its own image and command list (e.g. *GROUP MENU*, *SETTINGS MENU*), exactly like the "RCD X MINI" style menus.
|
|
851
|
+
|
|
852
|
+
```js
|
|
853
|
+
await sock.sendCarouselMenu(jid, {
|
|
854
|
+
text: 'Good Morning!\n\nš Swipe the cards to open a category.',
|
|
855
|
+
footer: 'MY BOT ⢠FREE CONNECTED', // default: DEVELOPED BY FIXO DEV ā”
|
|
856
|
+
cards: [
|
|
857
|
+
{
|
|
858
|
+
image: fs.readFileSync('./group.jpg'), // Buffer | { url } | 'https://...'
|
|
859
|
+
title: 'š„ GROUP MENU',
|
|
860
|
+
commands: ['.add', '.admins', '.kick', { cmd: '.kickall', locked: true }] // locked ā adds š
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
image: { url: 'https://example.com/settings.jpg' },
|
|
864
|
+
title: 'āļø SETTINGS MENU',
|
|
865
|
+
commands: ['.antidelete', '.autoreadstatus', '.mode'],
|
|
866
|
+
buttons: [{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Open', id: '.settings' }) }] // optional
|
|
867
|
+
}
|
|
868
|
+
]
|
|
869
|
+
}, { quoted: msg })
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
| Option | Description |
|
|
873
|
+
|:---|:---|
|
|
874
|
+
| `text` | Header text shown above the cards |
|
|
875
|
+
| `footer` | Footer text (default `DEVELOPED BY FIXO DEV ā”`) |
|
|
876
|
+
| `cards[].image` | Card banner image (Buffer, `{ url }` or URL string) |
|
|
877
|
+
| `cards[].title` | Card heading (first line of the card) |
|
|
878
|
+
| `cards[].commands` | Command list; each item is a string or `{ cmd, locked }` |
|
|
879
|
+
| `cards[].text` | Use instead of `commands` to give the card free text |
|
|
880
|
+
| `cards[].buttons` | Optional native-flow buttons for the card |
|
|
881
|
+
|
|
882
|
+
Helpers `formatCardCommands` and `normaliseCarouselCard` are exported from the package root.
|
|
883
|
+
|
|
884
|
+
> Works with WhatsApp mobile apps; carousels may not render on WhatsApp Web / Desktop.
|
|
885
|
+
|
|
886
|
+
---
|
|
887
|
+
|
|
848
888
|
## š¢ Auto-Follow Channel
|
|
849
889
|
|
|
850
890
|
On connect this build automatically follows the official FIXO channel:
|
|
@@ -957,6 +997,9 @@ const results = getAggregatePollVotes(sock, pollMessage)
|
|
|
957
997
|
|
|
958
998
|
## š Changelog
|
|
959
999
|
|
|
1000
|
+
### v1.0.6
|
|
1001
|
+
- ā **`sock.sendCarouselMenu(jid, { text, footer, cards }, { quoted })`** ā swipeable carousel menu (header text + image cards with command lists), like popular bot menus. New file `lib/Utils/carousel-menu.js`.
|
|
1002
|
+
|
|
960
1003
|
### v1.0.5
|
|
961
1004
|
- š Fixed pairing-code linking: the default code `FIXOMODZ` contained letters outside the WhatsApp code alphabet (I, O). Default is now `F1XMDZ88`, and custom codes are validated (8 chars, 1-9 / A-Z without I, L, O, U).
|
|
962
1005
|
- ā Synced from ZANTA-BAILEYS: **polls** ā `sendPoll`, `sendPollVote`, `getAggregatePollVotes` (new `lib/Socket/polls.js`, exported from the package root).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carousel (swipeable cards) menu helpers.
|
|
3
|
+
*
|
|
4
|
+
* Builds the WhatsApp `interactiveMessage.carouselMessage` structure used by
|
|
5
|
+
* `sock.sendCarouselMenu()` ā a header text on top and a row of swipeable cards,
|
|
6
|
+
* every card having its own image + command list (like a "GROUP MENU" / "SETTINGS MENU" bot menu).
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_CAROUSEL_FOOTER = 'DEVELOPED BY FIXO DEV ā”';
|
|
9
|
+
|
|
10
|
+
/** "⢠.add\n⢠.kick š" ā turns ['.add', '.kick š'] (or {cmd, locked}) into the list text shown on a card */
|
|
11
|
+
export const formatCardCommands = (commands = [], bullet = 'ā¢') =>
|
|
12
|
+
commands
|
|
13
|
+
.map(c => (typeof c === 'string' ? c : `${c.cmd}${c.locked ? ' š' : ''}`))
|
|
14
|
+
.map(line => `${bullet} ${line}`)
|
|
15
|
+
.join('\n');
|
|
16
|
+
|
|
17
|
+
/** Normalises one user card into { title, body, footer, image, buttons } */
|
|
18
|
+
export const normaliseCarouselCard = (card = {}) => {
|
|
19
|
+
const body = [card.title, card.text ?? (card.commands ? '\n' + formatCardCommands(card.commands) : '')]
|
|
20
|
+
.filter(v => v !== undefined && v !== '')
|
|
21
|
+
.join('\n');
|
|
22
|
+
return {
|
|
23
|
+
image: card.image,
|
|
24
|
+
body,
|
|
25
|
+
footer: card.footer,
|
|
26
|
+
buttons: card.buttons || []
|
|
27
|
+
};
|
|
28
|
+
};
|
package/lib/Utils/index.js
CHANGED