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.
- package/README.md +0 -7
- package/lib/messages/MediaMessage.js +0 -15
- package/lib/messages/MediaMessage.js.map +1 -1
- package/lib/telegram/TelegramBot.d.ts +3 -3
- package/lib/telegram/TelegramBot.js +7 -16
- package/lib/telegram/TelegramBot.js.map +1 -1
- package/lib/telegram/TelegramEvents.js.map +1 -1
- package/lib/telegram/TelegramSendingController.d.ts +17 -12
- package/lib/telegram/TelegramSendingController.js +12 -45
- package/lib/telegram/TelegramSendingController.js.map +1 -1
- package/lib/telegram/TelegramToRompotConverter.d.ts +3 -3
- package/lib/telegram/TelegramToRompotConverter.js.map +1 -1
- package/lib/telegram/TelegramUtils.d.ts +10 -10
- package/lib/telegram/TelegramUtils.js +20 -20
- package/lib/telegram/TelegramUtils.js.map +1 -1
- package/lib/telegram/telegramTypes.d.ts +5 -0
- package/lib/telegram/telegramTypes.js +3 -0
- package/lib/telegram/telegramTypes.js.map +1 -0
- package/lib/wa/ConfigWAEvents.js +14 -11
- package/lib/wa/ConfigWAEvents.js.map +1 -1
- package/lib/wa/ConvertWAMessage.js +49 -60
- package/lib/wa/ConvertWAMessage.js.map +1 -1
- package/lib/wa/ID.d.ts +13 -1
- package/lib/wa/ID.js +43 -1
- package/lib/wa/ID.js.map +1 -1
- package/lib/wa/WhatsAppBot.d.ts +0 -2
- package/lib/wa/WhatsAppBot.js +8 -12
- package/lib/wa/WhatsAppBot.js.map +1 -1
- package/lib/wa/constants/DisconnectReasons.d.ts +1 -1
- package/lib/wa/constants/DisconnectReasons.js +1 -0
- package/lib/wa/constants/DisconnectReasons.js.map +1 -1
- package/lib/wa/constants/ErrorCodes.d.ts +4 -0
- package/lib/wa/constants/ErrorCodes.js +4 -0
- package/lib/wa/constants/ErrorCodes.js.map +1 -1
- package/lib/wa/constants/JIDPatterns.d.ts +8 -1
- package/lib/wa/constants/JIDPatterns.js +12 -2
- package/lib/wa/constants/JIDPatterns.js.map +1 -1
- package/lib/wa/core/ConnectionManager.js +1 -0
- package/lib/wa/core/ConnectionManager.js.map +1 -1
- package/lib/wa/events/CallEventHandler.js +15 -11
- package/lib/wa/events/CallEventHandler.js.map +1 -1
- package/lib/wa/events/ConnectionEventHandler.js +30 -24
- package/lib/wa/events/ConnectionEventHandler.js.map +1 -1
- package/lib/wa/events/ContactEventHandler.js +30 -40
- package/lib/wa/events/ContactEventHandler.js.map +1 -1
- package/lib/wa/events/GroupEventHandler.js +2 -2
- package/lib/wa/events/GroupEventHandler.js.map +1 -1
- package/lib/wa/events/HistoryEventHandler.js +13 -23
- package/lib/wa/events/HistoryEventHandler.js.map +1 -1
- package/lib/wa/events/LIDMappingEventHandler.d.ts +4 -13
- package/lib/wa/events/LIDMappingEventHandler.js +12 -42
- package/lib/wa/events/LIDMappingEventHandler.js.map +1 -1
- package/lib/wa/events/MessageEventHandler.d.ts +2 -2
- package/lib/wa/events/MessageEventHandler.js +6 -45
- package/lib/wa/events/MessageEventHandler.js.map +1 -1
- package/lib/wa/makeInMemoryStore.js +0 -21
- package/lib/wa/makeInMemoryStore.js.map +1 -1
- package/lib/wa/operations/ChatOperations.js +7 -6
- package/lib/wa/operations/ChatOperations.js.map +1 -1
- package/lib/wa/operations/MessageOperations.js +3 -6
- package/lib/wa/operations/MessageOperations.js.map +1 -1
- package/lib/wa/services/LIDMappingService.d.ts +4 -0
- package/lib/wa/services/LIDMappingService.js +30 -43
- package/lib/wa/services/LIDMappingService.js.map +1 -1
- package/lib/wa/services/LIDNormalizationService.d.ts +3 -2
- package/lib/wa/services/LIDNormalizationService.js +15 -30
- package/lib/wa/services/LIDNormalizationService.js.map +1 -1
- package/lib/wa/services/PendingMessageQueue.js +6 -4
- package/lib/wa/services/PendingMessageQueue.js.map +1 -1
- package/package.json +89 -98
- package/lib/wa/services/ContactService.d.ts +0 -122
- package/lib/wa/services/ContactService.js +0 -442
- package/lib/wa/services/ContactService.js.map +0 -1
- package/lib/wa/utils/ContactIdHelper.d.ts +0 -112
- package/lib/wa/utils/ContactIdHelper.js +0 -216
- package/lib/wa/utils/ContactIdHelper.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,98 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "trompot",
|
|
3
|
-
"version": "1.
|
|
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
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"eslint
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
}
|