@sugansociety/gallagherrich 4.16.8

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 (180) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1024 -0
  3. package/filters.d.ts +1 -0
  4. package/filters.js +1 -0
  5. package/format.d.ts +1 -0
  6. package/format.js +1 -0
  7. package/future.d.ts +1 -0
  8. package/future.js +1 -0
  9. package/lib/button.js +102 -0
  10. package/lib/cli.mjs +105 -0
  11. package/lib/composer.js +583 -0
  12. package/lib/context.js +1280 -0
  13. package/lib/core/helpers/args.js +59 -0
  14. package/lib/core/helpers/check.js +57 -0
  15. package/lib/core/helpers/compact.js +18 -0
  16. package/lib/core/helpers/deunionize.js +14 -0
  17. package/lib/core/helpers/formatting.js +92 -0
  18. package/lib/core/helpers/util.js +51 -0
  19. package/lib/core/network/client.js +321 -0
  20. package/lib/core/network/error.js +22 -0
  21. package/lib/core/network/multipart-stream.js +62 -0
  22. package/lib/core/network/polling.js +88 -0
  23. package/lib/core/network/webhook.js +55 -0
  24. package/lib/core/types/rich-message.js +288 -0
  25. package/lib/core/types/typegram.js +29 -0
  26. package/lib/filters.js +70 -0
  27. package/lib/filters.js.map +1 -0
  28. package/lib/format.js +39 -0
  29. package/lib/format.js.map +1 -0
  30. package/lib/future.js +167 -0
  31. package/lib/future.js.map +1 -0
  32. package/lib/index.js +50 -0
  33. package/lib/input.js +62 -0
  34. package/lib/markup.js +112 -0
  35. package/lib/markup.js.map +1 -0
  36. package/lib/middleware.js +3 -0
  37. package/lib/reactions.js +85 -0
  38. package/lib/router.js +47 -0
  39. package/lib/scenes/base.js +40 -0
  40. package/lib/scenes/context.js +105 -0
  41. package/lib/scenes/index.js +22 -0
  42. package/lib/scenes/stage.js +50 -0
  43. package/lib/scenes/wizard/context.js +32 -0
  44. package/lib/scenes/wizard/index.js +46 -0
  45. package/lib/scenes.js +18 -0
  46. package/lib/scenes.js.map +1 -0
  47. package/lib/session.js +167 -0
  48. package/lib/session.js.map +1 -0
  49. package/lib/telegraf.js +273 -0
  50. package/lib/telegram-types.js +7 -0
  51. package/lib/telegram.js +1270 -0
  52. package/lib/types.js +3 -0
  53. package/lib/types.js.map +1 -0
  54. package/lib/utils.js +6 -0
  55. package/lib/utils.js.map +1 -0
  56. package/markup.d.ts +1 -0
  57. package/markup.js +1 -0
  58. package/package.json +136 -0
  59. package/scenes.d.ts +1 -0
  60. package/scenes.js +1 -0
  61. package/session.d.ts +1 -0
  62. package/session.js +1 -0
  63. package/src/button.ts +182 -0
  64. package/src/composer.ts +1008 -0
  65. package/src/context.ts +1747 -0
  66. package/src/core/helpers/args.ts +63 -0
  67. package/src/core/helpers/check.ts +71 -0
  68. package/src/core/helpers/compact.ts +18 -0
  69. package/src/core/helpers/deunionize.ts +26 -0
  70. package/src/core/helpers/formatting.ts +119 -0
  71. package/src/core/helpers/util.ts +96 -0
  72. package/src/core/network/client.ts +396 -0
  73. package/src/core/network/error.ts +29 -0
  74. package/src/core/network/multipart-stream.ts +45 -0
  75. package/src/core/network/polling.ts +94 -0
  76. package/src/core/network/webhook.ts +58 -0
  77. package/src/core/types/rich-message.ts +375 -0
  78. package/src/core/types/typegram.ts +55 -0
  79. package/src/filters.ts +109 -0
  80. package/src/format.ts +110 -0
  81. package/src/future.ts +231 -0
  82. package/src/index.ts +18 -0
  83. package/src/input.ts +59 -0
  84. package/src/markup.ts +142 -0
  85. package/src/middleware.ts +24 -0
  86. package/src/reactions.ts +118 -0
  87. package/src/router.ts +55 -0
  88. package/src/scenes/base.ts +52 -0
  89. package/src/scenes/context.ts +136 -0
  90. package/src/scenes/index.ts +21 -0
  91. package/src/scenes/stage.ts +71 -0
  92. package/src/scenes/wizard/context.ts +58 -0
  93. package/src/scenes/wizard/index.ts +63 -0
  94. package/src/scenes.ts +1 -0
  95. package/src/session.ts +204 -0
  96. package/src/telegraf.ts +380 -0
  97. package/src/telegram-types.ts +256 -0
  98. package/src/telegram.ts +1676 -0
  99. package/src/types.ts +2 -0
  100. package/src/utils.ts +1 -0
  101. package/types.d.ts +1 -0
  102. package/types.js +1 -0
  103. package/typings/button.d.ts +36 -0
  104. package/typings/button.d.ts.map +1 -0
  105. package/typings/composer.d.ts +227 -0
  106. package/typings/composer.d.ts.map +1 -0
  107. package/typings/context.d.ts +699 -0
  108. package/typings/context.d.ts.map +1 -0
  109. package/typings/core/helpers/args.d.ts +11 -0
  110. package/typings/core/helpers/args.d.ts.map +1 -0
  111. package/typings/core/helpers/check.d.ts +56 -0
  112. package/typings/core/helpers/check.d.ts.map +1 -0
  113. package/typings/core/helpers/compact.d.ts +4 -0
  114. package/typings/core/helpers/compact.d.ts.map +1 -0
  115. package/typings/core/helpers/deunionize.d.ts +18 -0
  116. package/typings/core/helpers/deunionize.d.ts.map +1 -0
  117. package/typings/core/helpers/formatting.d.ts +30 -0
  118. package/typings/core/helpers/formatting.d.ts.map +1 -0
  119. package/typings/core/helpers/util.d.ts +27 -0
  120. package/typings/core/helpers/util.d.ts.map +1 -0
  121. package/typings/core/network/client.d.ts +55 -0
  122. package/typings/core/network/client.d.ts.map +1 -0
  123. package/typings/core/network/error.d.ts +16 -0
  124. package/typings/core/network/error.d.ts.map +1 -0
  125. package/typings/core/network/multipart-stream.d.ts +20 -0
  126. package/typings/core/network/multipart-stream.d.ts.map +1 -0
  127. package/typings/core/network/polling.d.ts +16 -0
  128. package/typings/core/network/polling.d.ts.map +1 -0
  129. package/typings/core/network/webhook.d.ts +7 -0
  130. package/typings/core/network/webhook.d.ts.map +1 -0
  131. package/typings/core/types/rich-message.d.ts +144 -0
  132. package/typings/core/types/rich-message.d.ts.map +1 -0
  133. package/typings/core/types/typegram.d.ts +46 -0
  134. package/typings/core/types/typegram.d.ts.map +1 -0
  135. package/typings/filters.d.ts +18 -0
  136. package/typings/filters.d.ts.map +1 -0
  137. package/typings/format.d.ts +22 -0
  138. package/typings/format.d.ts.map +1 -0
  139. package/typings/future.d.ts +12 -0
  140. package/typings/future.d.ts.map +1 -0
  141. package/typings/index.d.ts +16 -0
  142. package/typings/index.d.ts.map +1 -0
  143. package/typings/input.d.ts +59 -0
  144. package/typings/input.d.ts.map +1 -0
  145. package/typings/markup.d.ts +27 -0
  146. package/typings/markup.d.ts.map +1 -0
  147. package/typings/middleware.d.ts +8 -0
  148. package/typings/middleware.d.ts.map +1 -0
  149. package/typings/reactions.d.ts +32 -0
  150. package/typings/reactions.d.ts.map +1 -0
  151. package/typings/router.d.ts +21 -0
  152. package/typings/router.d.ts.map +1 -0
  153. package/typings/scenes/base.d.ts +22 -0
  154. package/typings/scenes/base.d.ts.map +1 -0
  155. package/typings/scenes/context.d.ts +36 -0
  156. package/typings/scenes/context.d.ts.map +1 -0
  157. package/typings/scenes/index.d.ts +11 -0
  158. package/typings/scenes/index.d.ts.map +1 -0
  159. package/typings/scenes/stage.d.ts +24 -0
  160. package/typings/scenes/stage.d.ts.map +1 -0
  161. package/typings/scenes/wizard/context.d.ts +29 -0
  162. package/typings/scenes/wizard/context.d.ts.map +1 -0
  163. package/typings/scenes/wizard/index.d.ts +16 -0
  164. package/typings/scenes/wizard/index.d.ts.map +1 -0
  165. package/typings/scenes.d.ts +2 -0
  166. package/typings/scenes.d.ts.map +1 -0
  167. package/typings/session.d.ts +55 -0
  168. package/typings/session.d.ts.map +1 -0
  169. package/typings/telegraf.d.ts +119 -0
  170. package/typings/telegraf.d.ts.map +1 -0
  171. package/typings/telegram-types.d.ts +141 -0
  172. package/typings/telegram-types.d.ts.map +1 -0
  173. package/typings/telegram.d.ts +694 -0
  174. package/typings/telegram.d.ts.map +1 -0
  175. package/typings/types.d.ts +3 -0
  176. package/typings/types.d.ts.map +1 -0
  177. package/typings/utils.d.ts +2 -0
  178. package/typings/utils.d.ts.map +1 -0
  179. package/utils.d.ts +1 -0
  180. package/utils.js +1 -0
package/filters.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './typings/filters'
package/filters.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/filters')
package/format.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './typings/format'
package/format.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/format')
package/future.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './typings/future'
package/future.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/future')
package/lib/button.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webApp = exports.login = exports.pay = exports.game = exports.switchToCurrentChat = exports.switchToChat = exports.callback = exports.url = exports.channelRequest = exports.groupRequest = exports.botRequest = exports.userRequest = exports.pollRequest = exports.locationRequest = exports.contactRequest = exports.text = void 0;
4
+ function text(text, hide = false) {
5
+ return { text, hide };
6
+ }
7
+ exports.text = text;
8
+ function contactRequest(text, hide = false) {
9
+ return { text, request_contact: true, hide };
10
+ }
11
+ exports.contactRequest = contactRequest;
12
+ function locationRequest(text, hide = false) {
13
+ return { text, request_location: true, hide };
14
+ }
15
+ exports.locationRequest = locationRequest;
16
+ function pollRequest(text, type, hide = false) {
17
+ return { text, request_poll: { type }, hide };
18
+ }
19
+ exports.pollRequest = pollRequest;
20
+ function userRequest(text,
21
+ /** Must fit in a signed 32 bit int */
22
+ request_id, extra, hide = false) {
23
+ return {
24
+ text,
25
+ request_users: { request_id, ...extra },
26
+ hide,
27
+ };
28
+ }
29
+ exports.userRequest = userRequest;
30
+ function botRequest(text,
31
+ /** Must fit in a signed 32 bit int */
32
+ request_id, extra, hide = false) {
33
+ return {
34
+ text,
35
+ request_users: { request_id, user_is_bot: true, ...extra },
36
+ hide,
37
+ };
38
+ }
39
+ exports.botRequest = botRequest;
40
+ function groupRequest(text,
41
+ /** Must fit in a signed 32 bit int */
42
+ request_id, extra, hide = false) {
43
+ return {
44
+ text,
45
+ request_chat: { request_id, chat_is_channel: false, ...extra },
46
+ hide,
47
+ };
48
+ }
49
+ exports.groupRequest = groupRequest;
50
+ function channelRequest(text,
51
+ /** Must fit in a signed 32 bit int */
52
+ request_id, extra, hide = false) {
53
+ return {
54
+ text,
55
+ request_chat: { request_id, chat_is_channel: true, ...extra },
56
+ hide,
57
+ };
58
+ }
59
+ exports.channelRequest = channelRequest;
60
+ function url(text, url, hide = false) {
61
+ return { text, url, hide };
62
+ }
63
+ exports.url = url;
64
+ function callback(text, data, hide = false) {
65
+ return { text, callback_data: data, hide };
66
+ }
67
+ exports.callback = callback;
68
+ function switchToChat(text, value, hide = false) {
69
+ return { text, switch_inline_query: value, hide };
70
+ }
71
+ exports.switchToChat = switchToChat;
72
+ function switchToCurrentChat(text, value, hide = false) {
73
+ return { text, switch_inline_query_current_chat: value, hide };
74
+ }
75
+ exports.switchToCurrentChat = switchToCurrentChat;
76
+ function game(text, hide = false) {
77
+ return { text, callback_game: {}, hide };
78
+ }
79
+ exports.game = game;
80
+ function pay(text, hide = false) {
81
+ return { text, pay: true, hide };
82
+ }
83
+ exports.pay = pay;
84
+ function login(text, url, opts = {}, hide = false) {
85
+ return {
86
+ text,
87
+ login_url: { ...opts, url },
88
+ hide,
89
+ };
90
+ }
91
+ exports.login = login;
92
+ function webApp(text, url, hide = false
93
+ // works as both InlineKeyboardButton and KeyboardButton
94
+ ) {
95
+ return {
96
+ text,
97
+ web_app: { url },
98
+ hide,
99
+ };
100
+ }
101
+ exports.webApp = webApp;
102
+ //# sourceMappingURL=button.js.map
package/lib/cli.mjs ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import d from 'debug';
3
+ import parse from 'mri';
4
+ import path from 'path';
5
+ import { Telegraf } from './index.js';
6
+ const debug = d('telegraf:cli');
7
+ const helpMsg = `Usage: telegraf [opts] <bot-file>
8
+
9
+ -t Bot token [$BOT_TOKEN]
10
+ -d Webhook domain [$BOT_DOMAIN]
11
+ -H Webhook host [0.0.0.0]
12
+ -p Webhook port [$PORT or 3000]
13
+ -l Enable logs
14
+ -h Show this help message
15
+ -m Bot API method to run directly
16
+ -D Data to pass to the Bot API method`;
17
+ const help = () => console.log(helpMsg);
18
+ /**
19
+ * Runs the cli program and returns exit code
20
+ */
21
+ export async function main(argv, env = {}) {
22
+ const args = parse(argv, {
23
+ alias: {
24
+ // string params, all optional
25
+ t: 'token',
26
+ d: 'domain',
27
+ m: 'method',
28
+ D: 'data',
29
+ // defaults exist
30
+ H: 'host',
31
+ p: 'port',
32
+ // boolean params
33
+ l: 'logs',
34
+ h: 'help',
35
+ },
36
+ boolean: ['h', 'l'],
37
+ default: {
38
+ H: '0.0.0.0',
39
+ p: env.PORT || '3000',
40
+ },
41
+ });
42
+ if (args.help) {
43
+ help();
44
+ return 0;
45
+ }
46
+ const token = args.token || env.BOT_TOKEN;
47
+ const domain = args.domain || env.BOT_DOMAIN;
48
+ if (!token) {
49
+ console.error('Please supply Bot Token');
50
+ help();
51
+ return 1;
52
+ }
53
+ const bot = new Telegraf(token);
54
+ if (args.method) {
55
+ const method = args.method;
56
+ console.log(await bot.telegram.callApi(method, JSON.parse(args.data || '{}')));
57
+ return 0;
58
+ }
59
+ let [, , file] = args._;
60
+ if (!file) {
61
+ try {
62
+ const packageJson = (await import(path.resolve(process.cwd(), 'package.json')));
63
+ file = packageJson.main || 'index.js';
64
+ // eslint-disable-next-line no-empty
65
+ }
66
+ catch (err) { }
67
+ }
68
+ if (!file) {
69
+ console.error('Please supply a bot handler file.\n');
70
+ help();
71
+ return 2;
72
+ }
73
+ if (file[0] !== '/')
74
+ file = path.resolve(process.cwd(), file);
75
+ try {
76
+ if (args.logs)
77
+ d.enable('telegraf:*');
78
+ const mod = await import(file);
79
+ const botHandler = mod.botHandler || mod.default;
80
+ const httpHandler = mod.httpHandler;
81
+ const tlsOptions = mod.tlsOptions;
82
+ const config = {};
83
+ if (domain) {
84
+ config.webhook = {
85
+ domain,
86
+ host: args.host,
87
+ port: Number(args.port),
88
+ tlsOptions,
89
+ cb: httpHandler,
90
+ };
91
+ }
92
+ bot.use(botHandler);
93
+ debug(`Starting module ${file}`);
94
+ await bot.launch(config);
95
+ }
96
+ catch (err) {
97
+ console.error(`Error launching bot from ${file}`, err === null || err === void 0 ? void 0 : err.stack);
98
+ return 3;
99
+ }
100
+ // Enable graceful stop
101
+ process.once('SIGINT', () => bot.stop('SIGINT'));
102
+ process.once('SIGTERM', () => bot.stop('SIGTERM'));
103
+ return 0;
104
+ }
105
+ process.exitCode = await main(process.argv, process.env);