@adriangalilea/utils 0.7.0 → 0.9.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 (81) hide show
  1. package/README.md +29 -5
  2. package/dist/bot/access-control.d.ts +106 -62
  3. package/dist/bot/access-control.d.ts.map +1 -1
  4. package/dist/bot/access-control.js +255 -146
  5. package/dist/bot/access-control.js.map +1 -1
  6. package/dist/bot/index.d.ts +3 -0
  7. package/dist/bot/index.d.ts.map +1 -1
  8. package/dist/bot/index.js +3 -0
  9. package/dist/bot/index.js.map +1 -1
  10. package/dist/bot/kit.d.ts.map +1 -1
  11. package/dist/bot/kit.js +6 -0
  12. package/dist/bot/kit.js.map +1 -1
  13. package/dist/bot/language.d.ts +305 -0
  14. package/dist/bot/language.d.ts.map +1 -0
  15. package/dist/bot/language.js +250 -0
  16. package/dist/bot/language.js.map +1 -0
  17. package/dist/bot/menu.d.ts +189 -0
  18. package/dist/bot/menu.d.ts.map +1 -0
  19. package/dist/bot/menu.js +331 -0
  20. package/dist/bot/menu.js.map +1 -0
  21. package/dist/bot/message-history.d.ts +259 -0
  22. package/dist/bot/message-history.d.ts.map +1 -0
  23. package/dist/bot/message-history.js +111 -0
  24. package/dist/bot/message-history.js.map +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +2 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/say/index.d.ts +62 -0
  30. package/dist/say/index.d.ts.map +1 -0
  31. package/dist/say/index.js +59 -0
  32. package/dist/say/index.js.map +1 -0
  33. package/package.json +17 -1
  34. package/dist/currency/crypto-symbols-data.d.ts +0 -10
  35. package/dist/currency/crypto-symbols-data.d.ts.map +0 -1
  36. package/dist/currency/crypto-symbols-data.js +0 -13765
  37. package/dist/currency/crypto-symbols-data.js.map +0 -1
  38. package/dist/currency/crypto-symbols.d.ts +0 -20
  39. package/dist/currency/crypto-symbols.d.ts.map +0 -1
  40. package/dist/currency/crypto-symbols.js +0 -23
  41. package/dist/currency/crypto-symbols.js.map +0 -1
  42. package/dist/currency/download-crypto-list.d.ts +0 -10
  43. package/dist/currency/download-crypto-list.d.ts.map +0 -1
  44. package/dist/currency/download-crypto-list.js +0 -69
  45. package/dist/currency/download-crypto-list.js.map +0 -1
  46. package/dist/currency/index.d.ts +0 -84
  47. package/dist/currency/index.d.ts.map +0 -1
  48. package/dist/currency/index.js +0 -230
  49. package/dist/currency/index.js.map +0 -1
  50. package/dist/dir.d.ts +0 -40
  51. package/dist/dir.d.ts.map +0 -1
  52. package/dist/dir.js +0 -108
  53. package/dist/dir.js.map +0 -1
  54. package/dist/file.d.ts +0 -53
  55. package/dist/file.d.ts.map +0 -1
  56. package/dist/file.js +0 -211
  57. package/dist/file.js.map +0 -1
  58. package/dist/format.d.ts +0 -40
  59. package/dist/format.d.ts.map +0 -1
  60. package/dist/format.js +0 -83
  61. package/dist/format.js.map +0 -1
  62. package/dist/kev.d.ts +0 -149
  63. package/dist/kev.d.ts.map +0 -1
  64. package/dist/kev.js +0 -761
  65. package/dist/kev.js.map +0 -1
  66. package/dist/log.d.ts +0 -91
  67. package/dist/log.d.ts.map +0 -1
  68. package/dist/log.js +0 -300
  69. package/dist/log.js.map +0 -1
  70. package/dist/logger.d.ts +0 -91
  71. package/dist/logger.d.ts.map +0 -1
  72. package/dist/logger.js +0 -269
  73. package/dist/logger.js.map +0 -1
  74. package/dist/path.d.ts +0 -67
  75. package/dist/path.d.ts.map +0 -1
  76. package/dist/path.js +0 -107
  77. package/dist/path.js.map +0 -1
  78. package/dist/project.d.ts +0 -35
  79. package/dist/project.d.ts.map +0 -1
  80. package/dist/project.js +0 -154
  81. package/dist/project.js.map +0 -1
@@ -0,0 +1,331 @@
1
+ /**
2
+ * Composable settings menu — registers a single slash command, renders
3
+ * an `InlineKeyboard`, routes callbacks. Features (language, history,
4
+ * etc.) contribute items; the bot builder adds custom items inline.
5
+ *
6
+ * ## Why menu is a separate primitive
7
+ *
8
+ * The user-facing menu is just UI — composing items. Features (per-user
9
+ * state, recording, gates) have their OWN runtime behaviour independent
10
+ * of any menu.
11
+ *
12
+ * ## GDPR rights (Forget / Export)
13
+ *
14
+ * If you pass `personalData: { storage }`, the menu adds two buttons:
15
+ *
16
+ * - 🗑 Forget my data — `storage.delete(sessionKey(userId))`
17
+ * - 📥 Export my data — `storage.get(sessionKey(userId))` → JSON file
18
+ *
19
+ * Because all per-user state across our plugins lives in ONE shared
20
+ * session record (see `bot/language`, `bot/message-history`), wiping
21
+ * or exporting that single key covers everything in one shot. No
22
+ * registry, no cascade, no per-plugin coordination.
23
+ *
24
+ * The `sessionKey` option defaults to `String(userId)` — matching
25
+ * `@gramio/session`'s default `getSessionKey: (ctx) => `${ctx.senderId}`.
26
+ * If you customize the session's `getSessionKey`, pass a matching
27
+ * function here.
28
+ *
29
+ * ## Privacy URL
30
+ *
31
+ * `privacy` defaults to [Telegram's Standard Bot Privacy Policy](https://telegram.org/privacy-tpa).
32
+ * Override when you retain content or process data beyond what the
33
+ * standard covers.
34
+ *
35
+ * Peer deps: `gramio`, `@gramio/storage`.
36
+ *
37
+ * @example Personal LLM bot — language only, no retention
38
+ *
39
+ * import { language } from '@adriangalilea/utils/bot/language'
40
+ * import { botMenu } from '@adriangalilea/utils/bot/menu'
41
+ *
42
+ * const lang = language({ session: userSession, supported: ['en','es'] as const, default: 'en' })
43
+ *
44
+ * const menu = botMenu({
45
+ * command: 'settings',
46
+ * description: 'Open settings',
47
+ * adminContact: '@adriangalilea',
48
+ * items: [lang.menuItem],
49
+ * })
50
+ *
51
+ * bot.extend(userSession).extend(lang.plugin).extend(menu.plugin)
52
+ *
53
+ * @example Bot with retention — adds Forget/Export
54
+ *
55
+ * const menu = botMenu({
56
+ * command: 'settings',
57
+ * description: 'Open settings',
58
+ * adminContact: '@adriangalilea',
59
+ * privacy: 'https://yourbot.com/privacy',
60
+ * personalData: { storage }, // ← enables Forget/Export
61
+ * items: [lang.menuItem],
62
+ * })
63
+ *
64
+ * bot
65
+ * .extend(userSession)
66
+ * .extend(history.plugin)
67
+ * .extend(menu.plugin)
68
+ */
69
+ import { CallbackData, InlineKeyboard, Plugin, } from 'gramio';
70
+ import { say } from '../say/index.js';
71
+ const FALLBACK_LANG = 'en';
72
+ const ctxLang = (ctx) => ctx.session?.language ?? FALLBACK_LANG;
73
+ const DEFAULT_COMMAND = 'settings';
74
+ const DEFAULT_DESCRIPTION = 'Open settings menu';
75
+ const DEFAULT_PRIVACY_URL = 'https://telegram.org/privacy-tpa';
76
+ const DEFAULT_HEADER = { en: '⚙️ Settings', es: '⚙️ Ajustes' };
77
+ const DEFAULT_SESSION_KEY = (userId) => String(userId);
78
+ // ─── callback data schemas ─────────────────────────────────────────
79
+ const navCb = new CallbackData('mNav').string('path');
80
+ const actCb = new CallbackData('mAct').string('path');
81
+ const forgetConfirmCb = new CallbackData('mFcfm');
82
+ const forgetCancelCb = new CallbackData('mFcnl');
83
+ const exportCb = new CallbackData('mExp');
84
+ export class BotMenu {
85
+ /** @internal */
86
+ _items;
87
+ /** @internal */
88
+ _opts;
89
+ constructor(opts) {
90
+ this._items = [...(opts.items ?? [])];
91
+ this._opts = {
92
+ command: opts.command ?? DEFAULT_COMMAND,
93
+ description: opts.description ?? DEFAULT_DESCRIPTION,
94
+ privacy: opts.privacy ?? DEFAULT_PRIVACY_URL,
95
+ header: opts.header ?? DEFAULT_HEADER,
96
+ adminContact: opts.adminContact,
97
+ personalData: opts.personalData
98
+ ? {
99
+ storage: opts.personalData.storage,
100
+ sessionKey: opts.personalData.sessionKey ?? DEFAULT_SESSION_KEY,
101
+ }
102
+ : null,
103
+ };
104
+ }
105
+ /** Append a custom item. Mutates the menu. */
106
+ add(item) {
107
+ this._items.push(item);
108
+ return this;
109
+ }
110
+ /** The gramio plugin: registers the slash command + all callback handlers. */
111
+ get plugin() {
112
+ return buildMenuPlugin(this);
113
+ }
114
+ }
115
+ export const botMenu = (opts) => new BotMenu(opts);
116
+ // ─── internal: rendering + plugin ──────────────────────────────────
117
+ const labelOf = (l, ctx) => {
118
+ const resolved = typeof l === 'function' ? l(ctx) : l;
119
+ if (typeof resolved === 'string')
120
+ return resolved;
121
+ return say(resolved, ctxLang(ctx));
122
+ };
123
+ const itemsForPath = (root, path) => {
124
+ if (path.length === 0)
125
+ return root;
126
+ const [head, ...rest] = path;
127
+ const found = root.find((i) => i.id === head);
128
+ if (!found || !('submenu' in found))
129
+ return null;
130
+ return itemsForPath(found.submenu, rest);
131
+ };
132
+ const itemForPath = (root, path) => {
133
+ if (path.length === 0)
134
+ return null;
135
+ let current = root;
136
+ let last;
137
+ for (const segment of path) {
138
+ if (!current)
139
+ return null;
140
+ last = current.find((i) => i.id === segment);
141
+ if (!last)
142
+ return null;
143
+ current = 'submenu' in last ? last.submenu : undefined;
144
+ }
145
+ return last ?? null;
146
+ };
147
+ const renderKeyboard = (menu, items, ctx, parentPath) => {
148
+ const kb = new InlineKeyboard();
149
+ const sorted = [...items]
150
+ .filter((i) => (i.visible ? i.visible(ctx) : true))
151
+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
152
+ for (const item of sorted) {
153
+ const path = [...parentPath, item.id].join('.');
154
+ const label = labelOf(item.label, ctx);
155
+ if ('action' in item) {
156
+ kb.text(label, actCb.pack({ path }));
157
+ }
158
+ else if ('url' in item) {
159
+ kb.url(label, item.url);
160
+ }
161
+ else {
162
+ kb.text(label, navCb.pack({ path }));
163
+ }
164
+ kb.row();
165
+ }
166
+ const lang = ctxLang(ctx);
167
+ if (parentPath.length === 0) {
168
+ // GDPR rights buttons at the root view.
169
+ if (menu._opts.personalData) {
170
+ kb.text(say({ en: '🗑 Forget my data', es: '🗑 Olvidar mis datos' }, lang), actCb.pack({ path: '_forget' }));
171
+ kb.row();
172
+ kb.text(say({ en: '📥 Export my data', es: '📥 Exportar mis datos' }, lang), exportCb.pack({}));
173
+ kb.row();
174
+ }
175
+ // Privacy link.
176
+ kb.url(say({ en: '📖 Privacy', es: '📖 Privacidad' }, lang), menu._opts.privacy);
177
+ kb.row();
178
+ }
179
+ else {
180
+ const backPath = parentPath.slice(0, -1).join('.');
181
+ kb.text(say({ en: '⬅️ Back', es: '⬅️ Volver' }, lang), navCb.pack({ path: backPath || '_root' }));
182
+ }
183
+ return kb;
184
+ };
185
+ const renderConfirmForget = (lang) => new InlineKeyboard()
186
+ .text(say({ en: '✅ Confirm delete', es: '✅ Confirmar borrado' }, lang), forgetConfirmCb.pack({}))
187
+ .row()
188
+ .text(say({ en: '⬅️ Cancel', es: '⬅️ Cancelar' }, lang), forgetCancelCb.pack({}));
189
+ const buildMenuPlugin = (menu) => {
190
+ const { command, description, header, personalData, adminContact } = menu._opts;
191
+ return new Plugin('@adriangalilea/utils/bot/menu')
192
+ .command(command, { description }, async (ctx) => {
193
+ const kb = renderKeyboard(menu, menu._items, ctx, []);
194
+ await ctx.send(labelOf(header, ctx), { reply_markup: kb });
195
+ })
196
+ // Navigate (root / submenu)
197
+ .callbackQuery(navCb, async (ctx) => {
198
+ const lang = ctxLang(ctx);
199
+ const raw = ctx.queryData.path;
200
+ const segments = raw === '_root' ? [] : raw.split('.');
201
+ const items = itemsForPath(menu._items, segments);
202
+ if (!items) {
203
+ await ctx.answer({
204
+ text: say({ en: 'Menu out of date.', es: 'Menú obsoleto.' }, lang),
205
+ });
206
+ return;
207
+ }
208
+ await ctx.answer({});
209
+ const kb = renderKeyboard(menu, items, ctx, segments);
210
+ try {
211
+ await ctx.editText(labelOf(header, ctx), { reply_markup: kb });
212
+ }
213
+ catch {
214
+ // message too old to edit
215
+ }
216
+ })
217
+ // Action items + the forget pre-confirmation
218
+ .callbackQuery(actCb, async (ctx) => {
219
+ const lang = ctxLang(ctx);
220
+ const raw = ctx.queryData.path;
221
+ if (raw === '_forget') {
222
+ await ctx.answer({});
223
+ try {
224
+ await ctx.editText(say({
225
+ en: '⚠️ Delete all your data?\n\n' +
226
+ 'This removes the session record we keep about you ' +
227
+ '(preferences, history, access state). Not reversible.',
228
+ es: '⚠️ ¿Borrar todos tus datos?\n\n' +
229
+ 'Esto elimina el registro de sesión que guardamos sobre ti ' +
230
+ '(preferencias, historial, estado de acceso). No se puede deshacer.',
231
+ }, lang), { reply_markup: renderConfirmForget(lang) });
232
+ }
233
+ catch {
234
+ /* ignore */
235
+ }
236
+ return;
237
+ }
238
+ const item = itemForPath(menu._items, raw.split('.'));
239
+ if (!item || !('action' in item)) {
240
+ await ctx.answer({
241
+ text: say({ en: 'Item not found.', es: 'Elemento no encontrado.' }, lang),
242
+ });
243
+ return;
244
+ }
245
+ await ctx.answer({});
246
+ await item.action(ctx);
247
+ })
248
+ // Forget — confirm path
249
+ .callbackQuery(forgetConfirmCb, async (ctx) => {
250
+ const lang = ctxLang(ctx);
251
+ if (!personalData) {
252
+ await ctx.answer({
253
+ text: say({ en: 'Not configured.', es: 'No configurado.' }, lang),
254
+ show_alert: true,
255
+ });
256
+ return;
257
+ }
258
+ const userId = ctx.from?.id;
259
+ if (userId === undefined)
260
+ return ctx.answer({
261
+ text: say({ en: 'No user.', es: 'Sin usuario.' }, lang),
262
+ });
263
+ try {
264
+ await personalData.storage.delete(personalData.sessionKey(userId));
265
+ await ctx.answer({
266
+ text: say({ en: 'Deleted.', es: 'Borrado.' }, lang),
267
+ });
268
+ try {
269
+ await ctx.editText(say({
270
+ en: '✅ Your data has been deleted.',
271
+ es: '✅ Tus datos han sido borrados.',
272
+ }, lang));
273
+ }
274
+ catch {
275
+ /* ignore */
276
+ }
277
+ }
278
+ catch (e) {
279
+ console.error('[menu] /forget failed', e);
280
+ await ctx.answer({
281
+ text: say({ en: 'Failed.', es: 'Falló.' }, lang),
282
+ });
283
+ await ctx.send(say({
284
+ en: `❌ Could not delete your data.\n\nPlease contact ${adminContact}.`,
285
+ es: `❌ No se han podido borrar tus datos.\n\nContacta con ${adminContact}.`,
286
+ }, lang));
287
+ }
288
+ })
289
+ .callbackQuery(forgetCancelCb, async (ctx) => {
290
+ await ctx.answer({});
291
+ const kb = renderKeyboard(menu, menu._items, ctx, []);
292
+ try {
293
+ await ctx.editText(labelOf(header, ctx), { reply_markup: kb });
294
+ }
295
+ catch {
296
+ /* ignore */
297
+ }
298
+ })
299
+ // Export — JSON file with the user's whole session record
300
+ .callbackQuery(exportCb, async (ctx) => {
301
+ const lang = ctxLang(ctx);
302
+ if (!personalData) {
303
+ await ctx.answer({
304
+ text: say({ en: 'Not configured.', es: 'No configurado.' }, lang),
305
+ show_alert: true,
306
+ });
307
+ return;
308
+ }
309
+ const userId = ctx.from?.id;
310
+ if (userId === undefined)
311
+ return ctx.answer({
312
+ text: say({ en: 'No user.', es: 'Sin usuario.' }, lang),
313
+ });
314
+ const record = (await personalData.storage.get(personalData.sessionKey(userId))) ?? {};
315
+ const file = new File([JSON.stringify({ userId, exportedAt: Date.now(), data: record }, null, 2)], `my-data-${userId}-${Date.now()}.json`, { type: 'application/json' });
316
+ await ctx.answer({});
317
+ try {
318
+ await ctx.sendDocument(file, {
319
+ caption: say({ en: '📥 Your data export', es: '📥 Exportación de tus datos' }, lang),
320
+ });
321
+ }
322
+ catch (e) {
323
+ console.error('[menu] /export sendDocument failed', e);
324
+ await ctx.send(say({
325
+ en: `❌ Could not send your data export.\n\nPlease contact ${adminContact}.`,
326
+ es: `❌ No se ha podido enviar la exportación de tus datos.\n\nContacta con ${adminContact}.`,
327
+ }, lang));
328
+ }
329
+ });
330
+ };
331
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/bot/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,MAAM,GACP,MAAM,QAAQ,CAAA;AAGf,OAAO,EAAE,GAAG,EAAiB,MAAM,iBAAiB,CAAA;AA4BpD,MAAM,aAAa,GAAG,IAAI,CAAA;AAC1B,M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 @@
1
+ /**
2
+ * Per-user rolling message history for GramIO bots — opt-in, with
3
+ * retention.
4
+ *
5
+ * Follows the same shared-session pattern as `bot/language`: the
6
+ * user creates a `session()` once at bot level, and each feature
7
+ * plugin (including this one) declares it as a dependency. gramio
8
+ * dedupes the runtime extension; the types flow.
9
+ *
10
+ * ## What this plugin owns
11
+ *
12
+ * - Appends each incoming user message to `ctx.session.history.items`
13
+ * - Prunes entries older than `retentionDays` or beyond `maxMessages`
14
+ * - Exposes a read-only pruned snapshot at `ctx.history` for handlers
15
+ *
16
+ * ## GDPR caveat — retention IS personal data
17
+ *
18
+ * Unlike `bot/language` (preference data, covered by Telegram's standard
19
+ * privacy policy), retaining user **message content** is the one thing
20
+ * the [standard policy](https://telegram.org/privacy-tpa) does NOT cover
21
+ * by default. If you extend `messageHistory`, you should:
22
+ *
23
+ * 1. Set a custom `privacy` URL on your `botMenu` describing what you
24
+ * retain and for how long.
25
+ * 2. Pass `personalData: { storage }` to your `botMenu` so 🗑 Forget
26
+ * and 📥 Export buttons appear — letting users see and delete
27
+ * the data you keep about them.
28
+ *
29
+ * These are not enforced by this plugin (would couple it to menu); they
30
+ * are documented as the bot author's legal responsibility.
31
+ *
32
+ * ## Storage layout
33
+ *
34
+ * Lives entirely inside the shared session record:
35
+ *
36
+ * storage[String(senderId)] = {
37
+ * ...other plugins' fields,
38
+ * history: { items: [HistoryEntry, ...] }
39
+ * }
40
+ *
41
+ * Peer deps: `gramio`, `@gramio/session`.
42
+ *
43
+ * @example
44
+ * import { Bot } from 'gramio'
45
+ * import { session } from '@gramio/session'
46
+ * import { redisStorage } from '@gramio/storage-redis'
47
+ * import { messageHistory } from '@adriangalilea/utils/bot/message-history'
48
+ *
49
+ * const userSession = session({ storage: redisStorage(), key: 'session', initial: () => ({}) })
50
+ *
51
+ * const history = messageHistory({
52
+ * session: userSession,
53
+ * maxMessages: 100,
54
+ * retentionDays: 7,
55
+ * })
56
+ *
57
+ * const bot = new Bot(process.env.BOT_TOKEN!)
58
+ * .extend(userSession)
59
+ * .extend(history.plugin)
60
+ * .command('replay', (ctx) => {
61
+ * const last = ctx.history.slice(-3).map((e) => e.text).join('\n---\n')
62
+ * return ctx.send(last || '(no history)')
63
+ * })
64
+ */
65
+ import { type DeriveDefinitions, Plugin } from 'gramio';
66
+ import { session } from '@gramio/session';
67
+ export type HistoryEntry = {
68
+ /** Telegram message id. */
69
+ messageId: number;
70
+ /** Unix seconds (Telegram's `message.date`). */
71
+ date: number;
72
+ /** Message text, or empty string if non-text. */
73
+ text: string;
74
+ };
75
+ export type HistoryRecord = {
76
+ items: HistoryEntry[];
77
+ };
78
+ /** Loose session shape — this plugin only touches the `history` field. */
79
+ type SessionLike = {
80
+ history?: HistoryRecord;
81
+ };
82
+ /** @internal — kept unexported so it doesn't clash with peers' refs. */
83
+ type HistorySessionPluginRef = ReturnType<typeof session<SessionLike, 'session'>>;
84
+ export type MessageHistoryOptions = {
85
+ /**
86
+ * Shared session plugin. This plugin extends it for the type flow;
87
+ * gramio's runtime dedup ensures it only runs once per update.
88
+ */
89
+ session: HistorySessionPluginRef;
90
+ /** Ring buffer cap. Oldest entries dropped when exceeded. */
91
+ maxMessages: number;
92
+ /** Entries older than this (in days) are dropped on read. */
93
+ retentionDays: number;
94
+ };
95
+ export type MessageHistoryFeature = {
96
+ plugin: ReturnType<typeof buildHistoryPlugin>;
97
+ };
98
+ type HistoryDerives = {
99
+ history: ReadonlyArray<HistoryEntry>;
100
+ };
101
+ export declare const messageHistory: (opts: MessageHistoryOptions) => MessageHistoryFeature;
102
+ declare const buildHistoryPlugin: (args: {
103
+ sessionPlugin: HistorySessionPluginRef;
104
+ maxMessages: number;
105
+ retentionDays: number;
106
+ }) => Plugin<{}, DeriveDefinitions & {
107
+ global: HistoryDerives;
108
+ } & {
109
+ message: {
110
+ session: SessionLike & {
111
+ $clear: () => Promise<void>;
112
+ };
113
+ };
114
+ channel_post: {
115
+ session: SessionLike & {
116
+ $clear: () => Promise<void>;
117
+ };
118
+ };
119
+ inline_query: {
120
+ session: SessionLike & {
121
+ $clear: () => Promise<void>;
122
+ };
123
+ };
124
+ chosen_inline_result: {
125
+ session: SessionLike & {
126
+ $clear: () => Promise<void>;
127
+ };
128
+ };
129
+ callback_query: {
130
+ session: SessionLike & {
131
+ $clear: () => Promise<void>;
132
+ };
133
+ };
134
+ shipping_query: {
135
+ session: SessionLike & {
136
+ $clear: () => Promise<void>;
137
+ };
138
+ };
139
+ pre_checkout_query: {
140
+ session: SessionLike & {
141
+ $clear: () => Promise<void>;
142
+ };
143
+ };
144
+ poll_answer: {
145
+ session: SessionLike & {
146
+ $clear: () => Promise<void>;
147
+ };
148
+ };
149
+ chat_join_request: {
150
+ session: SessionLike & {
151
+ $clear: () => Promise<void>;
152
+ };
153
+ };
154
+ new_chat_members: {
155
+ session: SessionLike & {
156
+ $clear: () => Promise<void>;
157
+ };
158
+ };
159
+ new_chat_title: {
160
+ session: SessionLike & {
161
+ $clear: () => Promise<void>;
162
+ };
163
+ };
164
+ new_chat_photo: {
165
+ session: SessionLike & {
166
+ $clear: () => Promise<void>;
167
+ };
168
+ };
169
+ delete_chat_photo: {
170
+ session: SessionLike & {
171
+ $clear: () => Promise<void>;
172
+ };
173
+ };
174
+ group_chat_created: {
175
+ session: SessionLike & {
176
+ $clear: () => Promise<void>;
177
+ };
178
+ };
179
+ message_auto_delete_timer_changed: {
180
+ session: SessionLike & {
181
+ $clear: () => Promise<void>;
182
+ };
183
+ };
184
+ migrate_to_chat_id: {
185
+ session: SessionLike & {
186
+ $clear: () => Promise<void>;
187
+ };
188
+ };
189
+ migrate_from_chat_id: {
190
+ session: SessionLike & {
191
+ $clear: () => Promise<void>;
192
+ };
193
+ };
194
+ pinned_message: {
195
+ session: SessionLike & {
196
+ $clear: () => Promise<void>;
197
+ };
198
+ };
199
+ invoice: {
200
+ session: SessionLike & {
201
+ $clear: () => Promise<void>;
202
+ };
203
+ };
204
+ successful_payment: {
205
+ session: SessionLike & {
206
+ $clear: () => Promise<void>;
207
+ };
208
+ };
209
+ chat_shared: {
210
+ session: SessionLike & {
211
+ $clear: () => Promise<void>;
212
+ };
213
+ };
214
+ proximity_alert_triggered: {
215
+ session: SessionLike & {
216
+ $clear: () => Promise<void>;
217
+ };
218
+ };
219
+ video_chat_scheduled: {
220
+ session: SessionLike & {
221
+ $clear: () => Promise<void>;
222
+ };
223
+ };
224
+ video_chat_started: {
225
+ session: SessionLike & {
226
+ $clear: () => Promise<void>;
227
+ };
228
+ };
229
+ video_chat_ended: {
230
+ session: SessionLike & {
231
+ $clear: () => Promise<void>;
232
+ };
233
+ };
234
+ video_chat_participants_invited: {
235
+ session: SessionLike & {
236
+ $clear: () => Promise<void>;
237
+ };
238
+ };
239
+ web_app_data: {
240
+ session: SessionLike & {
241
+ $clear: () => Promise<void>;
242
+ };
243
+ };
244
+ location: {
245
+ session: SessionLike & {
246
+ $clear: () => Promise<void>;
247
+ };
248
+ };
249
+ passport_data: {
250
+ session: SessionLike & {
251
+ $clear: () => Promise<void>;
252
+ };
253
+ };
254
+ } & {
255
+ message: HistoryDerives;
256
+ callback_query: HistoryDerives;
257
+ }, {}>;
258
+ export {};
259
+ //# sourceMappingURL=message-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-history.d.ts","sourceRoot":"","sources":["../../src/bot/message-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAIzC,MAAM,MAAM,YAAY,GAAG;IACzB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MA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