@mrlegendbot/baileys 1.2.4 → 1.2.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.
@@ -1462,6 +1462,57 @@ export const makeMessagesSocket = config => {
1462
1462
  });
1463
1463
  return waMsg;
1464
1464
  },
1465
+ sendjson: async (target, json = {}, config = {}) => {
1466
+ const msg = generateWAMessageFromContent(target, json, {});
1467
+ return relayMessage(target, msg.message, { messageId: msg.key.id, ...config });
1468
+ },
1469
+ decodeJid: jid => {
1470
+ if (!jid) return jid;
1471
+ if (/\:\d+@/gi.test(jid)) {
1472
+ const decode = jidDecode(jid) || {};
1473
+ return (decode.user && decode.server && `${decode.user}@${decode.server}`) || jid;
1474
+ }
1475
+ return jid;
1476
+ },
1477
+ makeFakeCommand: async (m, text, chatUpdate) => {
1478
+ const x = {};
1479
+ x.chat = m.key?.remoteJid;
1480
+ x.fromMe = m.key?.fromMe;
1481
+ if ((m.key?.participant?.endsWith('@lid')) && (m.key?.participant === sock.user?.lid)) {
1482
+ x.sender = sock.user?.lid;
1483
+ } else {
1484
+ x.sender = sock.decodeJid((x.fromMe && sock.user?.id) || x.participant || m.key?.participant || x.chat || '');
1485
+ }
1486
+ m.sender = x.sender;
1487
+ let recipient;
1488
+ if (m.key?.remoteJid?.includes(':')) {
1489
+ recipient = m.key.remoteJid.split(':')[0] + '@lid';
1490
+ } else {
1491
+ recipient = m.key?.remoteJid;
1492
+ }
1493
+ const messages = await generateWAMessageFromContent(
1494
+ recipient,
1495
+ { extendedTextMessage: { text: text || '' } },
1496
+ {}
1497
+ );
1498
+ messages.key.fromMe = true;
1499
+ messages.key.id = 'INTERNAL-CMD';
1500
+ messages.pushName = m.pushName;
1501
+ if (chatUpdate) {
1502
+ messages.key.participant = chatUpdate[0]?.update?.pollUpdates?.[0]?.pollUpdateMessageKey?.participant || '';
1503
+ }
1504
+ return ev.emit('messages.upsert', { messages: [messages], type: 'append' });
1505
+ },
1506
+ pollMenu: async (jid, name = '', pollOptions = [], context = {}, selectableCount = 1) => {
1507
+ const values = pollOptions.map(o => typeof o === 'string' ? o : o.vote);
1508
+ const pollMsg = await sock.sendMessage(jid, {
1509
+ poll: { name, values, selectableCount },
1510
+ ...(context && typeof context === 'object' ? context : {})
1511
+ });
1512
+ sock.tempPollStore.push({ id: pollMsg.key.id, cmds: pollOptions });
1513
+ return pollMsg;
1514
+ },
1515
+ tempPollStore: [],
1465
1516
  sendMessage: async (jid, content, options = {}) => {
1466
1517
  const userJid = authState.creds.me.id;
1467
1518
  if (typeof content === 'object' && 'disappearingMessagesInChat' in content && typeof content['disappearingMessagesInChat'] !== 'undefined' && isJidGroup(jid)) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@mrlegendbot/baileys",
3
3
  "type": "module",
4
- "version": "1.2.4",
5
- "description": "Self-modified fork of Baileys (based on @whiskeysockets/baileys 7.0.0-rc13) — ships prebuilt, installable as a normal semver dependency.",
4
+ "version": "1.2.5",
5
+ "description": "Self-modified fork of Baileys with friend-compatible sendjson, richMenu, pollMenu and makeFakeCommand helpers.",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation",