Isaac Quarenta
feat(botcore): BotCore WhatsApp PV simples estilo negra_plena -> POST /api/akira (Akiragpu)
6727a3d Download botcore/modules/CustomerIdentifier.ts from akra35567/Akiragpu: direct link, hf CLI and curl.
- Browser
- Download file 899 Bytes
-
https://huggingface.co/spaces/akra35567/Akiragpu/resolve/main/botcore/modules/CustomerIdentifier.ts
- Command line
-
hf download hf://spaces/akra35567/Akiragpu/botcore/modules/CustomerIdentifier.ts
-
curl -L -o CustomerIdentifier.ts https://huggingface.co/spaces/akra35567/Akiragpu/resolve/main/botcore/modules/CustomerIdentifier.ts
899 Bytes
| import { jidDecode } from '@whiskeysockets/baileys'; | |
| import parsePhoneNumberFromString from 'libphonenumber-js'; | |
| export class CustomerIdentifier { | |
| public getClientId(rawJid: string | null | undefined): string { | |
| if (!rawJid) return 'unknown_customer'; | |
| try { | |
| const decoded = jidDecode(rawJid); | |
| if (decoded?.user) return decoded.user; | |
| } catch { | |
| // fallback abaixo | |
| } | |
| const cleanStr = String(rawJid).split('@')[0].split(':')[0]; | |
| return cleanStr || 'unknown_customer'; | |
| } | |
| public formatForCRM(rawJid: string): string { | |
| const numericId = this.getClientId(rawJid); | |
| if (numericId === 'unknown_customer') return numericId; | |
| const phoneNumber = parsePhoneNumberFromString(`+${numericId}`); | |
| if (phoneNumber?.isValid()) return phoneNumber.number; | |
| return numericId; | |
| } | |
| } | |