@builderbot/provider-wppconnect 0.1.3-alpha.22

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.
@@ -0,0 +1,118 @@
1
+ import { ProviderClass } from '@builderbot/bot';
2
+ import { BotContext, BotCtxMiddlewareOptions, SendOptions } from '@builderbot/bot/dist/types';
3
+ import { Message, Whatsapp } from '@wppconnect-team/wppconnect';
4
+
5
+ import { WPPConnectHttpServer } from './server';
6
+ import { SaveFileOptions } from './types';
7
+ declare class WPPConnectProvider extends ProviderClass {
8
+ globalVendorArgs: {
9
+ name: string;
10
+ port: number;
11
+ };
12
+ vendor: Whatsapp;
13
+ wppConnectProvider: any;
14
+ http: WPPConnectHttpServer | undefined;
15
+ constructor(args: {
16
+ name: string;
17
+ });
18
+ /**
19
+ *
20
+ * @param port
21
+ * @param opts
22
+ * @returns
23
+ */
24
+ initHttpServer: (port: number, opts: Pick<BotCtxMiddlewareOptions, 'blacklist'>) => void;
25
+ /**
26
+ * Iniciar WppConnect
27
+ */
28
+ initWppConnect: () => Promise<void>;
29
+ /**
30
+ * Mapeamos los eventos nativos a los que la clase Provider espera
31
+ * para tener un standar de eventos
32
+ * @returns
33
+ */
34
+ busEvents: () => {
35
+ event: string;
36
+ func: (payload: Message & {
37
+ lat?: string;
38
+ lng?: string;
39
+ name: string;
40
+ }) => void;
41
+ }[];
42
+ initBusEvents: () => void;
43
+ /**
44
+ * Enviar mensaje con botones
45
+ * @param {string} number
46
+ * @param {string} text
47
+ * @param {Array} buttons
48
+ * @example await sendButtons("+XXXXXXXXXXX", "Your Text", [{"body": "Button 1"},{"body": "Button 2"}])
49
+ */
50
+ sendButtons: (number: any, text: any, buttons: any[]) => Promise<Message>;
51
+ /**
52
+ * Enviar mensaje con encuesta
53
+ * @param {string} number
54
+ * @param {string} text
55
+ * @param {Array} poll
56
+ * @example await sendPollMessage("+XXXXXXXXXXX", "You accept terms", [ "Yes", "Not"], {"selectableCount": 1})
57
+ */
58
+ sendPoll: (number: any, text: any, poll: {
59
+ options: string[];
60
+ multiselect: any;
61
+ }) => Promise<false | Message>;
62
+ /**
63
+ * Enviar audio
64
+ * @alpha
65
+ * @param {string} number
66
+ * @param {string} message
67
+ * @param {boolean} voiceNote optional
68
+ * @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
69
+ */
70
+ sendPtt: (number: any, audioPath: string) => Promise<unknown>;
71
+ /**
72
+ * Enviar imagen
73
+ * @param {string} number - The phone number to send the image to.
74
+ * @param {string} filePath - The path to the image file.
75
+ * @param {string} text - The text to accompany the image.
76
+ * @returns {Promise<any>} - A promise representing the result of sending the image.
77
+ */
78
+ sendImage: (number: string, filePath: string, text: string) => Promise<any>;
79
+ /**
80
+ *
81
+ * @param {string} number
82
+ * @param {string} filePath
83
+ * @example await sendMessage('+XXXXXXXXXXX', './document/file.pdf')
84
+ */
85
+ sendFile: (number: any, filePath: string, text: any) => Promise<any>;
86
+ /**
87
+ * Enviar video
88
+ * @param {string} number - El número de teléfono al que se enviará el video.
89
+ * @param {string} filePath - La ruta al archivo de video.
90
+ * @param {string} text - El texto que acompañará al video.
91
+ * @returns {Promise<{
92
+ * ack: number;
93
+ * id: string;
94
+ * sendMsgResult: SendMsgResult;
95
+ * }>} - Una promesa que representa el resultado de enviar el video.
96
+ */
97
+ sendVideo: (number: string, filePath: string, text: string) => Promise<any>;
98
+ /**
99
+ * Enviar imagen o multimedia
100
+ * @param {*} number
101
+ * @param {*} mediaInput
102
+ * @param {*} message
103
+ * @returns
104
+ */
105
+ sendMedia: (number: any, mediaUrl: string, text: any) => Promise<any>;
106
+ /**
107
+ * Enviar mensaje al usuario
108
+ * @param {*} to
109
+ * @param {*} message
110
+ * @param {*} param2
111
+ * @returns
112
+ */
113
+ sendMessage: (number: string, message: string, options?: SendOptions) => Promise<any>;
114
+ private generateFileName;
115
+ saveFile: (ctx: Partial<Message & BotContext>, options?: SaveFileOptions) => Promise<string>;
116
+ }
117
+ export { WPPConnectProvider };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;IACH,SAAS,WAAkB,MAAM,YAAY,MAAM,QAAQ,MAAM,KAAG,QAAQ,GAAG,CAAC,CAE/E;IAED;;;;;OAKG;IAEH,QAAQ,WAAkB,GAAG,YAAY,MAAM,QAAQ,GAAG,kBAGzD;IAED;;;;;;;;;;OAUG;IACH,SAAS,WAAkB,MAAM,YAAY,MAAM,QAAQ,MAAM,KAAG,QAAQ,GAAG,CAAC,CAE/E;IAED;;;;;;OAMG;IACH,SAAS,WAAkB,GAAG,YAAY,MAAM,QAAQ,GAAG,kBAW1D;IAED;;;;;;OAMG;IACH,WAAW,WAAkB,MAAM,WAAW,MAAM,YAAY,WAAW,KAAG,QAAQ,GAAG,CAAC,CAKzF;IAED,OAAO,CAAC,gBAAgB,CAAmE;IAE3F,QAAQ,QAAe,QAAQ,OAAO,GAAG,UAAU,CAAC,YAAW,eAAe,KAAQ,QAAQ,MAAM,CAAC,CAapG;CACJ;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,38 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'node:events';
3
+ import polka, { Polka } from 'polka';
4
+
5
+ import { WPPConnectProvider } from '.';
6
+ import { BotCtxMiddleware } from './types';
7
+ export declare class WPPConnectHttpServer extends EventEmitter {
8
+ #private;
9
+ server: Polka;
10
+ port: number;
11
+ constructor(botName: string, _port: number);
12
+ /**
13
+ * Contruir HTTP Server
14
+ */
15
+ protected buildHTTPServer(): Polka;
16
+ /**
17
+ * Iniciar el servidor HTTP
18
+ */
19
+ start(vendor: BotCtxMiddleware, port?: number, args?: {
20
+ botName: string;
21
+ }): void;
22
+ /**
23
+ *
24
+ * @param _
25
+ * @param res
26
+ */
27
+ protected indexHome: polka.Middleware;
28
+ stop(): Promise<void>;
29
+ }
30
+ /**
31
+ *
32
+ * @param inHandleCtx
33
+ * @returns
34
+ */
35
+ export declare const inHandleCtx: <T extends Pick<WPPConnectProvider, "sendMessage" | "vendor"> & {
36
+ provider: WPPConnectProvider;
37
+ }>(ctxPolka: (bot: T, req: any, res: any) => Promise<void>) => (req: any, res: any) => any;
38
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,aAAa,CAAA;AAGtC,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK1C,qBAAa,oBAAqB,SAAQ,YAAY;;IAC3C,MAAM,EAAE,KAAK,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;gBAGP,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAO1C;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,KAAK;IAOlC;;OAEG;IAEH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAezE;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,CAMpC;IAED,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAWxB;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW;cACwD,kBAAkB;2BACtD,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,WAEjE,GAAG,OAAO,GAAG,QAoBlB,CAAA"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { ProviderClass } from '@builderbot/bot';
3
+ export interface Response {
4
+ type: string;
5
+ data: Buffer;
6
+ }
7
+ export type BotCtxMiddleware = Partial<ProviderClass & {
8
+ provider: any;
9
+ }>;
10
+ export interface SaveFileOptions {
11
+ path?: string;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,aAAa,GAAG;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC,CAAA;AAEzE,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB"}
@@ -0,0 +1,8 @@
1
+ import { Response } from './types';
2
+ declare const WppConnectCleanNumber: (number: string, full?: boolean) => string;
3
+ declare const notMatches: (matches: RegExpMatchArray | null) => boolean;
4
+ declare const writeFilePromise: (pathQr: string, response: Response) => Promise<boolean>;
5
+ declare const WppConnectGenerateImage: (base: string, name?: string) => Promise<void | Error>;
6
+ declare const WppConnectValidNumber: (rawNumber: string) => boolean;
7
+ export { WppConnectValidNumber, WppConnectGenerateImage, WppConnectCleanNumber, notMatches, writeFilePromise };
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,QAAA,MAAM,qBAAqB,WAAY,MAAM,SAAQ,OAAO,KAAW,MAItE,CAAA;AAED,QAAA,MAAM,UAAU,YAAa,gBAAgB,GAAG,IAAI,KAAG,OAEtD,CAAA;AAED,QAAA,MAAM,gBAAgB,WAAY,MAAM,YAAY,QAAQ,KAAG,QAAQ,OAAO,CAO7E,CAAA;AAED,QAAA,MAAM,uBAAuB,SAAgB,MAAM,SAAQ,MAAM,KAAc,QAAQ,IAAI,GAAG,KAAK,CAclG,CAAA;AAED,QAAA,MAAM,qBAAqB,cAAe,MAAM,KAAG,OAIlD,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@builderbot/provider-wppconnect",
3
+ "version": "0.1.3-alpha.22",
4
+ "description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
5
+ "keywords": [],
6
+ "author": "Leifer Mendez <leifer33@gmail.com>",
7
+ "license": "ISC",
8
+ "main": "dist/index.cjs",
9
+ "types": "dist/index.d.ts",
10
+ "type": "module",
11
+ "scripts": {
12
+ "build": "rimraf dist && rollup --config",
13
+ "test": "npx uvu -r tsm ./__tests__",
14
+ "test:coverage": "npx c8 npm run test"
15
+ },
16
+ "files": [
17
+ "./dist/"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/codigoencasa/bot-whatsapp.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/codigoencasa/bot-whatsapp/issues"
25
+ },
26
+ "homepage": "https://github.com/codigoencasa/bot-whatsapp#readme",
27
+ "devDependencies": {
28
+ "@builderbot/bot": "^0.1.3-alpha.22",
29
+ "@rollup/plugin-commonjs": "^25.0.7",
30
+ "@rollup/plugin-json": "^6.1.0",
31
+ "@rollup/plugin-node-resolve": "^15.2.3",
32
+ "@types/body-parser": "^1.19.5",
33
+ "@types/mime-types": "^2.1.4",
34
+ "@types/node": "^20.11.5",
35
+ "@types/polka": "^0.5.7",
36
+ "@types/proxyquire": "^1.3.31",
37
+ "@types/qr-image": "^3.2.9",
38
+ "@types/sinon": "^17.0.3",
39
+ "mime-types": "^2.1.35",
40
+ "pino": "^8.17.2",
41
+ "proxyquire": "^2.1.3",
42
+ "puppeteer-core": "^21.9.0",
43
+ "qr-image": "^3.2.0",
44
+ "rimraf": "^5.0.5",
45
+ "rollup-plugin-typescript2": "^0.36.0",
46
+ "sinon": "^17.0.1"
47
+ },
48
+ "dependencies": {
49
+ "@wppconnect-team/wppconnect": "^1.28.4",
50
+ "body-parser": "^1.20.2",
51
+ "polka": "^0.5.2"
52
+ },
53
+ "gitHead": "e52a9fe13d30d65b650a54b6e116953c949b1158"
54
+ }