@adriangalilea/utils 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/dist/bot/access-control.d.ts +91 -58
- package/dist/bot/access-control.d.ts.map +1 -1
- package/dist/bot/access-control.js +105 -75
- package/dist/bot/access-control.js.map +1 -1
- package/dist/bot/coalesce.d.ts +107 -0
- package/dist/bot/coalesce.d.ts.map +1 -0
- package/dist/bot/coalesce.js +155 -0
- package/dist/bot/coalesce.js.map +1 -0
- package/dist/bot/index.d.ts +4 -0
- package/dist/bot/index.d.ts.map +1 -1
- package/dist/bot/index.js +4 -0
- package/dist/bot/index.js.map +1 -1
- package/dist/bot/kit.d.ts.map +1 -1
- package/dist/bot/kit.js +6 -0
- package/dist/bot/kit.js.map +1 -1
- package/dist/bot/language.d.ts +279 -0
- package/dist/bot/language.d.ts.map +1 -0
- package/dist/bot/language.js +222 -0
- package/dist/bot/language.js.map +1 -0
- package/dist/bot/menu.d.ts +175 -0
- package/dist/bot/menu.d.ts.map +1 -0
- package/dist/bot/menu.js +284 -0
- package/dist/bot/menu.js.map +1 -0
- package/dist/bot/message-history.d.ts +259 -0
- package/dist/bot/message-history.d.ts.map +1 -0
- package/dist/bot/message-history.js +111 -0
- package/dist/bot/message-history.js.map +1 -0
- package/package.json +17 -1
- package/dist/currency/crypto-symbols-data.d.ts +0 -10
- package/dist/currency/crypto-symbols-data.d.ts.map +0 -1
- package/dist/currency/crypto-symbols-data.js +0 -13765
- package/dist/currency/crypto-symbols-data.js.map +0 -1
- package/dist/currency/crypto-symbols.d.ts +0 -20
- package/dist/currency/crypto-symbols.d.ts.map +0 -1
- package/dist/currency/crypto-symbols.js +0 -23
- package/dist/currency/crypto-symbols.js.map +0 -1
- package/dist/currency/download-crypto-list.d.ts +0 -10
- package/dist/currency/download-crypto-list.d.ts.map +0 -1
- package/dist/currency/download-crypto-list.js +0 -69
- package/dist/currency/download-crypto-list.js.map +0 -1
- package/dist/currency/index.d.ts +0 -84
- package/dist/currency/index.d.ts.map +0 -1
- package/dist/currency/index.js +0 -230
- package/dist/currency/index.js.map +0 -1
- package/dist/dir.d.ts +0 -40
- package/dist/dir.d.ts.map +0 -1
- package/dist/dir.js +0 -108
- package/dist/dir.js.map +0 -1
- package/dist/file.d.ts +0 -53
- package/dist/file.d.ts.map +0 -1
- package/dist/file.js +0 -211
- package/dist/file.js.map +0 -1
- package/dist/format.d.ts +0 -40
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js +0 -83
- package/dist/format.js.map +0 -1
- package/dist/kev.d.ts +0 -149
- package/dist/kev.d.ts.map +0 -1
- package/dist/kev.js +0 -761
- package/dist/kev.js.map +0 -1
- package/dist/log.d.ts +0 -91
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -300
- package/dist/log.js.map +0 -1
- package/dist/logger.d.ts +0 -91
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -269
- package/dist/logger.js.map +0 -1
- package/dist/path.d.ts +0 -67
- package/dist/path.d.ts.map +0 -1
- package/dist/path.js +0 -107
- package/dist/path.js.map +0 -1
- package/dist/project.d.ts +0 -35
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -154
- package/dist/project.js.map +0 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coalesce client-split inbound messages.
|
|
3
|
+
*
|
|
4
|
+
* Telegram clients (Desktop / iOS / web) split a single message > 4096
|
|
5
|
+
* chars into multiple `sendMessage` calls before they ever reach the
|
|
6
|
+
* server. The bot receives them as **separate** `message` updates with
|
|
7
|
+
* no marker linking them. This middleware joins them back into one
|
|
8
|
+
* event so your handlers see the full text.
|
|
9
|
+
*
|
|
10
|
+
* user pastes 8000 chars → client splits in 2 → bot gets 2 updates
|
|
11
|
+
* │
|
|
12
|
+
* ▼
|
|
13
|
+
* coalesce middleware
|
|
14
|
+
* │
|
|
15
|
+
* hold + join
|
|
16
|
+
* │
|
|
17
|
+
* ▼
|
|
18
|
+
* handler sees ONE event
|
|
19
|
+
* with full ctx.text
|
|
20
|
+
*
|
|
21
|
+
* ## Detection rule (strict)
|
|
22
|
+
*
|
|
23
|
+
* We coalesce only when ALL hold. Otherwise fragments pass through
|
|
24
|
+
* as separate events — false negatives are preferred over silently
|
|
25
|
+
* merging unrelated messages.
|
|
26
|
+
*
|
|
27
|
+
* 1. Same chat.
|
|
28
|
+
* 2. Same user (override with `acrossUsers: true`).
|
|
29
|
+
* 3. Leading fragment length ≥ `minLeadingLength` (a current
|
|
30
|
+
* guess — see the type definition for the default and the
|
|
31
|
+
* reasoning). Short messages never start a real client split.
|
|
32
|
+
* 4. Each subsequent fragment within `windowMs` of the previous.
|
|
33
|
+
*
|
|
34
|
+
* ## Known caveats
|
|
35
|
+
*
|
|
36
|
+
* - `ctx.entities` is cleared on coalesced messages — per-fragment
|
|
37
|
+
* entity offsets would point at the wrong characters once joined.
|
|
38
|
+
* Plain-text consumers don't care; formatted-input consumers
|
|
39
|
+
* should disable this plugin.
|
|
40
|
+
* - In-memory buffer; doesn't survive bot restart mid-burst.
|
|
41
|
+
*
|
|
42
|
+
* Peer deps: `gramio`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { Bot } from 'gramio'
|
|
46
|
+
* import { coalesceLongMessages } from '@adriangalilea/utils/bot/coalesce'
|
|
47
|
+
*
|
|
48
|
+
* const bot = new Bot(process.env.BOT_TOKEN!)
|
|
49
|
+
* .extend(coalesceLongMessages()) // ← before .on / .command handlers
|
|
50
|
+
* .on('message', (ctx) => {
|
|
51
|
+
* // ctx.text is the full pasted text even if Telegram split it
|
|
52
|
+
* return ctx.send(`got ${ctx.text?.length} chars`)
|
|
53
|
+
* })
|
|
54
|
+
*
|
|
55
|
+
* @example Power-user escape hatch
|
|
56
|
+
*
|
|
57
|
+
* import { isCoalescent } from '@adriangalilea/utils/bot/coalesce'
|
|
58
|
+
*
|
|
59
|
+
* if (isCoalescent(prev, curr)) {
|
|
60
|
+
* // do your own thing
|
|
61
|
+
* }
|
|
62
|
+
*/
|
|
63
|
+
import { Plugin } from 'gramio';
|
|
64
|
+
// Current guess. Real Telegram clients split at natural boundaries
|
|
65
|
+
// (newline / paragraph / sentence) before the 4096 cap, but we don't
|
|
66
|
+
// yet have a solid dataset of where they actually land. Adjust as
|
|
67
|
+
// real-world data comes in. Single source of truth — both
|
|
68
|
+
// `isCoalescent` and the middleware read from here.
|
|
69
|
+
const DEFAULT_MIN_LEADING_LENGTH = 3750;
|
|
70
|
+
const DEFAULT_WINDOW_MS = 500;
|
|
71
|
+
const DEFAULT_ACROSS_USERS = false;
|
|
72
|
+
export const isCoalescent = (prev, curr, opts = {}) => {
|
|
73
|
+
const minLeadingLength = opts.minLeadingLength ?? DEFAULT_MIN_LEADING_LENGTH;
|
|
74
|
+
const windowMs = opts.windowMs ?? DEFAULT_WINDOW_MS;
|
|
75
|
+
const acrossUsers = opts.acrossUsers ?? DEFAULT_ACROSS_USERS;
|
|
76
|
+
if (prev.chatId !== curr.chatId)
|
|
77
|
+
return false;
|
|
78
|
+
if (!acrossUsers && prev.userId !== curr.userId)
|
|
79
|
+
return false;
|
|
80
|
+
if (prev.text.length < minLeadingLength)
|
|
81
|
+
return false;
|
|
82
|
+
if (curr.dateMs - prev.dateMs > windowMs)
|
|
83
|
+
return false;
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
export const coalesceLongMessages = (opts = {}) => {
|
|
87
|
+
const minLeadingLength = opts.minLeadingLength ?? DEFAULT_MIN_LEADING_LENGTH;
|
|
88
|
+
const windowMs = opts.windowMs ?? DEFAULT_WINDOW_MS;
|
|
89
|
+
const acrossUsers = opts.acrossUsers ?? DEFAULT_ACROSS_USERS;
|
|
90
|
+
const log = opts.log ?? false;
|
|
91
|
+
const dbg = (msg) => {
|
|
92
|
+
if (log)
|
|
93
|
+
console.error(`[coalesce] ${msg}`);
|
|
94
|
+
};
|
|
95
|
+
// Keyed per `<chatId>:<userId>` (or `<chatId>` when acrossUsers).
|
|
96
|
+
// Buffer lives only as long as fragments are still arriving — gets
|
|
97
|
+
// deleted on flush.
|
|
98
|
+
const buffers = new Map();
|
|
99
|
+
const keyFor = (chatId, userId) => acrossUsers ? `${chatId}` : `${chatId}:${userId}`;
|
|
100
|
+
return new Plugin('@adriangalilea/utils/bot/coalesce').use(async (ctx, next) => {
|
|
101
|
+
if (!ctx.is('message') || ctx.text === undefined)
|
|
102
|
+
return next();
|
|
103
|
+
const key = keyFor(ctx.chat.id, ctx.from.id);
|
|
104
|
+
const existing = buffers.get(key);
|
|
105
|
+
if (existing) {
|
|
106
|
+
// Continuation fragment — fold into the held buffer and reset
|
|
107
|
+
// the timer. No length check on continuations: once a buffer
|
|
108
|
+
// is open, anything within the window joins (the tail of a
|
|
109
|
+
// split is typically short). We don't call next(); this update
|
|
110
|
+
// is swallowed. The first fragment held by `existing.flush`
|
|
111
|
+
// will eventually fire next() with the combined text.
|
|
112
|
+
dbg(`join key=${key} len=${ctx.text.length} buffered=${existing.text.length}→${existing.text.length + ctx.text.length}`);
|
|
113
|
+
clearTimeout(existing.timer);
|
|
114
|
+
existing.text += ctx.text;
|
|
115
|
+
existing.timer = setTimeout(existing.flush, windowMs);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (ctx.text.length < minLeadingLength) {
|
|
119
|
+
// Short message → can never be the leading fragment of a real
|
|
120
|
+
// client split. Zero-latency passthrough.
|
|
121
|
+
dbg(`passthrough key=${key} len=${ctx.text.length} (<${minLeadingLength})`);
|
|
122
|
+
return next();
|
|
123
|
+
}
|
|
124
|
+
// Suspicious leading fragment: hold + start the wait window.
|
|
125
|
+
// Returns a Promise that only resolves after the buffer flushes
|
|
126
|
+
// (next() of THIS ctx is called with the combined text). This
|
|
127
|
+
// keeps gramio's middleware chain awaiting until we're done.
|
|
128
|
+
dbg(`open key=${key} len=${ctx.text.length} (≥${minLeadingLength}, wait ${windowMs}ms)`);
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
const buffered = {
|
|
131
|
+
text: ctx.text,
|
|
132
|
+
timer: setTimeout(() => buffered.flush(), windowMs),
|
|
133
|
+
flush: () => {
|
|
134
|
+
// Detach from the map FIRST so any fragment arriving mid-flush
|
|
135
|
+
// starts a fresh buffer instead of re-entering this one.
|
|
136
|
+
dbg(`flush key=${key} total=${buffered.text.length}`);
|
|
137
|
+
buffers.delete(key);
|
|
138
|
+
// gramio's MessageContext exposes `text` as an accessor
|
|
139
|
+
// with both `get` and `set` — assignment is the supported
|
|
140
|
+
// way to override. We don't touch `entities`: fragment-1
|
|
141
|
+
// entities reference fragment-1 text only, but plain-text
|
|
142
|
+
// consumers (the sensible use of this plugin) ignore them.
|
|
143
|
+
// Formatted-input consumers should disable the plugin.
|
|
144
|
+
ctx.text = buffered.text;
|
|
145
|
+
// Hand off to the rest of the chain. Resolve outer Promise
|
|
146
|
+
// once the chain (and any downstream awaits) settles, so
|
|
147
|
+
// gramio considers this middleware fully done.
|
|
148
|
+
Promise.resolve(next()).then(() => resolve(), reject);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
buffers.set(key, buffered);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=coalesce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalesce.js","sourceRoot":"","sources":["../../src/bot/coalesce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,mEAAmE;AACnE,qEAAqE;AACrE,kEAAkE;AAClE,0DAA0D;AAC1D,oDAAoD;AACpD,MAAM,0BAA0B,GAAG,IAAI,CAAA;AACvC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAC7B,MAAM,oBAAoB,GAAG,KAA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/bot/index.d.ts
CHANGED
|
@@ -13,5 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export * from './kit.js';
|
|
15
15
|
export * from './access-control.js';
|
|
16
|
+
export * from './coalesce.js';
|
|
16
17
|
export * from './llm-stream.js';
|
|
18
|
+
export * from './menu.js';
|
|
19
|
+
export * from './language.js';
|
|
20
|
+
export * from './message-history.js';
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/bot/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
package/dist/bot/index.js
CHANGED
|
@@ -13,5 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export * from './kit.js';
|
|
15
15
|
export * from './access-control.js';
|
|
16
|
+
export * from './coalesce.js';
|
|
16
17
|
export * from './llm-stream.js';
|
|
18
|
+
export * from './menu.js';
|
|
19
|
+
export * from './language.js';
|
|
20
|
+
export * from './message-history.js';
|
|
17
21
|
//# sourceMappingURL=index.js.map
|
package/dist/bot/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
package/dist/bot/kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/bot/kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACvC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,KAAK,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,OAAM,oBAAyB,KAC9B,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/bot/kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACvC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,KAAK,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,OAAM,oBAAyB,KAC9B,OAAO,CAAC,IAAI,CAwCd,CAAA;AAID,MAAM,MAAM,mBAAmB,GAAG;IAChC,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAM,mBAAwB;;;;;;;;MAqB1D,CAAA"}
|
package/dist/bot/kit.js
CHANGED
|
@@ -29,6 +29,12 @@ export const gracefulStart = async (bot, opts = {}) => {
|
|
|
29
29
|
};
|
|
30
30
|
process.on('SIGINT', () => void stop('SIGINT'));
|
|
31
31
|
process.on('SIGTERM', () => void stop('SIGTERM'));
|
|
32
|
+
// Publish all `.command(name, { description }, …)` registrations to
|
|
33
|
+
// Telegram via `setMyCommands`. Hashes scopes internally so unchanged
|
|
34
|
+
// metadata doesn't burn rate-limit budget. Hidden / un-described
|
|
35
|
+
// commands are skipped.
|
|
36
|
+
// See https://gramio.dev/triggers/command.html#how-synccommands-works
|
|
37
|
+
bot.onStart(() => bot.syncCommands());
|
|
32
38
|
await bot.start();
|
|
33
39
|
};
|
|
34
40
|
export const adminContext = (opts = {}) => {
|
package/dist/bot/kit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.js","sourceRoot":"","sources":["../../src/bot/kit.ts"],"names":[],"mappings":"AAwBA,OA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AE,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC/C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;IAEjD,oEAAoE;IACpE,sEAAsE;IACtE,iEAAiE;IACjE,wBAAwB;IACxB,sEAAsE;IACtE,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAA;IAErC,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;AACnB,CAAC,CAAA;AASD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAE,EAAE,EAAE;IAC7D,qFAAqF;IACrF,+EAA+E;IAC/E,oEAAoE;IACpE,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAA;IAE/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mEAAmE;YACjE,6CAA6C,CAChD,CAAA;IACH,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,gCAAgC,CAAC;SAChD,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;SACrB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAChB,sEAAsE;QACtE,mEAAmE;QACnE,yDAAyD;QACzD,OAAO,EAAE,UAAU,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO;KACvD,CAAC,CAAC,CAAA;AACP,CAAC,CAAA"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-user language preference for GramIO bots.
|
|
3
|
+
*
|
|
4
|
+
* Follows gramio's canonical "shared infrastructure" pattern (see
|
|
5
|
+
* [Composer docs — Production Architecture](https://gramio.dev/extend/middleware.html#production-architecture)):
|
|
6
|
+
* the bot's session is extended once at the top level by the user,
|
|
7
|
+
* and each feature plugin declares it as a required dependency.
|
|
8
|
+
* gramio's runtime deduplication ensures the session derive runs
|
|
9
|
+
* exactly once per update; TypeScript flows the session's data shape
|
|
10
|
+
* into every plugin that `.extend()`s it.
|
|
11
|
+
*
|
|
12
|
+
* ## What this plugin owns
|
|
13
|
+
*
|
|
14
|
+
* - Validates the supported BCP-47 language tags via `Intl.getCanonicalLocales`
|
|
15
|
+
* - Resolves `ctx.lang` on every event (override → Telegram hint → default)
|
|
16
|
+
* - Persists the user's chosen language as `ctx.session.language`
|
|
17
|
+
* - Provides a `menuItem` for a `botMenu`'s language picker
|
|
18
|
+
*
|
|
19
|
+
* ## What this plugin does NOT own
|
|
20
|
+
*
|
|
21
|
+
* - The session itself. The user creates it (`session(...)`) and
|
|
22
|
+
* extends it at bot level before this plugin.
|
|
23
|
+
* - GDPR machinery. A language preference is trivially covered by
|
|
24
|
+
* [Telegram's Standard Bot Privacy Policy](https://telegram.org/privacy-tpa)
|
|
25
|
+
* under "data necessary to function".
|
|
26
|
+
*
|
|
27
|
+
* ## Resolution priority for `ctx.lang`
|
|
28
|
+
*
|
|
29
|
+
* 1. `ctx.session.language` — stored override
|
|
30
|
+
* 2. `ctx.from.languageCode` — Telegram-detected user lang, only in
|
|
31
|
+
* user-scoped resolution (in groups it would flicker per-speaker)
|
|
32
|
+
* 3. `default` — the fallback passed at construction
|
|
33
|
+
*
|
|
34
|
+
* Peer deps: `gramio`, `@gramio/session`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* import { Bot } from 'gramio'
|
|
38
|
+
* import { session } from '@gramio/session'
|
|
39
|
+
* import { redisStorage } from '@gramio/storage-redis'
|
|
40
|
+
* import { language } from '@adriangalilea/utils/bot/language'
|
|
41
|
+
*
|
|
42
|
+
* const userSession = session({
|
|
43
|
+
* storage: redisStorage(),
|
|
44
|
+
* key: 'session',
|
|
45
|
+
* initial: () => ({}), // plugins add their fields by convention
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* const lang = language({
|
|
49
|
+
* session: userSession,
|
|
50
|
+
* supported: ['en','es'] as const,
|
|
51
|
+
* default: 'en',
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* const bot = new Bot(process.env.BOT_TOKEN!)
|
|
55
|
+
* .extend(userSession) // ← FIRST: ctx.session lands on the real ctx
|
|
56
|
+
* .extend(lang.plugin) // declares userSession as dep; runtime dedup
|
|
57
|
+
* .command('hello', (ctx) => ctx.send({ en: 'Hello', es: 'Hola' }[ctx.lang]))
|
|
58
|
+
*/
|
|
59
|
+
import { type DeriveDefinitions, Plugin } from 'gramio';
|
|
60
|
+
import { session } from '@gramio/session';
|
|
61
|
+
import type { MenuItem } from './menu.js';
|
|
62
|
+
/** Branded BCP-47 language tag — obtainable only via the validators below. */
|
|
63
|
+
export type LangCode = string & {
|
|
64
|
+
readonly __langCode: unique symbol;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Validate + canonicalize a BCP-47 tag using the standard
|
|
68
|
+
* `Intl.getCanonicalLocales`. Throws `RangeError` on invalid input.
|
|
69
|
+
* Canonicalizes casing: `'en-us'` → `'en-US'`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const parseLangCode: (s: string) => LangCode;
|
|
72
|
+
/** Non-throwing type guard. Same parser path as `parseLangCode`. */
|
|
73
|
+
export declare const isLangCode: (s: unknown) => s is LangCode;
|
|
74
|
+
export type LanguageScopeStrategy = 'user' | 'chat';
|
|
75
|
+
export type LanguageScope = LanguageScopeStrategy | {
|
|
76
|
+
private?: LanguageScopeStrategy;
|
|
77
|
+
group?: LanguageScopeStrategy;
|
|
78
|
+
supergroup?: LanguageScopeStrategy;
|
|
79
|
+
channel?: LanguageScopeStrategy;
|
|
80
|
+
};
|
|
81
|
+
/** Loose session shape — the plugin only touches the `language` field. */
|
|
82
|
+
type SessionLike = {
|
|
83
|
+
language?: string;
|
|
84
|
+
};
|
|
85
|
+
/** @internal — kept unexported so it doesn't clash with peers' refs. */
|
|
86
|
+
type LangSessionPluginRef = ReturnType<typeof session<SessionLike, 'session'>>;
|
|
87
|
+
export type LanguageOptions<Langs extends readonly string[]> = {
|
|
88
|
+
/**
|
|
89
|
+
* The session plugin to read/write `ctx.session.language` from.
|
|
90
|
+
* Must be extended on the bot before this plugin (gramio's runtime
|
|
91
|
+
* dedup ensures the session derive only runs once per update).
|
|
92
|
+
*/
|
|
93
|
+
session: LangSessionPluginRef;
|
|
94
|
+
/** Tuple of BCP-47 tags. Each validated via `Intl.getCanonicalLocales`. */
|
|
95
|
+
supported: Langs;
|
|
96
|
+
/** Must be a member of `supported`. */
|
|
97
|
+
default: Langs[number];
|
|
98
|
+
/** See module docstring. Per chat-type override possible. */
|
|
99
|
+
scope?: LanguageScope;
|
|
100
|
+
/**
|
|
101
|
+
* Override per-language menu label. Default uses an emoji flag prefix
|
|
102
|
+
* derived from the language code.
|
|
103
|
+
*/
|
|
104
|
+
labels?: Partial<Record<Langs[number], string>>;
|
|
105
|
+
/** Header text for the language sub-menu. Default `'🌐 Language'`. */
|
|
106
|
+
menuLabel?: string;
|
|
107
|
+
};
|
|
108
|
+
export type LanguageFeature<Lang extends string> = {
|
|
109
|
+
plugin: ReturnType<typeof buildLanguagePlugin<Lang>>;
|
|
110
|
+
menuItem: MenuItem;
|
|
111
|
+
};
|
|
112
|
+
type LanguageDerives<Lang extends string> = {
|
|
113
|
+
lang: Lang;
|
|
114
|
+
};
|
|
115
|
+
export declare const language: <const Langs extends readonly string[]>(opts: LanguageOptions<Langs>) => LanguageFeature<Langs[number]>;
|
|
116
|
+
declare const buildLanguagePlugin: <Lang extends string>(args: {
|
|
117
|
+
sessionPlugin: LangSessionPluginRef;
|
|
118
|
+
canonicalSet: ReadonlySet<string>;
|
|
119
|
+
defaultLanguage: Lang;
|
|
120
|
+
matchSupported: (s: string | undefined) => Lang | undefined;
|
|
121
|
+
scopeOpt: LanguageScope | undefined;
|
|
122
|
+
}) => Plugin<{}, DeriveDefinitions & {
|
|
123
|
+
global: LanguageDerives<Lang>;
|
|
124
|
+
} & {
|
|
125
|
+
message: {
|
|
126
|
+
session: SessionLike & {
|
|
127
|
+
$clear: () => Promise<void>;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
channel_post: {
|
|
131
|
+
session: SessionLike & {
|
|
132
|
+
$clear: () => Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
inline_query: {
|
|
136
|
+
session: SessionLike & {
|
|
137
|
+
$clear: () => Promise<void>;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
chosen_inline_result: {
|
|
141
|
+
session: SessionLike & {
|
|
142
|
+
$clear: () => Promise<void>;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
callback_query: {
|
|
146
|
+
session: SessionLike & {
|
|
147
|
+
$clear: () => Promise<void>;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
shipping_query: {
|
|
151
|
+
session: SessionLike & {
|
|
152
|
+
$clear: () => Promise<void>;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
pre_checkout_query: {
|
|
156
|
+
session: SessionLike & {
|
|
157
|
+
$clear: () => Promise<void>;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
poll_answer: {
|
|
161
|
+
session: SessionLike & {
|
|
162
|
+
$clear: () => Promise<void>;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
chat_join_request: {
|
|
166
|
+
session: SessionLike & {
|
|
167
|
+
$clear: () => Promise<void>;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
new_chat_members: {
|
|
171
|
+
session: SessionLike & {
|
|
172
|
+
$clear: () => Promise<void>;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
new_chat_title: {
|
|
176
|
+
session: SessionLike & {
|
|
177
|
+
$clear: () => Promise<void>;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
new_chat_photo: {
|
|
181
|
+
session: SessionLike & {
|
|
182
|
+
$clear: () => Promise<void>;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
delete_chat_photo: {
|
|
186
|
+
session: SessionLike & {
|
|
187
|
+
$clear: () => Promise<void>;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
group_chat_created: {
|
|
191
|
+
session: SessionLike & {
|
|
192
|
+
$clear: () => Promise<void>;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
message_auto_delete_timer_changed: {
|
|
196
|
+
session: SessionLike & {
|
|
197
|
+
$clear: () => Promise<void>;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
migrate_to_chat_id: {
|
|
201
|
+
session: SessionLike & {
|
|
202
|
+
$clear: () => Promise<void>;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
migrate_from_chat_id: {
|
|
206
|
+
session: SessionLike & {
|
|
207
|
+
$clear: () => Promise<void>;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
pinned_message: {
|
|
211
|
+
session: SessionLike & {
|
|
212
|
+
$clear: () => Promise<void>;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
invoice: {
|
|
216
|
+
session: SessionLike & {
|
|
217
|
+
$clear: () => Promise<void>;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
successful_payment: {
|
|
221
|
+
session: SessionLike & {
|
|
222
|
+
$clear: () => Promise<void>;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
chat_shared: {
|
|
226
|
+
session: SessionLike & {
|
|
227
|
+
$clear: () => Promise<void>;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
proximity_alert_triggered: {
|
|
231
|
+
session: SessionLike & {
|
|
232
|
+
$clear: () => Promise<void>;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
video_chat_scheduled: {
|
|
236
|
+
session: SessionLike & {
|
|
237
|
+
$clear: () => Promise<void>;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
video_chat_started: {
|
|
241
|
+
session: SessionLike & {
|
|
242
|
+
$clear: () => Promise<void>;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
video_chat_ended: {
|
|
246
|
+
session: SessionLike & {
|
|
247
|
+
$clear: () => Promise<void>;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
video_chat_participants_invited: {
|
|
251
|
+
session: SessionLike & {
|
|
252
|
+
$clear: () => Promise<void>;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
web_app_data: {
|
|
256
|
+
session: SessionLike & {
|
|
257
|
+
$clear: () => Promise<void>;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
location: {
|
|
261
|
+
session: SessionLike & {
|
|
262
|
+
$clear: () => Promise<void>;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
passport_data: {
|
|
266
|
+
session: SessionLike & {
|
|
267
|
+
$clear: () => Promise<void>;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
} & {
|
|
271
|
+
message: {
|
|
272
|
+
lang: Lang;
|
|
273
|
+
};
|
|
274
|
+
callback_query: {
|
|
275
|
+
lang: Lang;
|
|
276
|
+
};
|
|
277
|
+
}, {}>;
|
|
278
|
+
export {};
|
|
279
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/bot/language.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIzC,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,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