@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.
- package/LICENSE +22 -0
- package/README.md +1024 -0
- package/filters.d.ts +1 -0
- package/filters.js +1 -0
- package/format.d.ts +1 -0
- package/format.js +1 -0
- package/future.d.ts +1 -0
- package/future.js +1 -0
- package/lib/button.js +102 -0
- package/lib/cli.mjs +105 -0
- package/lib/composer.js +583 -0
- package/lib/context.js +1280 -0
- package/lib/core/helpers/args.js +59 -0
- package/lib/core/helpers/check.js +57 -0
- package/lib/core/helpers/compact.js +18 -0
- package/lib/core/helpers/deunionize.js +14 -0
- package/lib/core/helpers/formatting.js +92 -0
- package/lib/core/helpers/util.js +51 -0
- package/lib/core/network/client.js +321 -0
- package/lib/core/network/error.js +22 -0
- package/lib/core/network/multipart-stream.js +62 -0
- package/lib/core/network/polling.js +88 -0
- package/lib/core/network/webhook.js +55 -0
- package/lib/core/types/rich-message.js +288 -0
- package/lib/core/types/typegram.js +29 -0
- package/lib/filters.js +70 -0
- package/lib/filters.js.map +1 -0
- package/lib/format.js +39 -0
- package/lib/format.js.map +1 -0
- package/lib/future.js +167 -0
- package/lib/future.js.map +1 -0
- package/lib/index.js +50 -0
- package/lib/input.js +62 -0
- package/lib/markup.js +112 -0
- package/lib/markup.js.map +1 -0
- package/lib/middleware.js +3 -0
- package/lib/reactions.js +85 -0
- package/lib/router.js +47 -0
- package/lib/scenes/base.js +40 -0
- package/lib/scenes/context.js +105 -0
- package/lib/scenes/index.js +22 -0
- package/lib/scenes/stage.js +50 -0
- package/lib/scenes/wizard/context.js +32 -0
- package/lib/scenes/wizard/index.js +46 -0
- package/lib/scenes.js +18 -0
- package/lib/scenes.js.map +1 -0
- package/lib/session.js +167 -0
- package/lib/session.js.map +1 -0
- package/lib/telegraf.js +273 -0
- package/lib/telegram-types.js +7 -0
- package/lib/telegram.js +1270 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.js +6 -0
- package/lib/utils.js.map +1 -0
- package/markup.d.ts +1 -0
- package/markup.js +1 -0
- package/package.json +136 -0
- package/scenes.d.ts +1 -0
- package/scenes.js +1 -0
- package/session.d.ts +1 -0
- package/session.js +1 -0
- package/src/button.ts +182 -0
- package/src/composer.ts +1008 -0
- package/src/context.ts +1747 -0
- package/src/core/helpers/args.ts +63 -0
- package/src/core/helpers/check.ts +71 -0
- package/src/core/helpers/compact.ts +18 -0
- package/src/core/helpers/deunionize.ts +26 -0
- package/src/core/helpers/formatting.ts +119 -0
- package/src/core/helpers/util.ts +96 -0
- package/src/core/network/client.ts +396 -0
- package/src/core/network/error.ts +29 -0
- package/src/core/network/multipart-stream.ts +45 -0
- package/src/core/network/polling.ts +94 -0
- package/src/core/network/webhook.ts +58 -0
- package/src/core/types/rich-message.ts +375 -0
- package/src/core/types/typegram.ts +55 -0
- package/src/filters.ts +109 -0
- package/src/format.ts +110 -0
- package/src/future.ts +231 -0
- package/src/index.ts +18 -0
- package/src/input.ts +59 -0
- package/src/markup.ts +142 -0
- package/src/middleware.ts +24 -0
- package/src/reactions.ts +118 -0
- package/src/router.ts +55 -0
- package/src/scenes/base.ts +52 -0
- package/src/scenes/context.ts +136 -0
- package/src/scenes/index.ts +21 -0
- package/src/scenes/stage.ts +71 -0
- package/src/scenes/wizard/context.ts +58 -0
- package/src/scenes/wizard/index.ts +63 -0
- package/src/scenes.ts +1 -0
- package/src/session.ts +204 -0
- package/src/telegraf.ts +380 -0
- package/src/telegram-types.ts +256 -0
- package/src/telegram.ts +1676 -0
- package/src/types.ts +2 -0
- package/src/utils.ts +1 -0
- package/types.d.ts +1 -0
- package/types.js +1 -0
- package/typings/button.d.ts +36 -0
- package/typings/button.d.ts.map +1 -0
- package/typings/composer.d.ts +227 -0
- package/typings/composer.d.ts.map +1 -0
- package/typings/context.d.ts +699 -0
- package/typings/context.d.ts.map +1 -0
- package/typings/core/helpers/args.d.ts +11 -0
- package/typings/core/helpers/args.d.ts.map +1 -0
- package/typings/core/helpers/check.d.ts +56 -0
- package/typings/core/helpers/check.d.ts.map +1 -0
- package/typings/core/helpers/compact.d.ts +4 -0
- package/typings/core/helpers/compact.d.ts.map +1 -0
- package/typings/core/helpers/deunionize.d.ts +18 -0
- package/typings/core/helpers/deunionize.d.ts.map +1 -0
- package/typings/core/helpers/formatting.d.ts +30 -0
- package/typings/core/helpers/formatting.d.ts.map +1 -0
- package/typings/core/helpers/util.d.ts +27 -0
- package/typings/core/helpers/util.d.ts.map +1 -0
- package/typings/core/network/client.d.ts +55 -0
- package/typings/core/network/client.d.ts.map +1 -0
- package/typings/core/network/error.d.ts +16 -0
- package/typings/core/network/error.d.ts.map +1 -0
- package/typings/core/network/multipart-stream.d.ts +20 -0
- package/typings/core/network/multipart-stream.d.ts.map +1 -0
- package/typings/core/network/polling.d.ts +16 -0
- package/typings/core/network/polling.d.ts.map +1 -0
- package/typings/core/network/webhook.d.ts +7 -0
- package/typings/core/network/webhook.d.ts.map +1 -0
- package/typings/core/types/rich-message.d.ts +144 -0
- package/typings/core/types/rich-message.d.ts.map +1 -0
- package/typings/core/types/typegram.d.ts +46 -0
- package/typings/core/types/typegram.d.ts.map +1 -0
- package/typings/filters.d.ts +18 -0
- package/typings/filters.d.ts.map +1 -0
- package/typings/format.d.ts +22 -0
- package/typings/format.d.ts.map +1 -0
- package/typings/future.d.ts +12 -0
- package/typings/future.d.ts.map +1 -0
- package/typings/index.d.ts +16 -0
- package/typings/index.d.ts.map +1 -0
- package/typings/input.d.ts +59 -0
- package/typings/input.d.ts.map +1 -0
- package/typings/markup.d.ts +27 -0
- package/typings/markup.d.ts.map +1 -0
- package/typings/middleware.d.ts +8 -0
- package/typings/middleware.d.ts.map +1 -0
- package/typings/reactions.d.ts +32 -0
- package/typings/reactions.d.ts.map +1 -0
- package/typings/router.d.ts +21 -0
- package/typings/router.d.ts.map +1 -0
- package/typings/scenes/base.d.ts +22 -0
- package/typings/scenes/base.d.ts.map +1 -0
- package/typings/scenes/context.d.ts +36 -0
- package/typings/scenes/context.d.ts.map +1 -0
- package/typings/scenes/index.d.ts +11 -0
- package/typings/scenes/index.d.ts.map +1 -0
- package/typings/scenes/stage.d.ts +24 -0
- package/typings/scenes/stage.d.ts.map +1 -0
- package/typings/scenes/wizard/context.d.ts +29 -0
- package/typings/scenes/wizard/context.d.ts.map +1 -0
- package/typings/scenes/wizard/index.d.ts +16 -0
- package/typings/scenes/wizard/index.d.ts.map +1 -0
- package/typings/scenes.d.ts +2 -0
- package/typings/scenes.d.ts.map +1 -0
- package/typings/session.d.ts +55 -0
- package/typings/session.d.ts.map +1 -0
- package/typings/telegraf.d.ts +119 -0
- package/typings/telegraf.d.ts.map +1 -0
- package/typings/telegram-types.d.ts +141 -0
- package/typings/telegram-types.d.ts.map +1 -0
- package/typings/telegram.d.ts +694 -0
- package/typings/telegram.d.ts.map +1 -0
- package/typings/types.d.ts +3 -0
- package/typings/types.d.ts.map +1 -0
- package/typings/utils.d.ts +2 -0
- package/typings/utils.d.ts.map +1 -0
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const stream = __importStar(require("stream"));
|
|
30
|
+
const check_1 = require("../helpers/check");
|
|
31
|
+
const sandwich_stream_1 = __importDefault(require("sandwich-stream"));
|
|
32
|
+
const CRNL = '\r\n';
|
|
33
|
+
class MultipartStream extends sandwich_stream_1.default {
|
|
34
|
+
constructor(boundary) {
|
|
35
|
+
super({
|
|
36
|
+
head: `--${boundary}${CRNL}`,
|
|
37
|
+
tail: `${CRNL}--${boundary}--`,
|
|
38
|
+
separator: `${CRNL}--${boundary}${CRNL}`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
addPart(part) {
|
|
42
|
+
const partStream = new stream.PassThrough();
|
|
43
|
+
for (const [key, header] of Object.entries(part.headers)) {
|
|
44
|
+
partStream.write(`${key}:${header}${CRNL}`);
|
|
45
|
+
}
|
|
46
|
+
partStream.write(CRNL);
|
|
47
|
+
if (MultipartStream.isStream(part.body)) {
|
|
48
|
+
part.body.pipe(partStream);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
partStream.end(part.body);
|
|
52
|
+
}
|
|
53
|
+
this.add(partStream);
|
|
54
|
+
}
|
|
55
|
+
static isStream(stream) {
|
|
56
|
+
return (typeof stream === 'object' &&
|
|
57
|
+
stream !== null &&
|
|
58
|
+
(0, check_1.hasPropType)(stream, 'pipe', 'function'));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = MultipartStream;
|
|
62
|
+
//# sourceMappingURL=multipart-stream.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Polling = void 0;
|
|
7
|
+
const abort_controller_1 = __importDefault(require("abort-controller"));
|
|
8
|
+
const debug_1 = __importDefault(require("debug"));
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const error_1 = require("./error");
|
|
11
|
+
const debug = (0, debug_1.default)('telegraf:polling');
|
|
12
|
+
const wait = (0, util_1.promisify)(setTimeout);
|
|
13
|
+
function always(x) {
|
|
14
|
+
return () => x;
|
|
15
|
+
}
|
|
16
|
+
const noop = always(Promise.resolve());
|
|
17
|
+
class Polling {
|
|
18
|
+
constructor(telegram, allowedUpdates) {
|
|
19
|
+
this.telegram = telegram;
|
|
20
|
+
this.allowedUpdates = allowedUpdates;
|
|
21
|
+
this.abortController = new abort_controller_1.default();
|
|
22
|
+
this.skipOffsetSync = false;
|
|
23
|
+
this.offset = 0;
|
|
24
|
+
}
|
|
25
|
+
async *[Symbol.asyncIterator]() {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
debug('Starting long polling');
|
|
28
|
+
do {
|
|
29
|
+
try {
|
|
30
|
+
const updates = await this.telegram.callApi('getUpdates', {
|
|
31
|
+
timeout: 50,
|
|
32
|
+
offset: this.offset,
|
|
33
|
+
allowed_updates: this.allowedUpdates,
|
|
34
|
+
}, this.abortController);
|
|
35
|
+
const last = updates[updates.length - 1];
|
|
36
|
+
if (last !== undefined) {
|
|
37
|
+
this.offset = last.update_id + 1;
|
|
38
|
+
}
|
|
39
|
+
yield updates;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const err = error;
|
|
43
|
+
if (err.name === 'AbortError')
|
|
44
|
+
return;
|
|
45
|
+
if (err.name === 'FetchError' ||
|
|
46
|
+
(err instanceof error_1.TelegramError && err.code === 429) ||
|
|
47
|
+
(err instanceof error_1.TelegramError && err.code >= 500)) {
|
|
48
|
+
const retryAfter = (_b = (_a = err.parameters) === null || _a === void 0 ? void 0 : _a.retry_after) !== null && _b !== void 0 ? _b : 5;
|
|
49
|
+
debug('Failed to fetch updates, retrying after %ds.', retryAfter, err);
|
|
50
|
+
await wait(retryAfter * 1000);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (err instanceof error_1.TelegramError &&
|
|
54
|
+
// Unauthorized Conflict
|
|
55
|
+
(err.code === 401 || err.code === 409)) {
|
|
56
|
+
this.skipOffsetSync = true;
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
} while (!this.abortController.signal.aborted);
|
|
62
|
+
}
|
|
63
|
+
async syncUpdateOffset() {
|
|
64
|
+
if (this.skipOffsetSync)
|
|
65
|
+
return;
|
|
66
|
+
debug('Syncing update offset...');
|
|
67
|
+
await this.telegram.callApi('getUpdates', { offset: this.offset, limit: 1 });
|
|
68
|
+
}
|
|
69
|
+
async loop(handleUpdate) {
|
|
70
|
+
if (this.abortController.signal.aborted)
|
|
71
|
+
throw new Error('Polling instances must not be reused!');
|
|
72
|
+
try {
|
|
73
|
+
for await (const updates of this)
|
|
74
|
+
await Promise.all(updates.map(handleUpdate));
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
debug('Long polling stopped');
|
|
78
|
+
// prevent instance reuse
|
|
79
|
+
this.stop();
|
|
80
|
+
await this.syncUpdateOffset().catch(noop);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
stop() {
|
|
84
|
+
this.abortController.abort();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.Polling = Polling;
|
|
88
|
+
//# sourceMappingURL=polling.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const debug_1 = __importDefault(require("debug"));
|
|
7
|
+
const debug = (0, debug_1.default)('telegraf:webhook');
|
|
8
|
+
function generateWebhook(filter, updateHandler) {
|
|
9
|
+
return async (req, res, next = () => {
|
|
10
|
+
res.statusCode = 403;
|
|
11
|
+
debug('Replying with status code', res.statusCode);
|
|
12
|
+
res.end();
|
|
13
|
+
}) => {
|
|
14
|
+
debug('Incoming request', req.method, req.url);
|
|
15
|
+
if (!filter(req)) {
|
|
16
|
+
debug('Webhook filter failed', req.method, req.url);
|
|
17
|
+
return next();
|
|
18
|
+
}
|
|
19
|
+
let update;
|
|
20
|
+
try {
|
|
21
|
+
if (req.body != null) {
|
|
22
|
+
/* If req.body is already set, we expect it to be the parsed
|
|
23
|
+
request body (update object) received from Telegram
|
|
24
|
+
However, some libraries such as `serverless-http` set req.body to the
|
|
25
|
+
raw buffer, so we'll handle that additionally */
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
let body = req.body;
|
|
28
|
+
// if body is Buffer, parse it into string
|
|
29
|
+
if (body instanceof Buffer)
|
|
30
|
+
body = String(req.body);
|
|
31
|
+
// if body is string, parse it into object
|
|
32
|
+
if (typeof body === 'string')
|
|
33
|
+
body = JSON.parse(body);
|
|
34
|
+
update = body;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
let body = '';
|
|
38
|
+
// parse each buffer to string and append to body
|
|
39
|
+
for await (const chunk of req)
|
|
40
|
+
body += String(chunk);
|
|
41
|
+
// parse body to object
|
|
42
|
+
update = JSON.parse(body);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// if any of the parsing steps fails, give up and respond with error
|
|
47
|
+
res.writeHead(415).end();
|
|
48
|
+
debug('Failed to parse request body:', error);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
return await updateHandler(update, res);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.default = generateWebhook;
|
|
55
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Telegram Bot API 10.1 — Rich Messages
|
|
4
|
+
* https://core.telegram.org/bots/api#june-11-2026
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MD = exports.H = exports.RichMarkdownBuilder = exports.RichHTMLBuilder = void 0;
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// HTML Builder
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* Fluent builder for Rich Messages using HTML format.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const msg = new RichHTMLBuilder()
|
|
16
|
+
* .heading(1, 'Title')
|
|
17
|
+
* .paragraph(RichHTMLBuilder.bold('Hello') + ' world')
|
|
18
|
+
* .build()
|
|
19
|
+
*/
|
|
20
|
+
class RichHTMLBuilder {
|
|
21
|
+
constructor() {
|
|
22
|
+
this._parts = [];
|
|
23
|
+
}
|
|
24
|
+
// ── Inline static helpers ──────────────────────────────────────────────
|
|
25
|
+
static bold(t) { return `<b>${t}</b>`; }
|
|
26
|
+
static italic(t) { return `<i>${t}</i>`; }
|
|
27
|
+
static underline(t) { return `<u>${t}</u>`; }
|
|
28
|
+
static strikethrough(t) { return `<s>${t}</s>`; }
|
|
29
|
+
static spoiler(t) { return `<tg-spoiler>${t}</tg-spoiler>`; }
|
|
30
|
+
static code(t) { return `<code>${t}</code>`; }
|
|
31
|
+
static marked(t) { return `<mark>${t}</mark>`; }
|
|
32
|
+
static sub(t) { return `<sub>${t}</sub>`; }
|
|
33
|
+
static sup(t) { return `<sup>${t}</sup>`; }
|
|
34
|
+
static url(href, text) { return `<a href="${href}">${text}</a>`; }
|
|
35
|
+
static email(email, text) { return `<a href="mailto:${email}">${text !== null && text !== void 0 ? text : email}</a>`; }
|
|
36
|
+
static phone(phone, text) { return `<a href="tel:${phone}">${text !== null && text !== void 0 ? text : phone}</a>`; }
|
|
37
|
+
static mention(userId, text) { return `<a href="tg://user?id=${userId}">${text}</a>`; }
|
|
38
|
+
static customEmoji(emojiId, fallback) { return `<tg-emoji emoji-id="${emojiId}">${fallback}</tg-emoji>`; }
|
|
39
|
+
static time(unix, format, text) { return `<tg-time unix="${unix}" format="${format}">${text}</tg-time>`; }
|
|
40
|
+
static inlineMath(expression) { return `$${expression}$`; }
|
|
41
|
+
static anchor(name) { return `<a name="${name}"></a>`; }
|
|
42
|
+
static anchorLink(name, text) { return `<a href="#${name}">${text}</a>`; }
|
|
43
|
+
static ref(id, text) { return `<a href="#${id}">${text}</a>`; }
|
|
44
|
+
// ── Block methods ──────────────────────────────────────────────────────
|
|
45
|
+
heading(level, html) {
|
|
46
|
+
this._parts.push(`<h${level}>${html}</h${level}>`);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
paragraph(html) {
|
|
50
|
+
this._parts.push(`<p>${html}</p>`);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
pre(code, language) {
|
|
54
|
+
this._parts.push(language
|
|
55
|
+
? `<pre><code class="language-${language}">${code}</code></pre>`
|
|
56
|
+
: `<pre>${code}</pre>`);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
footer(html) {
|
|
60
|
+
this._parts.push(`<footer>${html}</footer>`);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
divider() {
|
|
64
|
+
this._parts.push('<hr/>');
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
ul(...items) {
|
|
68
|
+
this._parts.push(`<ul>${items.map((i) => `<li>${i}</li>`).join('')}</ul>`);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
ol(...items) {
|
|
72
|
+
this._parts.push(`<ol>${items.map((i) => `<li>${i}</li>`).join('')}</ol>`);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
taskList(...items) {
|
|
76
|
+
const lis = items.map((i) => `<li><input type="checkbox"${i.checked ? ' checked' : ''}>${i.text}</li>`);
|
|
77
|
+
this._parts.push(`<ul>${lis.join('')}</ul>`);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
blockQuote(html) {
|
|
81
|
+
this._parts.push(`<blockquote>${html}</blockquote>`);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
pullQuote(html, cite) {
|
|
85
|
+
this._parts.push(`<aside>${html}${cite ? `<cite>${cite}</cite>` : ''}</aside>`);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
photo(src, caption, spoiler) {
|
|
89
|
+
const img = `<img src="${src}"${spoiler ? ' tg-spoiler' : ''}/>`;
|
|
90
|
+
this._parts.push(caption ? `<figure>${img}<figcaption>${caption}</figcaption></figure>` : img);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
video(src, caption, spoiler) {
|
|
94
|
+
const vid = `<video src="${src}"${spoiler ? ' tg-spoiler' : ''}></video>`;
|
|
95
|
+
this._parts.push(caption ? `<figure>${vid}<figcaption>${caption}</figcaption></figure>` : vid);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
audio(src, caption) {
|
|
99
|
+
const aud = `<audio src="${src}"></audio>`;
|
|
100
|
+
this._parts.push(caption ? `<figure>${aud}<figcaption>${caption}</figcaption></figure>` : aud);
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
map(lat, long, zoom, caption) {
|
|
104
|
+
const tag = `<tg-map lat="${lat}" long="${long}"${zoom != null ? ` zoom="${zoom}"` : ''}/>`;
|
|
105
|
+
this._parts.push(caption ? `<figure>${tag}<figcaption>${caption}</figcaption></figure>` : tag);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
collage(...media) {
|
|
109
|
+
this._parts.push(`<tg-collage>${media.join('')}</tg-collage>`);
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
slideshow(...media) {
|
|
113
|
+
this._parts.push(`<tg-slideshow>${media.join('')}</tg-slideshow>`);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
table(rows, options) {
|
|
117
|
+
const attrs = [(options === null || options === void 0 ? void 0 : options.bordered) && 'bordered', (options === null || options === void 0 ? void 0 : options.striped) && 'striped']
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
.join(' ');
|
|
120
|
+
const [header, ...body] = rows;
|
|
121
|
+
const headHtml = (options === null || options === void 0 ? void 0 : options.hasHeader) && header
|
|
122
|
+
? `<tr>${header.map((c) => `<th>${c}</th>`).join('')}</tr>`
|
|
123
|
+
: '';
|
|
124
|
+
const bodyRows = ((options === null || options === void 0 ? void 0 : options.hasHeader) ? body : rows)
|
|
125
|
+
.map((r) => `<tr>${r.map((c) => `<td>${c}</td>`).join('')}</tr>`)
|
|
126
|
+
.join('');
|
|
127
|
+
this._parts.push(`<table${attrs ? ` ${attrs}` : ''}>${headHtml}${bodyRows}</table>`);
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
details(summary, content, open) {
|
|
131
|
+
this._parts.push(`<details${open ? ' open' : ''}><summary>${summary}</summary>${content}</details>`);
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
mathBlock(expression) {
|
|
135
|
+
this._parts.push(`<tg-math-block>${expression}</tg-math-block>`);
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
thinking(html) {
|
|
139
|
+
this._parts.push(`<tg-thinking>${html}</tg-thinking>`);
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
referenceDefinition(id, html) {
|
|
143
|
+
this._parts.push(`<tg-reference name="${id}">${html}</tg-reference>`);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
raw(html) {
|
|
147
|
+
this._parts.push(html);
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
build(options) {
|
|
151
|
+
return { html: this._parts.join('\n'), ...options };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.RichHTMLBuilder = RichHTMLBuilder;
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// Markdown Builder
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
/**
|
|
159
|
+
* Fluent builder for Rich Messages using Markdown format.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* const msg = new RichMarkdownBuilder()
|
|
163
|
+
* .heading(1, 'Title')
|
|
164
|
+
* .paragraph(RichMarkdownBuilder.bold('Hello') + ' world')
|
|
165
|
+
* .build()
|
|
166
|
+
*/
|
|
167
|
+
class RichMarkdownBuilder {
|
|
168
|
+
constructor() {
|
|
169
|
+
this._parts = [];
|
|
170
|
+
}
|
|
171
|
+
// ── Inline static helpers ──────────────────────────────────────────────
|
|
172
|
+
static bold(t) { return `**${t}**`; }
|
|
173
|
+
static italic(t) { return `*${t}*`; }
|
|
174
|
+
static underline(t) { return `<u>${t}</u>`; }
|
|
175
|
+
static strikethrough(t) { return `~~${t}~~`; }
|
|
176
|
+
static spoiler(t) { return `||${t}||`; }
|
|
177
|
+
static code(t) { return `\`${t}\``; }
|
|
178
|
+
static marked(t) { return `==${t}==`; }
|
|
179
|
+
static sub(t) { return `<sub>${t}</sub>`; }
|
|
180
|
+
static sup(t) { return `<sup>${t}</sup>`; }
|
|
181
|
+
static url(href, text) { return `[${text}](${href})`; }
|
|
182
|
+
static email(email, text) { return `[${text !== null && text !== void 0 ? text : email}](mailto:${email})`; }
|
|
183
|
+
static phone(phone, text) { return `[${text !== null && text !== void 0 ? text : phone}](tel:${phone})`; }
|
|
184
|
+
static mention(userId, text) { return `[${text}](tg://user?id=${userId})`; }
|
|
185
|
+
static customEmoji(emojiId, fallback) { return ``; }
|
|
186
|
+
static time(unix, format) { return ``; }
|
|
187
|
+
static inlineMath(expression) { return `$${expression}$`; }
|
|
188
|
+
// ── Block methods ──────────────────────────────────────────────────────
|
|
189
|
+
heading(level, text) {
|
|
190
|
+
this._parts.push(`${'#'.repeat(level)} ${text}`);
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
paragraph(text) {
|
|
194
|
+
this._parts.push(text);
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
pre(code, language) {
|
|
198
|
+
this._parts.push(`\`\`\`${language !== null && language !== void 0 ? language : ''}\n${code}\n\`\`\``);
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
divider() {
|
|
202
|
+
this._parts.push('---');
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
ul(...items) {
|
|
206
|
+
this._parts.push(items.map((i) => `- ${i}`).join('\n'));
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
ol(...items) {
|
|
210
|
+
this._parts.push(items.map((i, idx) => `${idx + 1}. ${i}`).join('\n'));
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
taskList(...items) {
|
|
214
|
+
this._parts.push(items.map((i) => `- [${i.checked ? 'x' : ' '}] ${i.text}`).join('\n'));
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
blockQuote(...lines) {
|
|
218
|
+
this._parts.push(lines.map((l) => `>${l}`).join('\n'));
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
photo(src, caption) {
|
|
222
|
+
this._parts.push(``);
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
video(src, caption) {
|
|
226
|
+
this._parts.push(``);
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
audio(src, caption) {
|
|
230
|
+
this._parts.push(``);
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
table(headers, rows, alignment) {
|
|
234
|
+
const sep = headers.map((_, i) => {
|
|
235
|
+
const a = alignment === null || alignment === void 0 ? void 0 : alignment[i];
|
|
236
|
+
if (a === 'center')
|
|
237
|
+
return ':---:';
|
|
238
|
+
if (a === 'right')
|
|
239
|
+
return '---:';
|
|
240
|
+
return ':---';
|
|
241
|
+
});
|
|
242
|
+
const lines = [
|
|
243
|
+
`| ${headers.join(' | ')} |`,
|
|
244
|
+
`|${sep.map((s) => s + '-').join('|')}|`,
|
|
245
|
+
...rows.map((r) => `| ${r.join(' | ')} |`),
|
|
246
|
+
];
|
|
247
|
+
this._parts.push(lines.join('\n'));
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
footnoteRef(id) { return `[^${id}]`; }
|
|
251
|
+
footnote(id, definition) {
|
|
252
|
+
this._parts.push(`[^${id}]: ${definition}`);
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
mathBlock(expression) {
|
|
256
|
+
this._parts.push(`$$${expression}$$`);
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
thinking(text) {
|
|
260
|
+
this._parts.push(`<tg-thinking>${text}</tg-thinking>`);
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
collage(...mediaSrcs) {
|
|
264
|
+
this._parts.push(`<tg-collage>\n${mediaSrcs.map((s) => ``).join('\n')}\n</tg-collage>`);
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
slideshow(...mediaSrcs) {
|
|
268
|
+
this._parts.push(`<tg-slideshow>\n${mediaSrcs.map((s) => ``).join('\n')}\n</tg-slideshow>`);
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
details(summary, content, open) {
|
|
272
|
+
this._parts.push(`<details${open ? ' open' : ''}><summary>${summary}</summary>\n${content}\n</details>`);
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
raw(md) {
|
|
276
|
+
this._parts.push(md);
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
build(options) {
|
|
280
|
+
return { markdown: this._parts.join('\n\n'), ...options };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.RichMarkdownBuilder = RichMarkdownBuilder;
|
|
284
|
+
/** Shorthand alias for RichHTMLBuilder */
|
|
285
|
+
exports.H = RichHTMLBuilder;
|
|
286
|
+
/** Shorthand alias for RichMarkdownBuilder */
|
|
287
|
+
exports.MD = RichMarkdownBuilder;
|
|
288
|
+
//# sourceMappingURL=rich-message.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./rich-message"), exports);
|
|
18
|
+
// internal type provisions
|
|
19
|
+
__exportStar(require("@telegraf/types/api"), exports);
|
|
20
|
+
__exportStar(require("@telegraf/types/inline"), exports);
|
|
21
|
+
__exportStar(require("@telegraf/types/manage"), exports);
|
|
22
|
+
__exportStar(require("@telegraf/types/markup"), exports);
|
|
23
|
+
__exportStar(require("@telegraf/types/message"), exports);
|
|
24
|
+
__exportStar(require("@telegraf/types/methods"), exports);
|
|
25
|
+
__exportStar(require("@telegraf/types/passport"), exports);
|
|
26
|
+
__exportStar(require("@telegraf/types/payment"), exports);
|
|
27
|
+
__exportStar(require("@telegraf/types/settings"), exports);
|
|
28
|
+
__exportStar(require("@telegraf/types/update"), exports);
|
|
29
|
+
//# sourceMappingURL=typegram.js.map
|
package/lib/filters.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allOf = exports.anyOf = exports.callbackQuery = exports.editedChannelPost = exports.channelPost = exports.editedMessage = exports.message = void 0;
|
|
4
|
+
const message = (...keys) => (update) => {
|
|
5
|
+
if (!('message' in update))
|
|
6
|
+
return false;
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
if (!(key in update.message))
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
exports.message = message;
|
|
14
|
+
const editedMessage = (...keys) => (update) => {
|
|
15
|
+
if (!('edited_message' in update))
|
|
16
|
+
return false;
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
if (!(key in update.edited_message))
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
exports.editedMessage = editedMessage;
|
|
24
|
+
const channelPost = (...keys) => (update) => {
|
|
25
|
+
if (!('channel_post' in update))
|
|
26
|
+
return false;
|
|
27
|
+
for (const key of keys) {
|
|
28
|
+
if (!(key in update.channel_post))
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
exports.channelPost = channelPost;
|
|
34
|
+
const editedChannelPost = (...keys) => (update) => {
|
|
35
|
+
if (!('edited_channel_post' in update))
|
|
36
|
+
return false;
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
if (!(key in update.edited_channel_post))
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
exports.editedChannelPost = editedChannelPost;
|
|
44
|
+
const callbackQuery = (...keys) => (update) => {
|
|
45
|
+
if (!('callback_query' in update))
|
|
46
|
+
return false;
|
|
47
|
+
for (const key of keys) {
|
|
48
|
+
if (!(key in update.callback_query))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
exports.callbackQuery = callbackQuery;
|
|
54
|
+
/** Any of the provided filters must match */
|
|
55
|
+
const anyOf = (...filters) => (update) => {
|
|
56
|
+
for (const filter of filters)
|
|
57
|
+
if (filter(update))
|
|
58
|
+
return true;
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
exports.anyOf = anyOf;
|
|
62
|
+
/** All of the provided filters must match */
|
|
63
|
+
const allOf = (...filters) => (update) => {
|
|
64
|
+
for (const filter of filters)
|
|
65
|
+
if (!filter(update))
|
|
66
|
+
return false;
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
exports.allOf = allOf;
|
|
70
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../src/filters.ts"],"names":[],"mappings":";;;AAwBO,MAAM,OAAO,GAClB,CAAqC,GAAG,IAAQ,EAAE,EAAE,CACpD,CACE,MAAc,EACsD,EAAE;IACtE,IAAI,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAA;IAC5C,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAVU,QAAA,OAAO,WAUjB;AAEI,MAAM,aAAa,GACxB,CAAiD,GAAG,IAAQ,EAAE,EAAE,CAChE,CACE,MAAc,EAGd,EAAE;IACF,IAAI,CAAC,CAAC,gBAAgB,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC;YAAE,OAAO,KAAK,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAZU,QAAA,aAAa,iBAYvB;AAEI,MAAM,WAAW,GACtB,CAAqC,GAAG,IAAQ,EAAE,EAAE,CACpD,CACE,MAAc,EAC0D,EAAE;IAC1E,IAAI,CAAC,CAAC,cAAc,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC;YAAE,OAAO,KAAK,CAAA;IACjD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAVU,QAAA,WAAW,eAUrB;AAEI,MAAM,iBAAiB,GAC5B,CAAiD,GAAG,IAAQ,EAAE,EAAE,CAChE,CACE,MAAc,EAGd,EAAE;IACF,IAAI,CAAC,CAAC,qBAAqB,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IACpD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC;YAAE,OAAO,KAAK,CAAA;IACxD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAZU,QAAA,iBAAiB,qBAY3B;AAEI,MAAM,aAAa,GACxB,CAA2C,GAAG,IAAQ,EAAE,EAAE,CAC1D,CACE,MAAc,EAGd,EAAE;IACF,IAAI,CAAC,CAAC,gBAAgB,IAAI,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC;YAAE,OAAO,KAAK,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAZU,QAAA,aAAa,iBAYvB;AAEH,6CAA6C;AACtC,MAAM,KAAK,GAChB,CACE,GAAG,OAEF,EACD,EAAE,CACJ,CAAC,MAAc,EAAwB,EAAE;IACvC,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,IAAI,MAAM,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAA;IAC7D,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AATU,QAAA,KAAK,SASf;AAEH,6CAA6C;AACtC,MAAM,KAAK,GAChB,CAA2C,GAAG,OAAW,EAAE,EAAE,CAC7D,CAAC,MAAc,EAA4B,EAAE;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAA;IAC/D,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AALU,QAAA,KAAK,SAKf"}
|
package/lib/format.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mention = exports.link = exports.pre = exports.code = exports.quote = exports.underline = exports.strikethrough = exports.spoiler = exports.italic = exports.bold = exports.fmt = exports.join = exports.FmtString = void 0;
|
|
4
|
+
const formatting_1 = require("./core/helpers/formatting");
|
|
5
|
+
Object.defineProperty(exports, "FmtString", { enumerable: true, get: function () { return formatting_1.FmtString; } });
|
|
6
|
+
// Nests<A, B> means the function will return A, and it can nest B
|
|
7
|
+
// Nests<'fmt', string> means it will nest anything
|
|
8
|
+
// Nests<'code', never> means it will not nest anything
|
|
9
|
+
// Allowing everything to nest 'fmt' is a necessary evil; it allows to indirectly nest illegal entities
|
|
10
|
+
// Except for 'code' and 'pre', which don't nest anything anyway, so they only deal with strings
|
|
11
|
+
exports.join = formatting_1.join;
|
|
12
|
+
exports.fmt = (0, formatting_1.createFmt)();
|
|
13
|
+
exports.bold = (0, formatting_1.createFmt)('bold');
|
|
14
|
+
exports.italic = (0, formatting_1.createFmt)('italic');
|
|
15
|
+
exports.spoiler = (0, formatting_1.createFmt)('spoiler');
|
|
16
|
+
exports.strikethrough =
|
|
17
|
+
//
|
|
18
|
+
(0, formatting_1.createFmt)('strikethrough');
|
|
19
|
+
exports.underline =
|
|
20
|
+
//
|
|
21
|
+
(0, formatting_1.createFmt)('underline');
|
|
22
|
+
exports.quote =
|
|
23
|
+
//
|
|
24
|
+
(0, formatting_1.createFmt)('blockquote');
|
|
25
|
+
exports.code = (0, formatting_1.createFmt)('code');
|
|
26
|
+
const pre = (language) => (0, formatting_1.createFmt)('pre', { language });
|
|
27
|
+
exports.pre = pre;
|
|
28
|
+
const link = (content, url) =>
|
|
29
|
+
//
|
|
30
|
+
(0, formatting_1.linkOrMention)(content, { type: 'text_link', url });
|
|
31
|
+
exports.link = link;
|
|
32
|
+
const mention = (name, user) => typeof user === 'number'
|
|
33
|
+
? (0, exports.link)(name, 'tg://user?id=' + user)
|
|
34
|
+
: (0, formatting_1.linkOrMention)(name, {
|
|
35
|
+
type: 'text_mention',
|
|
36
|
+
user,
|
|
37
|
+
});
|
|
38
|
+
exports.mention = mention;
|
|
39
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":";;;AACA,0DAKkC;AAEzB,0FANP,sBAAS,OAMO;AAWlB,kEAAkE;AAClE,mDAAmD;AACnD,uDAAuD;AAEvD,uGAAuG;AACvG,gGAAgG;AAEnF,QAAA,IAAI,GAAG,iBAA6B,CAAA;AAEpC,QAAA,GAAG,GAAG,IAAA,sBAAS,GAA0B,CAAA;AAEzC,QAAA,IAAI,GAAG,IAAA,sBAAS,EAAC,MAAM,CAGnC,CAAA;AAEY,QAAA,MAAM,GAAG,IAAA,sBAAS,EAAC,QAAQ,CAGvC,CAAA;AAEY,QAAA,OAAO,GAAG,IAAA,sBAAS,EAAC,SAAS,CAGzC,CAAA;AAEY,QAAA,aAAa;AACxB,EAAE;AACF,IAAA,sBAAS,EAAC,eAAe,CAGxB,CAAA;AAEU,QAAA,SAAS;AACpB,EAAE;AACF,IAAA,sBAAS,EAAC,WAAW,CAGpB,CAAA;AAEU,QAAA,KAAK;AAChB,EAAE;AACF,IAAA,sBAAS,EAAC,YAAY,CASrB,CAAA;AAEU,QAAA,IAAI,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAyB,CAAA;AAEtD,MAAM,GAAG,GAAG,CAAC,QAAgB,EAAE,EAAE,CACtC,IAAA,sBAAS,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAwB,CAAA;AAD1C,QAAA,GAAG,OACuC;AAEhD,MAAM,IAAI,GAAG,CAClB,OAQC,EACD,GAAW,EACX,EAAE;AACF,EAAE;AACF,IAAA,0BAAa,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAA2B,CAAA;AAbjE,QAAA,IAAI,QAa6D;AAEvE,MAAM,OAAO,GAAG,CACrB,IAQC,EACD,IAAmB,EACnB,EAAE,CACF,OAAO,IAAI,KAAK,QAAQ;IACtB,CAAC,CAAC,IAAA,YAAI,EAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IACpC,CAAC,CAAE,IAAA,0BAAa,EAAC,IAAI,EAAE;QACnB,IAAI,EAAE,cAAc;QACpB,IAAI;KACL,CAA+B,CAAA;AAjBzB,QAAA,OAAO,WAiBkB"}
|