@yui-bails/yui-bails 1.0.0 โ 1.2.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 +213 -0
- package/lib/Socket/index.d.ts +13 -0
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +17 -0
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/session-manager.d.ts +13 -0
- package/lib/Socket/session-manager.d.ts.map +1 -1
- package/lib/Types/Socket.d.ts +16 -0
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Utils/automation.d.ts +34 -0
- package/lib/Utils/automation.d.ts.map +1 -0
- package/lib/Utils/automation.js +44 -0
- package/lib/Utils/automation.js.map +1 -0
- package/lib/Utils/banner.d.ts +1 -1
- package/lib/Utils/banner.d.ts.map +1 -1
- package/lib/Utils/banner.js +1 -1
- package/lib/Utils/banner.js.map +1 -1
- package/lib/Utils/index.d.ts +3 -0
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/interactive.d.ts +126 -0
- package/lib/Utils/interactive.d.ts.map +1 -0
- package/lib/Utils/interactive.js +351 -0
- package/lib/Utils/interactive.js.map +1 -0
- package/lib/Utils/pretty-log.d.ts +33 -0
- package/lib/Utils/pretty-log.d.ts.map +1 -0
- package/lib/Utils/pretty-log.js +119 -0
- package/lib/Utils/pretty-log.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { MiscMessageGenerationOptions, WAMessage } from '../Types/index.js';
|
|
2
|
+
import type { SendButtonsOptions, SenderInfo } from './helpers.js';
|
|
3
|
+
import type { ButtonReply } from './replies.js';
|
|
4
|
+
type Content = Record<string, unknown>;
|
|
5
|
+
/** Who may tap a button: the person who asked, group admins, everybody, or your own check */
|
|
6
|
+
export type Who = 'sender' | 'admins' | 'anyone' | ((tap: SenderInfo, msg: WAMessage) => boolean | Promise<boolean>);
|
|
7
|
+
/** What a handler receives when someone taps one of these buttons */
|
|
8
|
+
export type TapContext = {
|
|
9
|
+
/** the message with the tap (reply to it with `sock.reply(msg, ...)`) */
|
|
10
|
+
msg: WAMessage;
|
|
11
|
+
reply: ButtonReply;
|
|
12
|
+
/** who tapped */
|
|
13
|
+
sender: SenderInfo;
|
|
14
|
+
};
|
|
15
|
+
export type GuardOptions = {
|
|
16
|
+
/** who may tap. Default `'sender'` (only the person who asked) */
|
|
17
|
+
who?: Who;
|
|
18
|
+
/** said to someone who may not tap. `false` ignores them silently */
|
|
19
|
+
denied?: string | false;
|
|
20
|
+
/** said when the button is too old. `false` ignores the tap silently */
|
|
21
|
+
expired?: string | false;
|
|
22
|
+
/** how long the buttons keep working after the last tap, in ms */
|
|
23
|
+
ttlMs?: number;
|
|
24
|
+
};
|
|
25
|
+
export type ConfirmOptions = GuardOptions & {
|
|
26
|
+
yes?: string;
|
|
27
|
+
no?: string;
|
|
28
|
+
footer?: string;
|
|
29
|
+
/** how long to wait for an answer, in ms. Default 30000. When it runs out, `confirm` returns `false` */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
};
|
|
32
|
+
export type PaginateOptions = GuardOptions & {
|
|
33
|
+
/** items per page. Default 5 */
|
|
34
|
+
perPage?: number;
|
|
35
|
+
title?: string;
|
|
36
|
+
footer?: string;
|
|
37
|
+
/** how each item is written. Default `1. item` */
|
|
38
|
+
format?: (item: any, index: number) => string;
|
|
39
|
+
prevText?: string;
|
|
40
|
+
nextText?: string;
|
|
41
|
+
/** said when there is nothing to show */
|
|
42
|
+
empty?: string;
|
|
43
|
+
};
|
|
44
|
+
export type MenuNode = {
|
|
45
|
+
title: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
/** sub-options: tapping this row opens another menu */
|
|
48
|
+
items?: MenuNode[];
|
|
49
|
+
/** text sent when this row is tapped (or shown above the sub-menu) */
|
|
50
|
+
text?: string;
|
|
51
|
+
/** runs when this row is tapped (rows without `items`) */
|
|
52
|
+
run?: (tap: TapContext & {
|
|
53
|
+
path: string[];
|
|
54
|
+
}) => void | Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
export type MenuDefinition = GuardOptions & {
|
|
57
|
+
title?: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
footer?: string;
|
|
60
|
+
/** text on the button that opens the list. Default "Ver opciones" */
|
|
61
|
+
buttonText?: string;
|
|
62
|
+
/** text of the row that goes back. Default "โฌ
Volver" */
|
|
63
|
+
backText?: string;
|
|
64
|
+
items: MenuNode[];
|
|
65
|
+
};
|
|
66
|
+
export type GuardedButtonsOptions = SendButtonsOptions & GuardOptions & {
|
|
67
|
+
/** the buttons stop working after the first allowed tap */
|
|
68
|
+
once?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type RepeatableOptions = GuardOptions & {
|
|
71
|
+
/** text on the button. Default "๐ Otra vez" */
|
|
72
|
+
buttonText?: string;
|
|
73
|
+
/** how many times it can be repeated. Default 10 */
|
|
74
|
+
maxRepeats?: number;
|
|
75
|
+
footer?: string;
|
|
76
|
+
};
|
|
77
|
+
export type InteractiveSocket = {
|
|
78
|
+
sendMessage: (jid: string, content: any, options?: MiscMessageGenerationOptions) => Promise<WAMessage | undefined> | WAMessage | undefined;
|
|
79
|
+
sendButtons: (jid: string, options: SendButtonsOptions, msgOptions?: MiscMessageGenerationOptions) => Promise<WAMessage | undefined> | WAMessage | undefined;
|
|
80
|
+
disableButtons: (msg: WAMessage, text?: string) => Promise<boolean>;
|
|
81
|
+
getSender: (msg: WAMessage) => Promise<SenderInfo>;
|
|
82
|
+
onReply: (matcher: (reply: ButtonReply) => boolean, run: (msg: WAMessage, reply: ButtonReply) => Promise<void>) => unknown;
|
|
83
|
+
isAdmin: (groupJid: string, who: SenderInfo) => Promise<boolean>;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Buttons that think: confirmations, pages, nested menus, buttons only some people can tap and
|
|
87
|
+
* "again" buttons. They are built on quick-reply buttons and dropdown rows, which already work,
|
|
88
|
+
* so there is nothing new for WhatsApp to reject.
|
|
89
|
+
*/
|
|
90
|
+
export declare const makeInteractive: (sock: InteractiveSocket, { now, logger }?: {
|
|
91
|
+
now?: () => number;
|
|
92
|
+
logger?: {
|
|
93
|
+
warn: (obj: unknown, msg?: string) => void;
|
|
94
|
+
};
|
|
95
|
+
}) => {
|
|
96
|
+
/**
|
|
97
|
+
* Asks yes / no with two buttons and returns `true` or `false`. Only the person who wrote
|
|
98
|
+
* the command can answer (change it with `who`). `false` also when time runs out.
|
|
99
|
+
*/
|
|
100
|
+
confirm: (msg: WAMessage, text: string, options?: ConfirmOptions) => Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Shows a long list in pages with "Anterior / Siguiente" buttons. Each page is a new message
|
|
103
|
+
* and the buttons of the previous one are removed. Returns the first page that was sent.
|
|
104
|
+
*/
|
|
105
|
+
paginate: (msg: WAMessage, items: unknown[], options?: PaginateOptions) => Promise<WAMessage | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* A menu with sub-menus. Every level is a dropdown list; sub-menus get a "Volver" row.
|
|
108
|
+
* WhatsApp usually allows about 10 rows per list: split bigger ones into sub-menus.
|
|
109
|
+
*/
|
|
110
|
+
menu: (msg: WAMessage, definition: MenuDefinition) => Promise<WAMessage | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* `sendButtons` where only some people can tap. Others get a short "this is not for you".
|
|
113
|
+
* Quick-reply buttons and dropdown rows are guarded; URL / call / copy buttons act by themselves.
|
|
114
|
+
*/
|
|
115
|
+
sendGuardedButtons: (msg: WAMessage, options: GuardedButtonsOptions, onTap: (tap: TapContext & {
|
|
116
|
+
id: string;
|
|
117
|
+
}) => void | Promise<void>) => Promise<WAMessage | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Sends something with a "๐ Otra vez" button. Each tap sends it again (a function gives a new
|
|
120
|
+
* result every time, e.g. a random phrase) and removes the button from the older message.
|
|
121
|
+
*/
|
|
122
|
+
sendRepeatable: (msg: WAMessage, source: string | Content | (() => string | Content | Promise<string | Content>), options?: RepeatableOptions) => Promise<WAMessage | undefined>;
|
|
123
|
+
};
|
|
124
|
+
export type Interactive = ReturnType<typeof makeInteractive>;
|
|
125
|
+
export {};
|
|
126
|
+
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/Utils/interactive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,4BAA4B,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEtC,6FAA6F;AAC7F,MAAM,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAEpH,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG;IACxB,yEAAyE;IACzE,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,WAAW,CAAA;IAClB,iBAAiB;IACjB,MAAM,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,kEAAkE;IAClE,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACvB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACxB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,YAAY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,eAAe,GAC3B,MAAM,iBAAiB,EACvB,kBAA4B;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAA;CAAO;IAgF/G;;;OAGG;mBACkB,SAAS,QAAQ,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,OAAO,CAAC;IAqD7F;;;OAGG;oBACmB,SAAS,SAAS,OAAO,EAAE,YAAW,eAAe;IAoD3E;;;OAGG;gBACe,SAAS,cAAc,cAAc;IAmFvD;;;OAGG;8BAEG,SAAS,WACL,qBAAqB,SACvB,CAAC,GAAG,EAAE,UAAU,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDlE;;;OAGG;0BAEG,SAAS,UACN,MAAM,GAAG,OAAO,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,YACtE,iBAAiB;CA6C5B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
const PREFIX = 'yui:';
|
|
3
|
+
const MAX_SESSIONS = 1000;
|
|
4
|
+
const DEFAULT_DENIED = '๐ซ Este botรณn no es para ti.';
|
|
5
|
+
const DEFAULT_EXPIRED = 'โ Este botรณn ya venciรณ. Pide el comando otra vez.';
|
|
6
|
+
const sameSender = (a, b) => (!!a.pn && a.pn === b.pn) ||
|
|
7
|
+
(!!a.lid && a.lid === b.lid) ||
|
|
8
|
+
(!!a.number && a.number === b.number) ||
|
|
9
|
+
(!!a.id && a.id === b.id);
|
|
10
|
+
const chatOf = (msg) => {
|
|
11
|
+
const jid = msg.key.remoteJid;
|
|
12
|
+
if (!jid)
|
|
13
|
+
throw new Boom('The message has no chat', { statusCode: 400 });
|
|
14
|
+
return jid;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Buttons that think: confirmations, pages, nested menus, buttons only some people can tap and
|
|
18
|
+
* "again" buttons. They are built on quick-reply buttons and dropdown rows, which already work,
|
|
19
|
+
* so there is nothing new for WhatsApp to reject.
|
|
20
|
+
*/
|
|
21
|
+
export const makeInteractive = (sock, { now = Date.now, logger } = {}) => {
|
|
22
|
+
const sessions = new Map();
|
|
23
|
+
let counter = 0;
|
|
24
|
+
const quiet = (task) => void task.catch(() => undefined);
|
|
25
|
+
const newSession = (owner, options, defaultTtl, handle) => {
|
|
26
|
+
if (sessions.size >= MAX_SESSIONS) {
|
|
27
|
+
for (const [token, session] of sessions) {
|
|
28
|
+
if (session.expiresAt < now())
|
|
29
|
+
sessions.delete(token);
|
|
30
|
+
}
|
|
31
|
+
if (sessions.size >= MAX_SESSIONS)
|
|
32
|
+
sessions.delete(sessions.keys().next().value);
|
|
33
|
+
}
|
|
34
|
+
counter += 1;
|
|
35
|
+
const token = `${now().toString(36)}${counter.toString(36)}${Math.floor(Math.random() * 1296).toString(36)}`;
|
|
36
|
+
const ttlMs = options.ttlMs ?? defaultTtl;
|
|
37
|
+
sessions.set(token, {
|
|
38
|
+
owner,
|
|
39
|
+
who: options.who ?? 'sender',
|
|
40
|
+
denied: options.denied ?? DEFAULT_DENIED,
|
|
41
|
+
expired: options.expired ?? DEFAULT_EXPIRED,
|
|
42
|
+
ttlMs,
|
|
43
|
+
expiresAt: now() + ttlMs,
|
|
44
|
+
handle
|
|
45
|
+
});
|
|
46
|
+
return token;
|
|
47
|
+
};
|
|
48
|
+
const isAllowed = async (session, tap, msg) => {
|
|
49
|
+
const { who } = session;
|
|
50
|
+
if (who === 'anyone')
|
|
51
|
+
return true;
|
|
52
|
+
if (typeof who === 'function')
|
|
53
|
+
return !!(await who(tap, msg));
|
|
54
|
+
if (who === 'admins' && tap.isGroup)
|
|
55
|
+
return sock.isAdmin(tap.chat, tap);
|
|
56
|
+
return sameSender(session.owner, tap);
|
|
57
|
+
};
|
|
58
|
+
// one handler for every button of every session: the id says which session it belongs to
|
|
59
|
+
void sock.onReply(reply => reply.id.startsWith(PREFIX), async (msg, reply) => {
|
|
60
|
+
const [, token = '', ...rest] = reply.id.split(':');
|
|
61
|
+
const chat = msg.key.remoteJid;
|
|
62
|
+
const say = async (text) => {
|
|
63
|
+
if (text && chat)
|
|
64
|
+
await sock.sendMessage(chat, { text }, { quoted: msg });
|
|
65
|
+
};
|
|
66
|
+
const session = sessions.get(token);
|
|
67
|
+
if (!session || session.expiresAt < now()) {
|
|
68
|
+
sessions.delete(token);
|
|
69
|
+
await say(session ? session.expired : DEFAULT_EXPIRED);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const sender = await sock.getSender(msg);
|
|
73
|
+
if (!(await isAllowed(session, sender, msg))) {
|
|
74
|
+
await say(session.denied);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
session.expiresAt = now() + session.ttlMs;
|
|
78
|
+
try {
|
|
79
|
+
await session.handle({ msg, reply, sender }, rest.join(':'));
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger?.warn({ error }, 'an interactive button handler failed');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const idFor = (token, payload) => `${PREFIX}${token}:${payload}`;
|
|
86
|
+
return {
|
|
87
|
+
/**
|
|
88
|
+
* Asks yes / no with two buttons and returns `true` or `false`. Only the person who wrote
|
|
89
|
+
* the command can answer (change it with `who`). `false` also when time runs out.
|
|
90
|
+
*/
|
|
91
|
+
confirm: async (msg, text, options = {}) => {
|
|
92
|
+
const jid = chatOf(msg);
|
|
93
|
+
const owner = await sock.getSender(msg);
|
|
94
|
+
const yes = options.yes ?? 'โ
Sรญ';
|
|
95
|
+
const no = options.no ?? 'โ No';
|
|
96
|
+
const timeoutMs = options.timeoutMs ?? 30000;
|
|
97
|
+
let sent;
|
|
98
|
+
let done = false;
|
|
99
|
+
let finish = () => undefined;
|
|
100
|
+
const result = new Promise(resolve => {
|
|
101
|
+
const timer = setTimeout(() => {
|
|
102
|
+
sessions.delete(token);
|
|
103
|
+
finish(false, 'โ Tiempo agotado');
|
|
104
|
+
}, timeoutMs);
|
|
105
|
+
finish = (answer, label) => {
|
|
106
|
+
if (done)
|
|
107
|
+
return;
|
|
108
|
+
done = true;
|
|
109
|
+
clearTimeout(timer);
|
|
110
|
+
resolve(answer);
|
|
111
|
+
if (sent)
|
|
112
|
+
quiet(sock.disableButtons(sent, `${text}\n\n${label}`));
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const token = newSession(owner, { ...options, ttlMs: timeoutMs }, timeoutMs, async (_tap, payload) => {
|
|
116
|
+
sessions.delete(token);
|
|
117
|
+
finish(payload === 'y', payload === 'y' ? `โบ ${yes}` : `โบ ${no}`);
|
|
118
|
+
});
|
|
119
|
+
try {
|
|
120
|
+
sent = await sock.sendButtons(jid, {
|
|
121
|
+
text,
|
|
122
|
+
footer: options.footer,
|
|
123
|
+
buttons: [
|
|
124
|
+
{ text: yes, id: idFor(token, 'y') },
|
|
125
|
+
{ text: no, id: idFor(token, 'n') }
|
|
126
|
+
]
|
|
127
|
+
}, { quoted: msg });
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
sessions.delete(token);
|
|
131
|
+
done = true;
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
},
|
|
136
|
+
/**
|
|
137
|
+
* Shows a long list in pages with "Anterior / Siguiente" buttons. Each page is a new message
|
|
138
|
+
* and the buttons of the previous one are removed. Returns the first page that was sent.
|
|
139
|
+
*/
|
|
140
|
+
paginate: async (msg, items, options = {}) => {
|
|
141
|
+
const jid = chatOf(msg);
|
|
142
|
+
if (!items.length) {
|
|
143
|
+
return sock.sendMessage(jid, { text: options.empty ?? 'No hay nada que mostrar.' }, { quoted: msg });
|
|
144
|
+
}
|
|
145
|
+
const perPage = Math.max(1, Math.floor(options.perPage ?? 5));
|
|
146
|
+
const pages = Math.ceil(items.length / perPage);
|
|
147
|
+
const owner = await sock.getSender(msg);
|
|
148
|
+
let last;
|
|
149
|
+
let token = '';
|
|
150
|
+
const show = async (page, quoted) => {
|
|
151
|
+
const start = page * perPage;
|
|
152
|
+
const lines = items
|
|
153
|
+
.slice(start, start + perPage)
|
|
154
|
+
.map((item, index) => options.format ? options.format(item, start + index) : `${start + index + 1}. ${String(item)}`);
|
|
155
|
+
const text = `${options.title ? `${options.title}\n\n` : ''}${lines.join('\n')}`;
|
|
156
|
+
const buttons = [];
|
|
157
|
+
if (page > 0)
|
|
158
|
+
buttons.push({ text: options.prevText ?? 'โ Anterior', id: idFor(token, `go:${page - 1}`) });
|
|
159
|
+
if (page < pages - 1)
|
|
160
|
+
buttons.push({ text: options.nextText ?? 'Siguiente โถ', id: idFor(token, `go:${page + 1}`) });
|
|
161
|
+
const footer = `${options.footer ? `${options.footer} ยท ` : ''}Pรกgina ${page + 1} de ${pages}`;
|
|
162
|
+
const sent = buttons.length
|
|
163
|
+
? await sock.sendButtons(jid, { text, footer, buttons }, { quoted })
|
|
164
|
+
: await sock.sendMessage(jid, { text, footer }, { quoted });
|
|
165
|
+
if (last)
|
|
166
|
+
quiet(sock.disableButtons(last));
|
|
167
|
+
last = sent;
|
|
168
|
+
return sent;
|
|
169
|
+
};
|
|
170
|
+
if (pages > 1) {
|
|
171
|
+
token = newSession(owner, options, 120000, async (tap, payload) => {
|
|
172
|
+
const page = Number(payload.replace('go:', ''));
|
|
173
|
+
if (Number.isInteger(page) && page >= 0 && page < pages)
|
|
174
|
+
await show(page, tap.msg);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
return await show(0, msg);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
sessions.delete(token);
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* A menu with sub-menus. Every level is a dropdown list; sub-menus get a "Volver" row.
|
|
187
|
+
* WhatsApp usually allows about 10 rows per list: split bigger ones into sub-menus.
|
|
188
|
+
*/
|
|
189
|
+
menu: async (msg, definition) => {
|
|
190
|
+
if (!definition.items?.length)
|
|
191
|
+
throw new Boom('menu needs at least one item', { statusCode: 400 });
|
|
192
|
+
const jid = chatOf(msg);
|
|
193
|
+
const owner = await sock.getSender(msg);
|
|
194
|
+
const root = { title: definition.title ?? 'Menรบ', text: definition.text, items: definition.items };
|
|
195
|
+
const nodeAt = (path) => {
|
|
196
|
+
let node = root;
|
|
197
|
+
for (const part of path ? path.split('.') : []) {
|
|
198
|
+
node = node?.items?.[Number(part)];
|
|
199
|
+
}
|
|
200
|
+
return node;
|
|
201
|
+
};
|
|
202
|
+
let token = '';
|
|
203
|
+
const showLevel = async (path, quoted) => {
|
|
204
|
+
const node = nodeAt(path);
|
|
205
|
+
if (!node?.items?.length)
|
|
206
|
+
return undefined;
|
|
207
|
+
const rows = node.items.map((child, index) => ({
|
|
208
|
+
title: child.title,
|
|
209
|
+
description: child.description,
|
|
210
|
+
id: idFor(token, path ? `${path}.${index}` : String(index))
|
|
211
|
+
}));
|
|
212
|
+
if (path) {
|
|
213
|
+
const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : '';
|
|
214
|
+
rows.push({
|
|
215
|
+
title: definition.backText ?? 'โฌ
Volver',
|
|
216
|
+
description: undefined,
|
|
217
|
+
id: idFor(token, `b${parent}`)
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return sock.sendButtons(jid, {
|
|
221
|
+
title: definition.title,
|
|
222
|
+
text: node.text ?? definition.text ?? node.title,
|
|
223
|
+
footer: definition.footer,
|
|
224
|
+
buttons: [{ text: definition.buttonText ?? 'Ver opciones', sections: [{ title: node.title, rows }] }]
|
|
225
|
+
}, { quoted });
|
|
226
|
+
};
|
|
227
|
+
token = newSession(owner, definition, 10 * 60000, async (tap, payload) => {
|
|
228
|
+
if (payload.startsWith('b')) {
|
|
229
|
+
await showLevel(payload.slice(1), tap.msg);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const node = nodeAt(payload);
|
|
233
|
+
if (!node)
|
|
234
|
+
return;
|
|
235
|
+
if (node.items?.length) {
|
|
236
|
+
await showLevel(payload, tap.msg);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (node.text)
|
|
240
|
+
await sock.sendMessage(chatOf(tap.msg), { text: node.text }, { quoted: tap.msg });
|
|
241
|
+
const titles = [];
|
|
242
|
+
let walk = root;
|
|
243
|
+
for (const part of payload.split('.')) {
|
|
244
|
+
walk = walk?.items?.[Number(part)];
|
|
245
|
+
if (walk)
|
|
246
|
+
titles.push(walk.title);
|
|
247
|
+
}
|
|
248
|
+
await node.run?.({ ...tap, path: titles });
|
|
249
|
+
});
|
|
250
|
+
try {
|
|
251
|
+
return await showLevel('', msg);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
sessions.delete(token);
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* `sendButtons` where only some people can tap. Others get a short "this is not for you".
|
|
260
|
+
* Quick-reply buttons and dropdown rows are guarded; URL / call / copy buttons act by themselves.
|
|
261
|
+
*/
|
|
262
|
+
sendGuardedButtons: async (msg, options, onTap) => {
|
|
263
|
+
const jid = chatOf(msg);
|
|
264
|
+
const owner = await sock.getSender(msg);
|
|
265
|
+
const originals = new Map();
|
|
266
|
+
let last;
|
|
267
|
+
const token = newSession(owner, options, 10 * 60000, async (tap, payload) => {
|
|
268
|
+
const id = originals.get(payload);
|
|
269
|
+
if (id === undefined)
|
|
270
|
+
return;
|
|
271
|
+
if (options.once) {
|
|
272
|
+
sessions.delete(token);
|
|
273
|
+
if (last)
|
|
274
|
+
quiet(sock.disableButtons(last));
|
|
275
|
+
}
|
|
276
|
+
await onTap({ ...tap, id });
|
|
277
|
+
});
|
|
278
|
+
const guard = (id) => {
|
|
279
|
+
const key = String(originals.size);
|
|
280
|
+
originals.set(key, id);
|
|
281
|
+
return idFor(token, key);
|
|
282
|
+
};
|
|
283
|
+
const rest = { ...options };
|
|
284
|
+
for (const key of ['once', 'who', 'denied', 'expired', 'ttlMs'])
|
|
285
|
+
delete rest[key];
|
|
286
|
+
const buttons = options.buttons.map(button => {
|
|
287
|
+
const spec = { ...button };
|
|
288
|
+
if (typeof spec.id === 'string')
|
|
289
|
+
spec.id = guard(spec.id);
|
|
290
|
+
if (Array.isArray(spec.sections)) {
|
|
291
|
+
spec.sections = spec.sections.map((section) => ({
|
|
292
|
+
...section,
|
|
293
|
+
rows: section.rows?.map(row => {
|
|
294
|
+
const original = row.id ?? row.rowId;
|
|
295
|
+
return typeof original === 'string' ? { ...row, id: guard(original) } : row;
|
|
296
|
+
})
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
return spec;
|
|
300
|
+
});
|
|
301
|
+
try {
|
|
302
|
+
last = await sock.sendButtons(jid, { ...rest, buttons }, { quoted: msg });
|
|
303
|
+
return last;
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
sessions.delete(token);
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
/**
|
|
311
|
+
* Sends something with a "๐ Otra vez" button. Each tap sends it again (a function gives a new
|
|
312
|
+
* result every time, e.g. a random phrase) and removes the button from the older message.
|
|
313
|
+
*/
|
|
314
|
+
sendRepeatable: async (msg, source, options = {}) => {
|
|
315
|
+
const jid = chatOf(msg);
|
|
316
|
+
const owner = await sock.getSender(msg);
|
|
317
|
+
const max = options.maxRepeats ?? 10;
|
|
318
|
+
let repeats = 0;
|
|
319
|
+
let last;
|
|
320
|
+
let token = '';
|
|
321
|
+
const sendOne = async (quoted) => {
|
|
322
|
+
const raw = typeof source === 'function' ? await source() : source;
|
|
323
|
+
const content = typeof raw === 'string' ? { text: raw } : { ...raw };
|
|
324
|
+
const footer = content.footer ?? options.footer;
|
|
325
|
+
const sent = repeats < max
|
|
326
|
+
? await sock.sendButtons(jid, {
|
|
327
|
+
...content,
|
|
328
|
+
footer,
|
|
329
|
+
buttons: [{ text: options.buttonText ?? '๐ Otra vez', id: idFor(token, 'again') }]
|
|
330
|
+
}, { quoted })
|
|
331
|
+
: await sock.sendMessage(jid, { ...content, footer }, { quoted });
|
|
332
|
+
if (last)
|
|
333
|
+
quiet(sock.disableButtons(last));
|
|
334
|
+
last = sent;
|
|
335
|
+
return sent;
|
|
336
|
+
};
|
|
337
|
+
token = newSession(owner, { who: 'anyone', ...options }, 10 * 60000, async (tap) => {
|
|
338
|
+
repeats += 1;
|
|
339
|
+
await sendOne(tap.msg);
|
|
340
|
+
});
|
|
341
|
+
try {
|
|
342
|
+
return await sendOne(msg);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
sessions.delete(token);
|
|
346
|
+
throw error;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/Utils/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAqHjC,MAAM,MAAM,GAAG,MAAM,CAAA;AACrB,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,MAAM,cAAc,GAAG,8BAA8B,CAAA;AACrD,MAAM,eAAe,GAAG,mDAAmD,CAAA;AAE3E,MAAM,UAAU,GAAG,CAAC,CAAa,EAAE,CAAa,EAAE,EAAE,CACnD,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC,CAA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,CAAA;YACvB,CAAC,CAAC,CAAA;YAEF,IAAI,CAAC;gBACJ,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;YAC1B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBACtB,MAAM,KAAK,CAAA;YACZ,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { WAMessage } from '../Types/index.js';
|
|
2
|
+
import type { ILogger } from './logger.js';
|
|
3
|
+
declare const LEVELS: readonly ["trace", "debug", "info", "warn", "error"];
|
|
4
|
+
type Level = (typeof LEVELS)[number];
|
|
5
|
+
export type PrettyLoggerOptions = {
|
|
6
|
+
/** lowest level shown. Default 'info' */
|
|
7
|
+
level?: Level;
|
|
8
|
+
/** colors in the terminal. Default true (off when NO_COLOR is set) */
|
|
9
|
+
color?: boolean;
|
|
10
|
+
/** where lines go. Default console.log */
|
|
11
|
+
write?: (line: string) => void;
|
|
12
|
+
/** clock, replaceable for tests */
|
|
13
|
+
now?: () => Date;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A logger that prints one readable line per entry (`12:30:01 โ texto`) instead of JSON, and
|
|
17
|
+
* rewrites well-known errors in plain Spanish. Pass it as `logger` in the socket config.
|
|
18
|
+
*/
|
|
19
|
+
export declare const makePrettyLogger: ({ level, color, write, now }?: PrettyLoggerOptions) => ILogger;
|
|
20
|
+
/** the visible text of a message, cut to `max` characters; media shows its type */
|
|
21
|
+
export declare const previewMessage: (msg: WAMessage, max?: number) => string;
|
|
22
|
+
type LogSocket = {
|
|
23
|
+
ev: {
|
|
24
|
+
on: (event: string, handler: (data: any) => void) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* One line per incoming message and per connection change, ready for a console or a hosting panel:
|
|
29
|
+
* `12:30:01 ๐ฉ grupo ยท 51925679896 ยท Amilcar: .ping`
|
|
30
|
+
*/
|
|
31
|
+
export declare const attachPrettyEvents: (sock: LogSocket, write?: (line: string) => void) => void;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=pretty-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-log.d.ts","sourceRoot":"","sources":["../../src/Utils/pretty-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGvC,QAAA,MAAM,MAAM,sDAAuD,CAAA;AACnE,KAAK,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpC,MAAM,MAAM,mBAAmB,GAAG;IACjC,yCAAyC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,0CAA0C;IAC1C,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAkCD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,+BAK9B,mBAAwB,KAAG,OA6B7B,CAAA;AAKD,mFAAmF;AACnF,eAAO,MAAM,cAAc,GAAI,KAAK,SAAS,EAAE,YAAQ,KAAG,MAmBzD,CAAA;AAED,KAAK,SAAS,GAAG;IAChB,EAAE,EAAE;QAAE,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,CAAA;KAAE,CAAA;CACjE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,SAAS,EAAE,QAAO,CAAC,IAAI,EAAE,MAAM,KAAK,IAAgC,SA6B5G,CAAA"}
|