gramstax 0.0.1 → 0.0.2

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 (62) hide show
  1. package/dist/src/index.cjs +2 -0
  2. package/dist/src/index.cjs.map +1 -0
  3. package/dist/src/{core/bot.d.ts → index.d.cts} +500 -12
  4. package/dist/src/index.d.ts +1292 -5
  5. package/dist/src/index.js +2 -4
  6. package/dist/src/index.js.map +1 -0
  7. package/package.json +10 -9
  8. package/dist/package.json +0 -52
  9. package/dist/src/base/general.d.ts +0 -7
  10. package/dist/src/base/general.d.ts.map +0 -1
  11. package/dist/src/base/general.js +0 -15
  12. package/dist/src/base/guard.d.ts +0 -13
  13. package/dist/src/base/guard.d.ts.map +0 -1
  14. package/dist/src/base/guard.js +0 -8
  15. package/dist/src/base/index.d.ts +0 -4
  16. package/dist/src/base/index.d.ts.map +0 -1
  17. package/dist/src/base/index.js +0 -3
  18. package/dist/src/base/page.d.ts +0 -263
  19. package/dist/src/base/page.d.ts.map +0 -1
  20. package/dist/src/base/page.js +0 -805
  21. package/dist/src/cache/external.d.ts +0 -10
  22. package/dist/src/cache/external.d.ts.map +0 -1
  23. package/dist/src/cache/external.js +0 -16
  24. package/dist/src/cache/index.d.ts +0 -2
  25. package/dist/src/cache/index.d.ts.map +0 -1
  26. package/dist/src/cache/index.js +0 -1
  27. package/dist/src/core/bot.d.ts.map +0 -1
  28. package/dist/src/core/bot.js +0 -465
  29. package/dist/src/core/ctx.d.ts +0 -60
  30. package/dist/src/core/ctx.d.ts.map +0 -1
  31. package/dist/src/core/ctx.js +0 -175
  32. package/dist/src/core/index.d.ts +0 -3
  33. package/dist/src/core/index.d.ts.map +0 -1
  34. package/dist/src/core/index.js +0 -2
  35. package/dist/src/grammy/index.d.ts +0 -2
  36. package/dist/src/grammy/index.d.ts.map +0 -1
  37. package/dist/src/grammy/index.js +0 -1
  38. package/dist/src/index.d.ts.map +0 -1
  39. package/dist/src/template/engine.d.ts +0 -34
  40. package/dist/src/template/engine.d.ts.map +0 -1
  41. package/dist/src/template/engine.js +0 -122
  42. package/dist/src/template/index.d.ts +0 -3
  43. package/dist/src/template/index.d.ts.map +0 -1
  44. package/dist/src/template/index.js +0 -2
  45. package/dist/src/template/manager.d.ts +0 -111
  46. package/dist/src/template/manager.d.ts.map +0 -1
  47. package/dist/src/template/manager.js +0 -237
  48. package/src/base/general.ts +0 -17
  49. package/src/base/guard.ts +0 -10
  50. package/src/base/index.ts +0 -3
  51. package/src/base/page.ts +0 -1111
  52. package/src/cache/external.ts +0 -15
  53. package/src/cache/index.ts +0 -1
  54. package/src/core/bot.ts +0 -535
  55. package/src/core/ctx.ts +0 -177
  56. package/src/core/index.ts +0 -2
  57. package/src/grammy/index.ts +0 -1
  58. package/src/index.ts +0 -4
  59. package/src/template/engine.ts +0 -167
  60. package/src/template/index.ts +0 -2
  61. package/src/template/manager.ts +0 -280
  62. package/src/types/page.d.ts +0 -4
@@ -1,805 +0,0 @@
1
- import { Ctx } from "../core/ctx";
2
- import { InlineKeyboard, Keyboard } from "../grammy";
3
- export class BasePage extends Ctx {
4
- static template; // string html
5
- static data; // for external access (**.data). example StartPage.data.callbackData
6
- ctx;
7
- constructor(ctx) {
8
- super(ctx.ct, ctx.templateManager, ctx.cacheSession, ctx.cacheKeyboard);
9
- this.session = ctx?.ctx?.session || ctx.session; // set to this PageBase
10
- this.ctx = ctx?.ctx || ctx; // if have ctx.ctx (from Page.ctx) use it, otherwise ctx (from CtxBot)
11
- }
12
- // =============== build data
13
- static buildData(callback) {
14
- return {
15
- name: ``,
16
- callbackData: callback
17
- ? function (...args) {
18
- const params = callback(...args);
19
- return `${this.name}${params === undefined ? `` : `:${params}`}`;
20
- }
21
- : function () {
22
- return this?.name;
23
- }
24
- };
25
- }
26
- // =============== build keyboard
27
- buildInlineKeyboard(callback, params) {
28
- const tkey = this.data.name;
29
- if (params?.cache === true) {
30
- const key = `${tkey}:${this.languageCode}:inline`;
31
- const ckb = this.cacheKeyboard.get(key);
32
- if (!ckb) {
33
- const ikb = new InlineKeyboard();
34
- const arr = this.templateManager.getKeyboard(tkey, params?.baseId, this.languageCode, `inline`, params?.data);
35
- const rkb = callback(ikb, arr);
36
- this.cacheKeyboard.set(key, rkb);
37
- return rkb;
38
- }
39
- return ckb;
40
- }
41
- const ikb = new InlineKeyboard();
42
- const arr = this.templateManager.getKeyboard(tkey, params?.baseId, this.languageCode, `inline`, params?.data);
43
- const rkb = callback(ikb, arr);
44
- return rkb;
45
- }
46
- buildKeyboard(callback, params) {
47
- const tkey = this.data.name;
48
- if (params?.cache === true) {
49
- const key = `${tkey}:${this.languageCode}:default`;
50
- const ckb = this.cacheKeyboard.get(key);
51
- if (!ckb) {
52
- const kb = new Keyboard();
53
- const arr = this.templateManager.getKeyboard(tkey, params?.baseId, this.languageCode, `default`, params?.data);
54
- const rkb = callback(kb, arr);
55
- rkb.resized(true);
56
- this.cacheKeyboard.set(key, rkb);
57
- return rkb;
58
- }
59
- return ckb;
60
- }
61
- const kb = new Keyboard();
62
- const arr = this.templateManager.getKeyboard(tkey, params?.baseId, this.languageCode, `default`, params?.data);
63
- const rkb = callback(kb, arr);
64
- rkb.resized();
65
- return rkb;
66
- }
67
- // =============== session validate
68
- // callback
69
- validateSessionCallback(method, name) {
70
- if (method === undefined) {
71
- method = this.session.method;
72
- }
73
- return method === undefined ? false : method === this.buildSessionMethodCallback(name);
74
- }
75
- validateSessionCallbackPayload(method, name) {
76
- if (method === undefined) {
77
- method = this.session.method;
78
- }
79
- return method === undefined ? false : method === this.buildSessionMethodCallbackPayload(name);
80
- }
81
- // text
82
- validateSessionText(method, name) {
83
- if (method === undefined) {
84
- method = this.session.method;
85
- }
86
- return method === undefined ? false : method === this.buildSessionMethodText(name);
87
- }
88
- validateSessionTextPayload(method, name) {
89
- if (method === undefined) {
90
- method = this.session.method;
91
- }
92
- return method === undefined ? false : method === this.buildSessionMethodTextPayload(name);
93
- }
94
- validateSessionTextCommand(method, name) {
95
- if (method === undefined) {
96
- method = this.session.method;
97
- }
98
- return method === undefined ? false : method === this.buildSessionMethodTextCommand(name);
99
- }
100
- validateSessionTextCommandPayload(method, name) {
101
- if (method === undefined) {
102
- method = this.session.method;
103
- }
104
- return method === undefined ? false : method === this.buildSessionMethodTextCommandPayload(name);
105
- }
106
- validateSessionTextFree(method, name) {
107
- if (method === undefined) {
108
- method = this.session.method;
109
- }
110
- return method === undefined ? false : method === this.buildSessionMethodTextFree(name);
111
- }
112
- // photo
113
- validateSessionPhotoCaption(method, name) {
114
- if (method === undefined) {
115
- method = this.session.method;
116
- }
117
- return method === undefined ? false : method === this.buildSessionMethodPhotoCaption(name);
118
- }
119
- validateSessionPhotoCaptionPayload(method, name) {
120
- if (method === undefined) {
121
- method = this.session.method;
122
- }
123
- return method === undefined ? false : method === this.buildSessionMethodPhotoCaptionPayload(name);
124
- }
125
- validateSessionPhotoCaptionCommand(method, name) {
126
- if (method === undefined) {
127
- method = this.session.method;
128
- }
129
- return method === undefined ? false : method === this.buildSessionMethodPhotoCaptionCommand(name);
130
- }
131
- validateSessionPhotoCaptionCommandPayload(method, name) {
132
- if (method === undefined) {
133
- method = this.session.method;
134
- }
135
- return method === undefined ? false : method === this.buildSessionMethodPhotoCaptionCommandPayload(name);
136
- }
137
- validateSessionPhotoFree(method, name) {
138
- if (method === undefined) {
139
- method = this.session.method;
140
- }
141
- return method === undefined ? false : method === this.buildSessionMethodPhotoFree(name);
142
- }
143
- // video
144
- validateSessionVideoCaption(method, name) {
145
- if (method === undefined) {
146
- method = this.session.method;
147
- }
148
- return method === undefined ? false : method === this.buildSessionMethodVideoCaption(name);
149
- }
150
- validateSessionVideoCaptionPayload(method, name) {
151
- if (method === undefined) {
152
- method = this.session.method;
153
- }
154
- return method === undefined ? false : method === this.buildSessionMethodVideoCaptionPayload(name);
155
- }
156
- validateSessionVideoCaptionCommand(method, name) {
157
- if (method === undefined) {
158
- method = this.session.method;
159
- }
160
- return method === undefined ? false : method === this.buildSessionMethodVideoCaptionCommand(name);
161
- }
162
- validateSessionVideoCaptionCommandPayload(method, name) {
163
- if (method === undefined) {
164
- method = this.session.method;
165
- }
166
- return method === undefined ? false : method === this.buildSessionMethodVideoCaptionCommandPayload(name);
167
- }
168
- validateSessionVideoFree(method, name) {
169
- if (method === undefined) {
170
- method = this.session.method;
171
- }
172
- return method === undefined ? false : method === this.buildSessionMethodVideoFree(name);
173
- }
174
- // audio
175
- validateSessionAudioCaption(method, name) {
176
- if (method === undefined) {
177
- method = this.session.method;
178
- }
179
- return method === undefined ? false : method === this.buildSessionMethodAudioCaption(name);
180
- }
181
- validateSessionAudioCaptionPayload(method, name) {
182
- if (method === undefined) {
183
- method = this.session.method;
184
- }
185
- return method === undefined ? false : method === this.buildSessionMethodAudioCaptionPayload(name);
186
- }
187
- validateSessionAudioCaptionCommand(method, name) {
188
- if (method === undefined) {
189
- method = this.session.method;
190
- }
191
- return method === undefined ? false : method === this.buildSessionMethodAudioCaptionCommand(name);
192
- }
193
- validateSessionAudioCaptionCommandPayload(method, name) {
194
- if (method === undefined) {
195
- method = this.session.method;
196
- }
197
- return method === undefined ? false : method === this.buildSessionMethodAudioCaptionCommandPayload(name);
198
- }
199
- validateSessionAudioFree(method, name) {
200
- if (method === undefined) {
201
- method = this.session.method;
202
- }
203
- return method === undefined ? false : method === this.buildSessionMethodAudioFree(name);
204
- }
205
- // document
206
- validateSessionDocumentCaption(method, name) {
207
- if (method === undefined) {
208
- method = this.session.method;
209
- }
210
- return method === undefined ? false : method === this.buildSessionMethodDocumentCaption(name);
211
- }
212
- validateSessionDocumentCaptionPayload(method, name) {
213
- if (method === undefined) {
214
- method = this.session.method;
215
- }
216
- return method === undefined ? false : method === this.buildSessionMethodDocumentCaptionPayload(name);
217
- }
218
- validateSessionDocumentCaptionCommand(method, name) {
219
- if (method === undefined) {
220
- method = this.session.method;
221
- }
222
- return method === undefined ? false : method === this.buildSessionMethodDocumentCaptionCommand(name);
223
- }
224
- validateSessionDocumentCaptionCommandPayload(method, name) {
225
- if (method === undefined) {
226
- method = this.session.method;
227
- }
228
- return method === undefined ? false : method === this.buildSessionMethodDocumentCaptionCommandPayload(name);
229
- }
230
- validateSessionDocumentFree(method, name) {
231
- if (method === undefined) {
232
- method = this.session.method;
233
- }
234
- return method === undefined ? false : method === this.buildSessionMethodDocumentFree(name);
235
- }
236
- // animation
237
- validateSessionAnimationCaption(method, name) {
238
- if (method === undefined) {
239
- method = this.session.method;
240
- }
241
- return method === undefined ? false : method === this.buildSessionMethodAnimationCaption(name);
242
- }
243
- validateSessionAnimationCaptionPayload(method, name) {
244
- if (method === undefined) {
245
- method = this.session.method;
246
- }
247
- return method === undefined ? false : method === this.buildSessionMethodAnimationCaptionPayload(name);
248
- }
249
- validateSessionAnimationCaptionCommand(method, name) {
250
- if (method === undefined) {
251
- method = this.session.method;
252
- }
253
- return method === undefined ? false : method === this.buildSessionMethodAnimationCaptionCommand(name);
254
- }
255
- validateSessionAnimationCaptionCommandPayload(method, name) {
256
- if (method === undefined) {
257
- method = this.session.method;
258
- }
259
- return method === undefined ? false : method === this.buildSessionMethodAnimationCaptionCommandPayload(name);
260
- }
261
- validateSessionAnimationFree(method, name) {
262
- if (method === undefined) {
263
- method = this.session.method;
264
- }
265
- return method === undefined ? false : method === this.buildSessionMethodAnimationFree(name);
266
- }
267
- // voice
268
- validateSessionVoiceCaption(method, name) {
269
- if (method === undefined) {
270
- method = this.session.method;
271
- }
272
- return method === undefined ? false : method === this.buildSessionMethodVoiceCaption(name);
273
- }
274
- validateSessionVoiceCaptionPayload(method, name) {
275
- if (method === undefined) {
276
- method = this.session.method;
277
- }
278
- return method === undefined ? false : method === this.buildSessionMethodVoiceCaptionPayload(name);
279
- }
280
- validateSessionVoiceCaptionCommand(method, name) {
281
- if (method === undefined) {
282
- method = this.session.method;
283
- }
284
- return method === undefined ? false : method === this.buildSessionMethodVoiceCaptionCommand(name);
285
- }
286
- validateSessionVoiceCaptionCommandPayload(method, name) {
287
- if (method === undefined) {
288
- method = this.session.method;
289
- }
290
- return method === undefined ? false : method === this.buildSessionMethodVoiceCaptionCommandPayload(name);
291
- }
292
- validateSessionVoiceFree(method, name) {
293
- if (method === undefined) {
294
- method = this.session.method;
295
- }
296
- return method === undefined ? false : method === this.buildSessionMethodVoiceFree(name);
297
- }
298
- // video note
299
- validateSessionVideoNoteCaption(method, name) {
300
- if (method === undefined) {
301
- method = this.session.method;
302
- }
303
- return method === undefined ? false : method === this.buildSessionMethodVideoNoteCaption(name);
304
- }
305
- validateSessionVideoNoteCaptionPayload(method, name) {
306
- if (method === undefined) {
307
- method = this.session.method;
308
- }
309
- return method === undefined ? false : method === this.buildSessionMethodVideoNoteCaptionPayload(name);
310
- }
311
- validateSessionVideoNoteCaptionCommand(method, name) {
312
- if (method === undefined) {
313
- method = this.session.method;
314
- }
315
- return method === undefined ? false : method === this.buildSessionMethodVideoNoteCaptionCommand(name);
316
- }
317
- validateSessionVideoNoteCaptionCommandPayload(method, name) {
318
- if (method === undefined) {
319
- method = this.session.method;
320
- }
321
- return method === undefined ? false : method === this.buildSessionMethodVideoNoteCaptionCommandPayload(name);
322
- }
323
- validateSessionVideoNoteFree(method, name) {
324
- if (method === undefined) {
325
- method = this.session.method;
326
- }
327
- return method === undefined ? false : method === this.buildSessionMethodVideoNoteFree(name);
328
- }
329
- // sticker
330
- validateSessionStickerFree(method, name) {
331
- if (method === undefined) {
332
- method = this.session.method;
333
- }
334
- return method === undefined ? false : method === this.buildSessionMethodStickerFree(name);
335
- }
336
- // location
337
- validateSessionLocationFree(method, name) {
338
- if (method === undefined) {
339
- method = this.session.method;
340
- }
341
- return method === undefined ? false : method === this.buildSessionMethodLocationFree(name);
342
- }
343
- // contact
344
- validateSessionContactFree(method, name) {
345
- if (method === undefined) {
346
- method = this.session.method;
347
- }
348
- return method === undefined ? false : method === this.buildSessionMethodContactFree(name);
349
- }
350
- // =============== session set
351
- // callback
352
- sessionCallback(params, name) {
353
- return this.sessionSet(this.buildSessionMethodCallback(name), params);
354
- }
355
- sessionCallbackPayload(params, name) {
356
- return this.sessionSet(this.buildSessionMethodCallbackPayload(name), params);
357
- }
358
- // text
359
- sessionText(params, name) {
360
- return this.sessionSet(this.buildSessionMethodText(name), params);
361
- }
362
- sessionTextPayload(params, name) {
363
- return this.sessionSet(this.buildSessionMethodTextPayload(name), params);
364
- }
365
- sessionTextCommand(params, name) {
366
- return this.sessionSet(this.buildSessionMethodTextCommand(name), params);
367
- }
368
- sessionTextCommandPayload(params, name) {
369
- return this.sessionSet(this.buildSessionMethodTextCommandPayload(name), params);
370
- }
371
- sessionTextFree(params, name) {
372
- return this.sessionSet(this.buildSessionMethodTextFree(name), params);
373
- }
374
- // photo
375
- sessionPhotoCaption(params, name) {
376
- return this.sessionSet(this.buildSessionMethodPhotoCaption(name), params);
377
- }
378
- sessionPhotoCaptionPayload(params, name) {
379
- return this.sessionSet(this.buildSessionMethodPhotoCaptionPayload(name), params);
380
- }
381
- sessionPhotoCaptionCommand(params, name) {
382
- return this.sessionSet(this.buildSessionMethodPhotoCaptionCommand(name), params);
383
- }
384
- sessionPhotoCaptionCommandPayload(params, name) {
385
- return this.sessionSet(this.buildSessionMethodPhotoCaptionCommandPayload(name), params);
386
- }
387
- sessionPhotoFree(params, name) {
388
- return this.sessionSet(this.buildSessionMethodPhotoFree(name), params);
389
- }
390
- // video
391
- sessionVideoCaption(params, name) {
392
- return this.sessionSet(this.buildSessionMethodVideoCaption(name), params);
393
- }
394
- sessionVideoCaptionPayload(params, name) {
395
- return this.sessionSet(this.buildSessionMethodVideoCaptionPayload(name), params);
396
- }
397
- sessionVideoCaptionCommand(params, name) {
398
- return this.sessionSet(this.buildSessionMethodVideoCaptionCommand(name), params);
399
- }
400
- sessionVideoCaptionCommandPayload(params, name) {
401
- return this.sessionSet(this.buildSessionMethodVideoCaptionCommandPayload(name), params);
402
- }
403
- sessionVideoFree(params, name) {
404
- return this.sessionSet(this.buildSessionMethodVideoFree(name), params);
405
- }
406
- // audio
407
- sessionAudioCaption(params, name) {
408
- return this.sessionSet(this.buildSessionMethodAudioCaption(name), params);
409
- }
410
- sessionAudioCaptionPayload(params, name) {
411
- return this.sessionSet(this.buildSessionMethodAudioCaptionPayload(name), params);
412
- }
413
- sessionAudioCaptionCommand(params, name) {
414
- return this.sessionSet(this.buildSessionMethodAudioCaptionCommand(name), params);
415
- }
416
- sessionAudioCaptionCommandPayload(params, name) {
417
- return this.sessionSet(this.buildSessionMethodAudioCaptionCommandPayload(name), params);
418
- }
419
- sessionAudioFree(params, name) {
420
- return this.sessionSet(this.buildSessionMethodAudioFree(name), params);
421
- }
422
- // document
423
- sessionDocumentCaption(params, name) {
424
- return this.sessionSet(this.buildSessionMethodDocumentCaption(name), params);
425
- }
426
- sessionDocumentCaptionPayload(params, name) {
427
- return this.sessionSet(this.buildSessionMethodDocumentCaptionPayload(name), params);
428
- }
429
- sessionDocumentCaptionCommand(params, name) {
430
- return this.sessionSet(this.buildSessionMethodDocumentCaptionCommand(name), params);
431
- }
432
- sessionDocumentCaptionCommandPayload(params, name) {
433
- return this.sessionSet(this.buildSessionMethodDocumentCaptionCommandPayload(name), params);
434
- }
435
- sessionDocumentFree(params, name) {
436
- return this.sessionSet(this.buildSessionMethodDocumentFree(name), params);
437
- }
438
- // animation
439
- sessionAnimationCaption(params, name) {
440
- return this.sessionSet(this.buildSessionMethodAnimationCaption(name), params);
441
- }
442
- sessionAnimationCaptionPayload(params, name) {
443
- return this.sessionSet(this.buildSessionMethodAnimationCaptionPayload(name), params);
444
- }
445
- sessionAnimationCaptionCommand(params, name) {
446
- return this.sessionSet(this.buildSessionMethodAnimationCaptionCommand(name), params);
447
- }
448
- sessionAnimationCaptionCommandPayload(params, name) {
449
- return this.sessionSet(this.buildSessionMethodAnimationCaptionCommandPayload(name), params);
450
- }
451
- sessionAnimationFree(params, name) {
452
- return this.sessionSet(this.buildSessionMethodAnimationFree(name), params);
453
- }
454
- // voice
455
- sessionVoiceCaption(params, name) {
456
- return this.sessionSet(this.buildSessionMethodVoiceCaption(name), params);
457
- }
458
- sessionVoiceCaptionPayload(params, name) {
459
- return this.sessionSet(this.buildSessionMethodVoiceCaptionPayload(name), params);
460
- }
461
- sessionVoiceCaptionCommand(params, name) {
462
- return this.sessionSet(this.buildSessionMethodVoiceCaptionCommand(name), params);
463
- }
464
- sessionVoiceCaptionCommandPayload(params, name) {
465
- return this.sessionSet(this.buildSessionMethodVoiceCaptionCommandPayload(name), params);
466
- }
467
- sessionVoiceFree(params, name) {
468
- return this.sessionSet(this.buildSessionMethodVoiceFree(name), params);
469
- }
470
- // video note
471
- sessionVideoNoteCaption(params, name) {
472
- return this.sessionSet(this.buildSessionMethodVideoNoteCaption(name), params);
473
- }
474
- sessionVideoNoteCaptionPayload(params, name) {
475
- return this.sessionSet(this.buildSessionMethodVideoNoteCaptionPayload(name), params);
476
- }
477
- sessionVideoNoteCaptionCommand(params, name) {
478
- return this.sessionSet(this.buildSessionMethodVideoNoteCaptionCommand(name), params);
479
- }
480
- sessionVideoNoteCaptionCommandPayload(params, name) {
481
- return this.sessionSet(this.buildSessionMethodVideoNoteCaptionCommandPayload(name), params);
482
- }
483
- sessionVideoNoteFree(params, name) {
484
- return this.sessionSet(this.buildSessionMethodVideoNoteFree(name), params);
485
- }
486
- // sticker
487
- sessionStickerFree(params, name) {
488
- return this.sessionSet(this.buildSessionMethodStickerFree(name), params);
489
- }
490
- // location
491
- sessionLocationFree(params, name) {
492
- return this.sessionSet(this.buildSessionMethodLocationFree(name), params);
493
- }
494
- // contact
495
- sessionContactFree(params, name) {
496
- return this.sessionSet(this.buildSessionMethodContactFree(name), params);
497
- }
498
- // =============== session update to set
499
- // callback
500
- sessionToCallback(paramsAdd, name) {
501
- return this.sessionCallback({ ...this.session.params, ...paramsAdd }, name);
502
- }
503
- sessionToCallbackPayload(paramsAdd, name) {
504
- return this.sessionCallbackPayload({ ...this.session.params, ...paramsAdd }, name);
505
- }
506
- // text
507
- sessionToText(paramsAdd, name) {
508
- return this.sessionText({ ...this.session.params, ...paramsAdd }, name);
509
- }
510
- sessionToTextPayload(paramsAdd, name) {
511
- return this.sessionTextPayload({ ...this.session.params, ...paramsAdd }, name);
512
- }
513
- sessionToTextCommand(paramsAdd, name) {
514
- return this.sessionTextCommand({ ...this.session.params, ...paramsAdd }, name);
515
- }
516
- sessionToTextCommandPayload(paramsAdd, name) {
517
- return this.sessionTextCommandPayload({ ...this.session.params, ...paramsAdd }, name);
518
- }
519
- sessionToTextFree(paramsAdd, name) {
520
- return this.sessionTextFree({ ...this.session.params, ...paramsAdd }, name);
521
- }
522
- // photo
523
- sessionToPhotoCaption(paramsAdd, name) {
524
- return this.sessionPhotoCaption({ ...this.session.params, ...paramsAdd }, name);
525
- }
526
- sessionToPhotoCaptionPayload(paramsAdd, name) {
527
- return this.sessionPhotoCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
528
- }
529
- sessionToPhotoCaptionCommand(paramsAdd, name) {
530
- return this.sessionPhotoCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
531
- }
532
- sessionToPhotoCaptionCommandPayload(paramsAdd, name) {
533
- return this.sessionPhotoCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
534
- }
535
- sessionToPhotoFree(paramsAdd, name) {
536
- return this.sessionPhotoFree({ ...this.session.params, ...paramsAdd }, name);
537
- }
538
- // video
539
- sessionToVideoCaption(paramsAdd, name) {
540
- return this.sessionVideoCaption({ ...this.session.params, ...paramsAdd }, name);
541
- }
542
- sessionToVideoCaptionPayload(paramsAdd, name) {
543
- return this.sessionVideoCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
544
- }
545
- sessionToVideoCaptionCommand(paramsAdd, name) {
546
- return this.sessionVideoCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
547
- }
548
- sessionToVideoCaptionCommandPayload(paramsAdd, name) {
549
- return this.sessionVideoCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
550
- }
551
- sessionToVideoFree(paramsAdd, name) {
552
- return this.sessionVideoFree({ ...this.session.params, ...paramsAdd }, name);
553
- }
554
- // audio
555
- sessionToAudioCaption(paramsAdd, name) {
556
- return this.sessionAudioCaption({ ...this.session.params, ...paramsAdd }, name);
557
- }
558
- sessionToAudioCaptionPayload(paramsAdd, name) {
559
- return this.sessionAudioCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
560
- }
561
- sessionToAudioCaptionCommand(paramsAdd, name) {
562
- return this.sessionAudioCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
563
- }
564
- sessionToAudioCaptionCommandPayload(paramsAdd, name) {
565
- return this.sessionAudioCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
566
- }
567
- sessionToAudioFree(paramsAdd, name) {
568
- return this.sessionAudioFree({ ...this.session.params, ...paramsAdd }, name);
569
- }
570
- // document
571
- sessionToDocumentCaption(paramsAdd, name) {
572
- return this.sessionDocumentCaption({ ...this.session.params, ...paramsAdd }, name);
573
- }
574
- sessionToDocumentCaptionPayload(paramsAdd, name) {
575
- return this.sessionDocumentCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
576
- }
577
- sessionToDocumentCaptionCommand(paramsAdd, name) {
578
- return this.sessionDocumentCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
579
- }
580
- sessionToDocumentCaptionCommandPayload(paramsAdd, name) {
581
- return this.sessionDocumentCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
582
- }
583
- sessionToDocumentFree(paramsAdd, name) {
584
- return this.sessionDocumentFree({ ...this.session.params, ...paramsAdd }, name);
585
- }
586
- // animation
587
- sessionToAnimationCaption(paramsAdd, name) {
588
- return this.sessionAnimationCaption({ ...this.session.params, ...paramsAdd }, name);
589
- }
590
- sessionToAnimationCaptionPayload(paramsAdd, name) {
591
- return this.sessionAnimationCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
592
- }
593
- sessionToAnimationCaptionCommand(paramsAdd, name) {
594
- return this.sessionAnimationCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
595
- }
596
- sessionToAnimationCaptionCommandPayload(paramsAdd, name) {
597
- return this.sessionAnimationCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
598
- }
599
- sessionToAnimationFree(paramsAdd, name) {
600
- return this.sessionAnimationFree({ ...this.session.params, ...paramsAdd }, name);
601
- }
602
- // voice
603
- sessionToVoiceCaption(paramsAdd, name) {
604
- return this.sessionVoiceCaption({ ...this.session.params, ...paramsAdd }, name);
605
- }
606
- sessionToVoiceCaptionPayload(paramsAdd, name) {
607
- return this.sessionVoiceCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
608
- }
609
- sessionToVoiceCaptionCommand(paramsAdd, name) {
610
- return this.sessionVoiceCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
611
- }
612
- sessionToVoiceCaptionCommandPayload(paramsAdd, name) {
613
- return this.sessionVoiceCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
614
- }
615
- sessionToVoiceFree(paramsAdd, name) {
616
- return this.sessionVoiceFree({ ...this.session.params, ...paramsAdd }, name);
617
- }
618
- // videonote
619
- sessionToVideoNoteCaption(paramsAdd, name) {
620
- return this.sessionVideoNoteCaption({ ...this.session.params, ...paramsAdd }, name);
621
- }
622
- sessionToVideoNoteCaptionPayload(paramsAdd, name) {
623
- return this.sessionVideoNoteCaptionPayload({ ...this.session.params, ...paramsAdd }, name);
624
- }
625
- sessionToVideoNoteCaptionCommand(paramsAdd, name) {
626
- return this.sessionVideoNoteCaptionCommand({ ...this.session.params, ...paramsAdd }, name);
627
- }
628
- sessionToVideoNoteCaptionCommandPayload(paramsAdd, name) {
629
- return this.sessionVideoNoteCaptionCommandPayload({ ...this.session.params, ...paramsAdd }, name);
630
- }
631
- sessionToVideoNoteFree(paramsAdd, name) {
632
- return this.sessionVideoNoteFree({ ...this.session.params, ...paramsAdd }, name);
633
- }
634
- // sticker
635
- sessionToStickerFree(paramsAdd, name) {
636
- return this.sessionStickerFree({ ...this.session.params, ...paramsAdd }, name);
637
- }
638
- // location
639
- sessionToLocationFree(paramsAdd, name) {
640
- return this.sessionLocationFree({ ...this.session.params, ...paramsAdd }, name);
641
- }
642
- // contact
643
- sessionToContactFree(paramsAdd, name) {
644
- return this.sessionContactFree({ ...this.session.params, ...paramsAdd }, name);
645
- }
646
- // =============== build intent
647
- buildIntent(str, fbCallbackData = true) {
648
- if (!str) {
649
- str = fbCallbackData ? this.data.callbackData() : this.data.name;
650
- }
651
- const tag = fbCallbackData ? `:` : ` `;
652
- return str?.indexOf?.(tag) != -1 ? str?.split?.(tag)?.[0] : str;
653
- }
654
- // =============== build session method
655
- buildSessionMethod(prefix, name) {
656
- return `${prefix}-${name || this.data.name}`;
657
- }
658
- // callback method
659
- buildSessionMethodCallback(name) {
660
- return this.buildSessionMethod(`1`, name);
661
- }
662
- buildSessionMethodCallbackPayload(name) {
663
- return this.buildSessionMethod(`2`, name);
664
- }
665
- // text method
666
- buildSessionMethodText(name) {
667
- return this.buildSessionMethod(`3`, name);
668
- }
669
- buildSessionMethodTextPayload(name) {
670
- return this.buildSessionMethod(`4`, name);
671
- }
672
- buildSessionMethodTextCommand(name) {
673
- return this.buildSessionMethod(`5`, name);
674
- }
675
- buildSessionMethodTextCommandPayload(name) {
676
- return this.buildSessionMethod(`6`, name);
677
- }
678
- buildSessionMethodTextFree(name) {
679
- return this.buildSessionMethod(`7`, name);
680
- }
681
- // photo method
682
- buildSessionMethodPhotoCaption(name) {
683
- return this.buildSessionMethod(`8`, name);
684
- }
685
- buildSessionMethodPhotoCaptionPayload(name) {
686
- return this.buildSessionMethod(`9`, name);
687
- }
688
- buildSessionMethodPhotoCaptionCommand(name) {
689
- return this.buildSessionMethod(`10`, name);
690
- }
691
- buildSessionMethodPhotoCaptionCommandPayload(name) {
692
- return this.buildSessionMethod(`11`, name);
693
- }
694
- buildSessionMethodPhotoFree(name) {
695
- return this.buildSessionMethod(`12`, name);
696
- }
697
- // video method
698
- buildSessionMethodVideoCaption(name) {
699
- return this.buildSessionMethod(`13`, name);
700
- }
701
- buildSessionMethodVideoCaptionPayload(name) {
702
- return this.buildSessionMethod(`14`, name);
703
- }
704
- buildSessionMethodVideoCaptionCommand(name) {
705
- return this.buildSessionMethod(`15`, name);
706
- }
707
- buildSessionMethodVideoCaptionCommandPayload(name) {
708
- return this.buildSessionMethod(`16`, name);
709
- }
710
- buildSessionMethodVideoFree(name) {
711
- return this.buildSessionMethod(`17`, name);
712
- }
713
- // audio method
714
- buildSessionMethodAudioCaption(name) {
715
- return this.buildSessionMethod(`18`, name);
716
- }
717
- buildSessionMethodAudioCaptionPayload(name) {
718
- return this.buildSessionMethod(`19`, name);
719
- }
720
- buildSessionMethodAudioCaptionCommand(name) {
721
- return this.buildSessionMethod(`20`, name);
722
- }
723
- buildSessionMethodAudioCaptionCommandPayload(name) {
724
- return this.buildSessionMethod(`21`, name);
725
- }
726
- buildSessionMethodAudioFree(name) {
727
- return this.buildSessionMethod(`22`, name);
728
- }
729
- // document method
730
- buildSessionMethodDocumentCaption(name) {
731
- return this.buildSessionMethod(`23`, name);
732
- }
733
- buildSessionMethodDocumentCaptionPayload(name) {
734
- return this.buildSessionMethod(`24`, name);
735
- }
736
- buildSessionMethodDocumentCaptionCommand(name) {
737
- return this.buildSessionMethod(`25`, name);
738
- }
739
- buildSessionMethodDocumentCaptionCommandPayload(name) {
740
- return this.buildSessionMethod(`26`, name);
741
- }
742
- buildSessionMethodDocumentFree(name) {
743
- return this.buildSessionMethod(`27`, name);
744
- }
745
- // animation method
746
- buildSessionMethodAnimationCaption(name) {
747
- return this.buildSessionMethod(`28`, name);
748
- }
749
- buildSessionMethodAnimationCaptionPayload(name) {
750
- return this.buildSessionMethod(`29`, name);
751
- }
752
- buildSessionMethodAnimationCaptionCommand(name) {
753
- return this.buildSessionMethod(`30`, name);
754
- }
755
- buildSessionMethodAnimationCaptionCommandPayload(name) {
756
- return this.buildSessionMethod(`31`, name);
757
- }
758
- buildSessionMethodAnimationFree(name) {
759
- return this.buildSessionMethod(`32`, name);
760
- }
761
- // voice method
762
- buildSessionMethodVoiceCaption(name) {
763
- return this.buildSessionMethod(`33`, name);
764
- }
765
- buildSessionMethodVoiceCaptionPayload(name) {
766
- return this.buildSessionMethod(`34`, name);
767
- }
768
- buildSessionMethodVoiceCaptionCommand(name) {
769
- return this.buildSessionMethod(`35`, name);
770
- }
771
- buildSessionMethodVoiceCaptionCommandPayload(name) {
772
- return this.buildSessionMethod(`36`, name);
773
- }
774
- buildSessionMethodVoiceFree(name) {
775
- return this.buildSessionMethod(`37`, name);
776
- }
777
- // video note method
778
- buildSessionMethodVideoNoteCaption(name) {
779
- return this.buildSessionMethod(`38`, name);
780
- }
781
- buildSessionMethodVideoNoteCaptionPayload(name) {
782
- return this.buildSessionMethod(`39`, name);
783
- }
784
- buildSessionMethodVideoNoteCaptionCommand(name) {
785
- return this.buildSessionMethod(`40`, name);
786
- }
787
- buildSessionMethodVideoNoteCaptionCommandPayload(name) {
788
- return this.buildSessionMethod(`41`, name);
789
- }
790
- buildSessionMethodVideoNoteFree(name) {
791
- return this.buildSessionMethod(`42`, name);
792
- }
793
- // sticker method
794
- buildSessionMethodStickerFree(name) {
795
- return this.buildSessionMethod(`43`, name);
796
- }
797
- // location method
798
- buildSessionMethodLocationFree(name) {
799
- return this.buildSessionMethod(`44`, name);
800
- }
801
- // contact method
802
- buildSessionMethodContactFree(name) {
803
- return this.buildSessionMethod(`45`, name);
804
- }
805
- }