@roidev/kachina-md 2.1.5 → 2.1.6

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.
@@ -22,6 +22,7 @@ import chalk from 'chalk';
22
22
  * @typedef {Object} ClientOptions
23
23
  * @property {string} [sessionId='kachina-session'] - Session ID for storing authentication data
24
24
  * @property {string} [phoneNumber=''] - Phone number for pairing method (format: 628123456789)
25
+ * @property {Array<string>} [owners=[]] - List of bot owner phone numbers (format: 628123456789)
25
26
  * @property {'qr'|'pairing'} [loginMethod='qr'] - Login method: 'qr' for QR code, 'pairing' for pairing code
26
27
  * @property {Array<string>} [browser=['Kachina-MD', 'Chrome', '1.0.0']] - Browser identification
27
28
  * @property {Object} [logger] - Pino logger instance
@@ -31,6 +32,7 @@ import chalk from 'chalk';
31
32
 
32
33
  /**
33
34
  * Main WhatsApp bot client class
35
+ * @description Core client for WhatsApp bot operations with plugin support
34
36
  *
35
37
  * @class Client
36
38
  * @extends EventEmitter
@@ -74,6 +76,7 @@ export class Client extends EventEmitter {
74
76
  this.config = {
75
77
  sessionId: options.sessionId || 'kachina-session',
76
78
  phoneNumber: options.phoneNumber || '',
79
+ owner: options.owners || [],
77
80
  loginMethod: options.loginMethod || 'qr', // 'qr' or 'pairing'
78
81
  browser: options.browser || ['Kachina-MD', 'Chrome', '1.0.0'],
79
82
  logger: options.logger || pino({ level: 'silent' }),
@@ -29,7 +29,7 @@ import { fileTypeFromBuffer } from 'file-type';
29
29
  /**
30
30
  * Serialize raw Baileys message into standardized format with helper methods
31
31
  * @async
32
- * @param {Object} msg - Raw Baileys message object
32
+ * @param {import('baileys').WAMessage} msg - Raw Baileys message object
33
33
  * @param {Object} sock - WhatsApp socket instance
34
34
  * @returns {Promise<SerializedMessage>} Serialized message object
35
35
  * @example
@@ -39,8 +39,8 @@ import { fileTypeFromBuffer } from 'file-type';
39
39
  * await m.react('👍'); // React with emoji
40
40
  */
41
41
  export async function serialize(msg, sock) {
42
- if (!msg) return msg;
43
-
42
+ msg = msg[0];
43
+ if (!msg) return null;
44
44
  const m = {};
45
45
 
46
46
  // Basic info
@@ -53,7 +53,7 @@ export async function serialize(msg, sock) {
53
53
  m.pushName = msg.pushName || '';
54
54
 
55
55
  // Message type
56
- const type = getContentType(msg.message);
56
+ const type = Object.keys(msg.message)[0];
57
57
  m.type = type;
58
58
  m.message = msg.message;
59
59
 
@@ -68,7 +68,7 @@ export async function serialize(msg, sock) {
68
68
  remoteJid: m.chat,
69
69
  fromMe: msg.message[type].contextInfo.participant === sock.user.id,
70
70
  id: msg.message[type].contextInfo.stanzaId,
71
- participant: msg.message[type].contextInfo.participant
71
+ participant: m.isGroup ? m.key.participantLid : m.key.participant
72
72
  },
73
73
  message: quoted,
74
74
  pushName: msg.message[type].contextInfo.pushName || ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roidev/kachina-md",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "WhatsApp Bot Framework - Simple, Fast, and Modular",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",