@2byte/tgbot-framework 1.0.11 → 1.0.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2byte/tgbot-framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "A TypeScript framework for creating Telegram bots with sections-based architecture (Bun optimized)",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dotenv": "^16.6.1",
|
|
35
35
|
"fs-extra": "^11.3.2",
|
|
36
36
|
"input": "^1.0.1",
|
|
37
|
-
"inquirer": "^
|
|
37
|
+
"inquirer": "^13.2.2",
|
|
38
38
|
"mustache": "^4.2.0",
|
|
39
39
|
"socks": "^2.8.6",
|
|
40
40
|
"telegraf": "^4.16.3",
|
|
@@ -4,6 +4,8 @@ import { Section } from "./Section";
|
|
|
4
4
|
export class InlineKeyboard {
|
|
5
5
|
private keyboard: any[][] = [];
|
|
6
6
|
private footFixedButtons: any[][] = [];
|
|
7
|
+
private appendIndexes: number[] = [];
|
|
8
|
+
private prependIndexes: number[] = [];
|
|
7
9
|
|
|
8
10
|
static init(ctx: Telegraf2byteContext, section: Section): InlineKeyboard {
|
|
9
11
|
return new InlineKeyboard(ctx, section);
|
|
@@ -22,24 +24,30 @@ export class InlineKeyboard {
|
|
|
22
24
|
return this;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
append(row: any[] | any[][] | any): InlineKeyboard {
|
|
27
|
+
append(...row: any[] | any[][] | any): InlineKeyboard {
|
|
26
28
|
if (!Array.isArray(row)) {
|
|
27
29
|
this.keyboard.push([row]);
|
|
30
|
+
this.appendIndexes.push(this.keyboard.length - 1);
|
|
28
31
|
} else if (Array.isArray(row[0])) {
|
|
29
32
|
this.keyboard.push(...row);
|
|
33
|
+
this.appendIndexes.push(...Array.from({ length: row.length }, (_, i) => this.keyboard.length - row.length + i));
|
|
30
34
|
} else {
|
|
31
35
|
this.keyboard.push(row);
|
|
36
|
+
this.appendIndexes.push(this.keyboard.length - 1);
|
|
32
37
|
}
|
|
33
38
|
return this;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
prepend(row: any[]): InlineKeyboard {
|
|
41
|
+
prepend(...row: any[]): InlineKeyboard {
|
|
37
42
|
if (!Array.isArray(row)) {
|
|
38
43
|
this.keyboard.unshift([row]);
|
|
44
|
+
this.prependIndexes.push(0);
|
|
39
45
|
} else if (Array.isArray(row[0])) {
|
|
40
46
|
this.keyboard.unshift(...row);
|
|
47
|
+
this.prependIndexes.push(...Array.from({ length: row.length }, (_, i) => i));
|
|
41
48
|
} else {
|
|
42
49
|
this.keyboard.unshift(row);
|
|
50
|
+
this.prependIndexes.push(0);
|
|
43
51
|
}
|
|
44
52
|
return this;
|
|
45
53
|
}
|
|
@@ -58,4 +66,14 @@ export class InlineKeyboard {
|
|
|
58
66
|
[Symbol.toPrimitive]() {
|
|
59
67
|
return this.valueOf();
|
|
60
68
|
}
|
|
69
|
+
|
|
70
|
+
reset(): InlineKeyboard {
|
|
71
|
+
const appendsPrepends = [...this.appendIndexes, ...this.prependIndexes].sort((a, b) => a - b);
|
|
72
|
+
for (let i = appendsPrepends.length - 1; i >= 0; i--) {
|
|
73
|
+
this.keyboard.splice(appendsPrepends[i], 1);
|
|
74
|
+
}
|
|
75
|
+
this.appendIndexes = [];
|
|
76
|
+
this.prependIndexes = [];
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
61
79
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ES2022",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"types": ["bun-types"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["*.ts"],
|
|
16
|
+
"exclude": ["node_modules", "dist", "packed"]
|
|
17
|
+
}
|