trompot 1.6.7 → 1.7.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.
Files changed (76) hide show
  1. package/README.md +0 -7
  2. package/lib/messages/MediaMessage.js +0 -15
  3. package/lib/messages/MediaMessage.js.map +1 -1
  4. package/lib/telegram/TelegramBot.d.ts +3 -3
  5. package/lib/telegram/TelegramBot.js +7 -16
  6. package/lib/telegram/TelegramBot.js.map +1 -1
  7. package/lib/telegram/TelegramEvents.js.map +1 -1
  8. package/lib/telegram/TelegramSendingController.d.ts +17 -12
  9. package/lib/telegram/TelegramSendingController.js +12 -45
  10. package/lib/telegram/TelegramSendingController.js.map +1 -1
  11. package/lib/telegram/TelegramToRompotConverter.d.ts +3 -3
  12. package/lib/telegram/TelegramToRompotConverter.js.map +1 -1
  13. package/lib/telegram/TelegramUtils.d.ts +10 -10
  14. package/lib/telegram/TelegramUtils.js +20 -20
  15. package/lib/telegram/TelegramUtils.js.map +1 -1
  16. package/lib/telegram/telegramTypes.d.ts +5 -0
  17. package/lib/telegram/telegramTypes.js +3 -0
  18. package/lib/telegram/telegramTypes.js.map +1 -0
  19. package/lib/wa/ConfigWAEvents.js +14 -11
  20. package/lib/wa/ConfigWAEvents.js.map +1 -1
  21. package/lib/wa/ConvertWAMessage.js +49 -60
  22. package/lib/wa/ConvertWAMessage.js.map +1 -1
  23. package/lib/wa/ID.d.ts +13 -1
  24. package/lib/wa/ID.js +43 -1
  25. package/lib/wa/ID.js.map +1 -1
  26. package/lib/wa/WhatsAppBot.d.ts +0 -2
  27. package/lib/wa/WhatsAppBot.js +8 -12
  28. package/lib/wa/WhatsAppBot.js.map +1 -1
  29. package/lib/wa/constants/DisconnectReasons.d.ts +1 -1
  30. package/lib/wa/constants/DisconnectReasons.js +1 -0
  31. package/lib/wa/constants/DisconnectReasons.js.map +1 -1
  32. package/lib/wa/constants/ErrorCodes.d.ts +4 -0
  33. package/lib/wa/constants/ErrorCodes.js +4 -0
  34. package/lib/wa/constants/ErrorCodes.js.map +1 -1
  35. package/lib/wa/constants/JIDPatterns.d.ts +8 -1
  36. package/lib/wa/constants/JIDPatterns.js +12 -2
  37. package/lib/wa/constants/JIDPatterns.js.map +1 -1
  38. package/lib/wa/core/ConnectionManager.js +1 -0
  39. package/lib/wa/core/ConnectionManager.js.map +1 -1
  40. package/lib/wa/events/CallEventHandler.js +15 -11
  41. package/lib/wa/events/CallEventHandler.js.map +1 -1
  42. package/lib/wa/events/ConnectionEventHandler.js +30 -24
  43. package/lib/wa/events/ConnectionEventHandler.js.map +1 -1
  44. package/lib/wa/events/ContactEventHandler.js +30 -40
  45. package/lib/wa/events/ContactEventHandler.js.map +1 -1
  46. package/lib/wa/events/GroupEventHandler.js +2 -2
  47. package/lib/wa/events/GroupEventHandler.js.map +1 -1
  48. package/lib/wa/events/HistoryEventHandler.js +13 -23
  49. package/lib/wa/events/HistoryEventHandler.js.map +1 -1
  50. package/lib/wa/events/LIDMappingEventHandler.d.ts +4 -13
  51. package/lib/wa/events/LIDMappingEventHandler.js +12 -42
  52. package/lib/wa/events/LIDMappingEventHandler.js.map +1 -1
  53. package/lib/wa/events/MessageEventHandler.d.ts +2 -2
  54. package/lib/wa/events/MessageEventHandler.js +6 -45
  55. package/lib/wa/events/MessageEventHandler.js.map +1 -1
  56. package/lib/wa/makeInMemoryStore.js +0 -21
  57. package/lib/wa/makeInMemoryStore.js.map +1 -1
  58. package/lib/wa/operations/ChatOperations.js +7 -6
  59. package/lib/wa/operations/ChatOperations.js.map +1 -1
  60. package/lib/wa/operations/MessageOperations.js +3 -6
  61. package/lib/wa/operations/MessageOperations.js.map +1 -1
  62. package/lib/wa/services/LIDMappingService.d.ts +4 -0
  63. package/lib/wa/services/LIDMappingService.js +30 -43
  64. package/lib/wa/services/LIDMappingService.js.map +1 -1
  65. package/lib/wa/services/LIDNormalizationService.d.ts +3 -2
  66. package/lib/wa/services/LIDNormalizationService.js +15 -30
  67. package/lib/wa/services/LIDNormalizationService.js.map +1 -1
  68. package/lib/wa/services/PendingMessageQueue.js +6 -4
  69. package/lib/wa/services/PendingMessageQueue.js.map +1 -1
  70. package/package.json +89 -98
  71. package/lib/wa/services/ContactService.d.ts +0 -122
  72. package/lib/wa/services/ContactService.js +0 -442
  73. package/lib/wa/services/ContactService.js.map +0 -1
  74. package/lib/wa/utils/ContactIdHelper.d.ts +0 -112
  75. package/lib/wa/utils/ContactIdHelper.js +0 -216
  76. package/lib/wa/utils/ContactIdHelper.js.map +0 -1
package/package.json CHANGED
@@ -1,98 +1,89 @@
1
- {
2
- "name": "trompot",
3
- "version": "1.6.7",
4
- "description": "Chatbot API multi-plataforma em TypeScript. Fork do Trompot.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "example": "ts-node-dev example/index.ts",
9
- "cluster": "ts-node-dev example/cluster.ts",
10
- "telegram": "ts-node-dev example/telegram.ts",
11
- "test": "ts-node example/test-refactoring.ts",
12
- "test:proactive": "ts-node example/test-send-proactive-whatsapp.ts",
13
- "test:bulk": "ts-node example/test-bulk-notifications-whatsapp.ts",
14
- "test:convert-lid": "ts-node example/test-convert-lid-to-jid.ts",
15
- "test:stable-id": "ts-node example/test-stable-user-id.ts",
16
- "test:perfect": "ts-node example/test-perfect-contact-system.ts",
17
- "test:force-contact": "ts-node example/test-force-contact-verification.ts",
18
- "test:complete": "ts-node example/test-complete-whatsapp-methods.ts",
19
- "test:connection": "ts-node example/test-connection-debug.ts",
20
- "build": "npm i && npm run clean && tsc",
21
- "clean": "rimraf lib",
22
- "lint": "eslint ."
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://github.com/TelksBr/trompot.git"
27
- },
28
- "keywords": [
29
- "whatsapp",
30
- "bot",
31
- "chatbot",
32
- "baileys",
33
- "typescript",
34
- "telegram",
35
- "api",
36
- "messaging",
37
- "automation",
38
- "nodejs"
39
- ],
40
- "author": "TelksBr",
41
- "license": "MIT",
42
- "bugs": {
43
- "url": "https://github.com/TelksBr/trompot/issues"
44
- },
45
- "homepage": "https://github.com/TelksBr/trompot#readme",
46
- "dependencies": {
47
- "@adiwajshing/keyed-db": "0.2.4",
48
- "@hapi/boom": "9.1.3",
49
- "@whiskeysockets/baileys": "7.0.0-rc.9",
50
- "axios": "1.13.2",
51
- "body-parser": "1.20.2",
52
- "cluster": "0.7.7",
53
- "crypto-digest-sync": "1.0.0",
54
- "express": "5.2.1",
55
- "long": "5.2.3",
56
- "node-cache": "5.1.2",
57
- "node-telegram-bot-api": "0.67.0",
58
- "pino": "9.7.0"
59
- },
60
- "files": [
61
- "lib/**/*"
62
- ],
63
- "devDependencies": {
64
- "@eslint/js": "^9.14.0",
65
- "@laxeder/wa-sticker": "4.4.5",
66
- "@types/body-parser": "1.19.5",
67
- "@types/express": "5.0.2",
68
- "@types/node": "^22.15.29",
69
- "@types/node-telegram-bot-api": "0.64.8",
70
- "@types/qrcode": "^1.5.6",
71
- "@types/ws": "8.18.1",
72
- "dotenv": "16.5.0",
73
- "eslint": "^9.14.0",
74
- "eslint-config-prettier": "10.1.5",
75
- "eslint-plugin-prettier": "^5.2.1",
76
- "globals": "16.2.0",
77
- "jimp": "^1.6.0",
78
- "prettier": "^3.3.3",
79
- "qrcode": "^1.5.4",
80
- "rimraf": "^6.0.1",
81
- "sharp": "0.32.6",
82
- "ts-node-dev": "2.0.0",
83
- "typescript": "5.8.3",
84
- "typescript-eslint": "^8.12.2"
85
- },
86
- "peerDependencies": {
87
- "@laxeder/wa-sticker": "4.4.5",
88
- "sharp": "0.34.2"
89
- },
90
- "peerDependenciesMeta": {
91
- "@laxeder/wa-sticker": {
92
- "optional": true
93
- },
94
- "sharp": {
95
- "optional": true
96
- }
97
- }
98
- }
1
+ {
2
+ "name": "trompot",
3
+ "version": "1.7.0",
4
+ "description": "Chatbot API multi-plataforma em TypeScript. Fork do Trompot.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "example": "ts-node-dev example/index.ts",
9
+ "cluster": "ts-node-dev example/cluster.ts",
10
+ "telegram": "ts-node-dev example/telegram.ts",
11
+ "test": "ts-node example/test-refactoring.ts",
12
+ "build": "npm i && npm run clean && tsc",
13
+ "clean": "rimraf lib",
14
+ "lint": "eslint ."
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/TelksBr/trompot.git"
19
+ },
20
+ "keywords": [
21
+ "whatsapp",
22
+ "bot",
23
+ "chatbot",
24
+ "baileys",
25
+ "typescript",
26
+ "telegram",
27
+ "api",
28
+ "messaging",
29
+ "automation",
30
+ "nodejs"
31
+ ],
32
+ "author": "TelksBr",
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/TelksBr/trompot/issues"
36
+ },
37
+ "homepage": "https://github.com/TelksBr/trompot#readme",
38
+ "dependencies": {
39
+ "@adiwajshing/keyed-db": "0.2.4",
40
+ "@hapi/boom": "9.1.3",
41
+ "@whiskeysockets/baileys": "7.0.0-rc14",
42
+ "axios": "1.13.2",
43
+ "body-parser": "1.20.2",
44
+ "cluster": "0.7.7",
45
+ "crypto-digest-sync": "1.0.0",
46
+ "express": "5.2.1",
47
+ "long": "5.2.3",
48
+ "node-cache": "5.1.2",
49
+ "node-telegram-bot-api": "1.2.0",
50
+ "pino": "9.7.0"
51
+ },
52
+ "files": [
53
+ "lib/**/*"
54
+ ],
55
+ "devDependencies": {
56
+ "@eslint/js": "^9.14.0",
57
+ "@laxeder/wa-sticker": "4.4.5",
58
+ "@types/body-parser": "1.19.5",
59
+ "@types/express": "5.0.2",
60
+ "@types/node": "^22.15.29",
61
+ "@types/qrcode": "^1.5.6",
62
+ "@types/ws": "8.18.1",
63
+ "dotenv": "16.5.0",
64
+ "eslint": "^9.14.0",
65
+ "eslint-config-prettier": "10.1.5",
66
+ "eslint-plugin-prettier": "^5.2.1",
67
+ "globals": "16.2.0",
68
+ "jimp": "^1.6.0",
69
+ "prettier": "^3.3.3",
70
+ "qrcode": "^1.5.4",
71
+ "rimraf": "^6.0.1",
72
+ "sharp": "0.32.6",
73
+ "ts-node-dev": "2.0.0",
74
+ "typescript": "5.8.3",
75
+ "typescript-eslint": "^8.12.2"
76
+ },
77
+ "peerDependencies": {
78
+ "@laxeder/wa-sticker": "4.4.5",
79
+ "sharp": "0.34.2"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@laxeder/wa-sticker": {
83
+ "optional": true
84
+ },
85
+ "sharp": {
86
+ "optional": true
87
+ }
88
+ }
89
+ }
@@ -1,122 +0,0 @@
1
- import { Contact as BaileysContact } from '@whiskeysockets/baileys';
2
- import { ILoggerService } from '../interfaces/ILoggerService';
3
- import { ICacheService } from '../interfaces/ICacheService';
4
- import WhatsAppBot from '../WhatsAppBot';
5
- /**
6
- * 🎯 ESTRUTURA ENRIQUECIDA DE CONTATO (Baileys v7)
7
- *
8
- * Segue a estrutura oficial do Baileys v7:
9
- * - `id`: Identificador principal (pode ser LID ou PN)
10
- * - `phoneNumber`: Presente quando `id` é LID
11
- * - `lid`: Presente quando `id` é PN
12
- *
13
- * @see https://whiskey.so/migrate-latest
14
- */
15
- export interface EnrichedContact extends BaileysContact {
16
- /** ID principal (LID ou PN) - PREFERIDO pelo WhatsApp */
17
- id: string;
18
- /** phoneNumber presente quando id é LID */
19
- phoneNumber?: string;
20
- /** LID presente quando id é PN */
21
- lid?: string;
22
- /** Metadados de persistência */
23
- firstSeenAt?: Date;
24
- lastSeenAt?: Date;
25
- lastUpdatedAt?: Date;
26
- /** Identificadores alternativos (de remoteJidAlt/participantAlt) */
27
- alternateIds?: string[];
28
- }
29
- /**
30
- * 🎯 SERVIÇO DE GERENCIAMENTO DE CONTATOS (Baileys v7)
31
- *
32
- * FILOSOFIA:
33
- * - LID é o identificador PRINCIPAL e MAIS CONFIÁVEL
34
- * - PN (phoneNumber) é OPCIONAL e informativo
35
- * - Aceita LID como identificador válido (não tenta "descobrir" PN a todo custo)
36
- * - Usa signalRepository.lidMapping oficial para conversões
37
- *
38
- * MUDANÇAS do Baileys v7:
39
- * - "PNs are WAY LESS RELIABLE. MIGRATE TO LIDs"
40
- * - Contact.id pode ser LID ou PN
41
- * - Se id é LID → phoneNumber pode estar presente
42
- * - Se id é PN → lid pode estar presente
43
- *
44
- * @since Baileys v7
45
- */
46
- export declare class ContactService {
47
- private bot;
48
- private logger;
49
- private cache;
50
- private contactsMap;
51
- private phoneToIdIndex;
52
- private lidToIdIndex;
53
- constructor(bot: WhatsAppBot, logger: ILoggerService, cache: ICacheService);
54
- /**
55
- * 🔄 Sincroniza contatos do evento contacts.upsert
56
- */
57
- syncContactsUpsert(contacts: BaileysContact[]): Promise<void>;
58
- /**
59
- * 🔄 Sincroniza contatos do evento contacts.update
60
- */
61
- syncContactsUpdate(contacts: Partial<BaileysContact>[]): Promise<void>;
62
- /**
63
- * ✨ Insere ou atualiza um contato (CORE DO SISTEMA)
64
- *
65
- * ✅ Baileys v7: Usa signalRepository.lidMapping oficial
66
- * ✅ Aceita LID como identificador válido
67
- * ✅ Enriquece com phoneNumber/lid quando disponível
68
- */
69
- private upsertContact;
70
- /**
71
- * 📞 Obtém phoneNumber de um JID/LID
72
- *
73
- * ✅ Baileys v7: Usa signalRepository.lidMapping oficial
74
- * ✅ Aceita que phoneNumber pode não estar disponível
75
- */
76
- getPhoneNumber(jid: string): Promise<string | null>;
77
- /**
78
- * 🔍 Busca JID/LID de um phoneNumber
79
- */
80
- getIdByPhoneNumber(phoneNumber: string): Promise<string | null>;
81
- /**
82
- * 📋 Obtém contato completo
83
- */
84
- getContact(jid: string): Promise<EnrichedContact | null>;
85
- /**
86
- * 📋 Lista todos os contatos
87
- */
88
- getAllContacts(): EnrichedContact[];
89
- /**
90
- * 💾 Salva contatos em arquivo persistente
91
- */
92
- private saveContactsToPersistence;
93
- /**
94
- * 📂 Carrega contatos do arquivo persistente
95
- */
96
- private loadContactsFromPersistence;
97
- /**
98
- * 🔄 Sincroniza com o store do Baileys (chamado após bind)
99
- */
100
- syncWithBaileysStore(): Promise<void>;
101
- /**
102
- * 🧹 Limpa cache (útil para testes)
103
- */
104
- clear(): void;
105
- /**
106
- * 🔄 Enriquece contato com mapeamento LID ↔ PN (NOVO - Baileys v7)
107
- *
108
- * Se o contato tem apenas LID, tenta obter PN.
109
- * Se o contato tem apenas PN, tenta obter LID.
110
- *
111
- * @param contactId - ID do contato (LID ou PN)
112
- * @returns true se conseguiu enriquecer, false caso contrário
113
- */
114
- enrichContactWithMapping(contactId: string): Promise<boolean>;
115
- /**
116
- * 🔄 Enriquece contato com mapeamento direto LID ↔ PN
117
- *
118
- * @param lid - LID do usuário (com ou sem @lid)
119
- * @param pn - PN do usuário (com ou sem @s.whatsapp.net)
120
- */
121
- enrichContactWithDirectMapping(lid: string, pn: string): Promise<void>;
122
- }