@victory_is_h1m/custom-baileys 0.0.0-stage → 1.0.0

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 CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @victory_is_h1m/custom-baileys
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Custom WhatsApp Web API wrapper built on `@whiskeysockets/baileys` with built-in custom pairing code support (`VICT-ORYY`), auto-reconnect, and helper methods.
4
+
5
+ ## Usage
6
+ ```javascript
7
+ import createVictoryBaileys from '@victory_is_h1m/custom-baileys';
8
+
9
+ const bot = await createVictoryBaileys({
10
+ phoneNumber: '2348162843527',
11
+ customPairingCode: 'VICT-ORYY',
12
+ });
13
+ ```
@@ -0,0 +1,13 @@
1
+ import { UserFacingSocketConfig, WASocket } from '@whiskeysockets/baileys';
2
+ export * from '@whiskeysockets/baileys';
3
+ export interface CustomBotOptions {
4
+ sessionDir?: string;
5
+ phoneNumber?: string;
6
+ customPairingCode?: string;
7
+ autoReconnect?: boolean;
8
+ onPairingCode?: (formattedCode: string, rawCode: string) => void;
9
+ onReady?: (sock: WASocket) => void;
10
+ socketConfig?: Partial<UserFacingSocketConfig>;
11
+ }
12
+ export declare function createVictoryBaileys(options?: CustomBotOptions): Promise<any>;
13
+ export default createVictoryBaileys;
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ import makeWASocket, { Browsers, DisconnectReason, useMultiFileAuthState, fetchLatestBaileysVersion, } from '@whiskeysockets/baileys';
2
+ export * from '@whiskeysockets/baileys';
3
+ export async function createVictoryBaileys(options = {}) {
4
+ const { sessionDir = './auth_session', phoneNumber, customPairingCode = 'VICT-ORYY', autoReconnect = true, onPairingCode, onReady, socketConfig = {}, } = options;
5
+ const { state, saveCreds } = await useMultiFileAuthState(sessionDir);
6
+ const { version } = await fetchLatestBaileysVersion();
7
+ let pairingRequested = false;
8
+ const sock = makeWASocket({
9
+ version,
10
+ auth: state,
11
+ browser: Browsers.ubuntu('Chrome'),
12
+ syncFullHistory: true,
13
+ markOnlineOnConnect: true,
14
+ ...socketConfig,
15
+ });
16
+ sock.ev.on('creds.update', saveCreds);
17
+ sock.ev.on('connection.update', async (update) => {
18
+ const { connection, lastDisconnect, qr } = update;
19
+ if ((qr || connection === 'connecting') && !state.creds.registered && phoneNumber && !pairingRequested) {
20
+ pairingRequested = true;
21
+ try {
22
+ const cleanNumber = phoneNumber.replace(/\D/g, '');
23
+ const cleanCode = customPairingCode.replace(/[^A-Za-z0-9]/g, '').toUpperCase();
24
+ await new Promise((res) => setTimeout(res, 1500));
25
+ const code = await sock.requestPairingCode(cleanNumber, cleanCode);
26
+ const formatted = `${code.slice(0, 4)}-${code.slice(4)}`;
27
+ if (onPairingCode)
28
+ onPairingCode(formatted, code);
29
+ else
30
+ console.log(`\n[VICTORY-BAILEYS] Pairing Code: ${formatted}\n`);
31
+ }
32
+ catch (err) {
33
+ pairingRequested = false;
34
+ console.error('[VICTORY-BAILEYS] Pairing code error:', err);
35
+ }
36
+ }
37
+ if (connection === 'open') {
38
+ console.log('[VICTORY-BAILEYS] Connected to WhatsApp!');
39
+ if (onReady)
40
+ onReady(sock);
41
+ if (onReady)
42
+ onReady(sock);
43
+ }
44
+ if (connection === 'close') {
45
+ const statusCode = lastDisconnect?.error?.output?.statusCode;
46
+ if (autoReconnect && statusCode !== DisconnectReason.loggedOut) {
47
+ createVictoryBaileys(options);
48
+ }
49
+ }
50
+ });
51
+ const helpers = {
52
+ sendText: (jid, text, mentions, quoted) => sock.sendMessage(jid, { text, mentions }, { quoted }),
53
+ sendImage: (jid, source, caption) => sock.sendMessage(jid, { image: typeof source === 'string' ? { url: source } : source, caption }),
54
+ sendVideo: (jid, source, caption, gifPlayback = false) => sock.sendMessage(jid, { video: typeof source === 'string' ? { url: source } : source, caption, gifPlayback }),
55
+ sendAudio: (jid, source, ptt = false) => sock.sendMessage(jid, { audio: typeof source === 'string' ? { url: source } : source, ptt, mimetype: 'audio/mp4' }),
56
+ sendDocument: (jid, source, fileName, mimetype) => sock.sendMessage(jid, { document: typeof source === 'string' ? { url: source } : source, fileName, mimetype }),
57
+ sendSticker: (jid, source) => sock.sendMessage(jid, { sticker: typeof source === 'string' ? { url: source } : source }),
58
+ sendPoll: (jid, name, values, selectableCount = 1) => sock.sendMessage(jid, { poll: { name, values, selectableCount } }),
59
+ react: (jid, key, emoji) => sock.sendMessage(jid, { react: { text: emoji, key } }),
60
+ sendLocation: (jid, degreesLatitude, degreesLongitude) => sock.sendMessage(jid, { location: { degreesLatitude, degreesLongitude } }),
61
+ editMessage: (jid, key, newText) => sock.sendMessage(jid, { text: newText, edit: key }),
62
+ deleteMessage: (jid, key) => sock.sendMessage(jid, { delete: key }),
63
+ postStatus: (content, statusJidList) => sock.sendMessage('status@broadcast', content, { statusJidList }),
64
+ createGroup: (subject, participants) => sock.groupCreate(subject, participants),
65
+ groupAction: (groupJid, participants, action) => sock.groupParticipantsUpdate(groupJid, participants, action),
66
+ setGroupSettings: (groupJid, setting) => sock.groupSettingUpdate(groupJid, setting),
67
+ setTyping: (jid, isTyping = true) => sock.sendPresenceUpdate(isTyping ? 'composing' : 'paused', jid),
68
+ updateBio: (status) => sock.updateProfileStatus(status),
69
+ sendRaw: (jid, content, opts) => sock.sendMessage(jid, content, opts),
70
+ };
71
+ return { sock, ...helpers };
72
+ }
73
+ export default createVictoryBaileys;
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@victory_is_h1m/custom-baileys",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC",
13
+ "type": "module",
14
+ "dependencies": {
15
+ "@hapi/boom": "^10.0.1",
16
+ "@whiskeysockets/baileys": "^7.0.0-rc14"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^26.6.10",
20
+ "typescript": "^5.9.3"
21
+ },
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ]
26
+ }