@2byte/tgbot-framework 1.0.10 → 1.0.11
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
package/src/core/App.ts
CHANGED
|
@@ -377,7 +377,7 @@ export class App {
|
|
|
377
377
|
const sectionRoute = new RunSectionRoute()
|
|
378
378
|
.section(sectionId)
|
|
379
379
|
.method(method)
|
|
380
|
-
.actionPath(
|
|
380
|
+
.callbackParams(actionPath, actionParams.toString());
|
|
381
381
|
|
|
382
382
|
this.runSection(ctx, sectionRoute).catch((err) => {
|
|
383
383
|
this.debugLog("Error running section:", err);
|
|
@@ -575,6 +575,7 @@ export class App {
|
|
|
575
575
|
|
|
576
576
|
// Если указан runSection, выполняем его
|
|
577
577
|
if (runSection) {
|
|
578
|
+
runSection.runAsCommand();
|
|
578
579
|
await this.runSection(ctx, runSection);
|
|
579
580
|
}
|
|
580
581
|
} else {
|
|
@@ -825,11 +826,11 @@ export class App {
|
|
|
825
826
|
runnedSection = findRunnedSection();
|
|
826
827
|
if (runnedSection) {
|
|
827
828
|
runnedSection.instance
|
|
828
|
-
.updateCtx(ctx)
|
|
829
|
+
.updateCtx(ctx)
|
|
830
|
+
.updateRoute(sectionRoute)
|
|
831
|
+
.setCallbackParams(sectionRoute.getCallbackParams());
|
|
829
832
|
|
|
830
|
-
|
|
831
|
-
runnedSection.route.runAsCallbackQuery();
|
|
832
|
-
}
|
|
833
|
+
runnedSection.route.runAsCallbackQuery(sectionRoute.runIsCallbackQuery);
|
|
833
834
|
|
|
834
835
|
isRestoredSection = true;
|
|
835
836
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Telegraf2byteContext } from "./Telegraf2byteContext";
|
|
2
2
|
import { Input, Markup } from "telegraf";
|
|
3
|
-
import type { ReplyKeyboardMarkup } from
|
|
3
|
+
import type { ReplyKeyboardMarkup } from "telegraf/core/types/telegram";
|
|
4
4
|
import { InlineKeyboard } from "./InlineKeyboard";
|
|
5
5
|
import { RequestInputOptions } from "../types";
|
|
6
6
|
import { Message } from "telegraf/types";
|
|
@@ -198,21 +198,20 @@ export default class Message2byte {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
const message = this.ctx.callbackQuery?.message as Message;
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
if (message) {
|
|
203
|
-
if (
|
|
203
|
+
if ("media_group_id" in message || "caption" in message) {
|
|
204
204
|
const editMessageCaption = this.editMessageCaption(this.messageValue, this.messageExtra);
|
|
205
205
|
|
|
206
|
-
if (editMessageCaption &&
|
|
206
|
+
if (editMessageCaption && "message_id" in editMessageCaption) {
|
|
207
207
|
this.messageId = editMessageCaption.message_id as number;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
return editMessageCaption;
|
|
211
211
|
} else {
|
|
212
|
-
|
|
213
212
|
const editedText = this.editMessageText(this.messageValue, this.messageExtra);
|
|
214
213
|
|
|
215
|
-
if (editedText &&
|
|
214
|
+
if (editedText && "message_id" in editedText) {
|
|
216
215
|
// this.messageId = editedText.message_id as number;
|
|
217
216
|
}
|
|
218
217
|
|
|
@@ -221,13 +220,15 @@ export default class Message2byte {
|
|
|
221
220
|
} else {
|
|
222
221
|
// this.messageExtra.message_id = this.messageId;
|
|
223
222
|
|
|
224
|
-
|
|
223
|
+
try {
|
|
224
|
+
const messageEntity = await this.editMessageText(this.messageValue, this.messageExtra);
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
if (typeof messageEntity === "object" && "message_id" in messageEntity) {
|
|
227
|
+
this.messageId = messageEntity.message_id as number;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return messageEntity;
|
|
231
|
+
} catch (e) {}
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -6,7 +6,7 @@ export class RunSectionRoute {
|
|
|
6
6
|
method: null,
|
|
7
7
|
methodArgs: null,
|
|
8
8
|
callbackParams: new URLSearchParams(),
|
|
9
|
-
|
|
9
|
+
runAsCallbackQuery: false,
|
|
10
10
|
actionPath: null,
|
|
11
11
|
hearsKey: null,
|
|
12
12
|
};
|
|
@@ -20,7 +20,7 @@ export class RunSectionRoute {
|
|
|
20
20
|
|
|
21
21
|
method(name: string = 'index', isRunCallbackQuery: boolean = false): this {
|
|
22
22
|
this.runParams.method = name;
|
|
23
|
-
this.runParams.
|
|
23
|
+
this.runParams.runAsCallbackQuery = isRunCallbackQuery;
|
|
24
24
|
return this;
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -32,13 +32,13 @@ export class RunSectionRoute {
|
|
|
32
32
|
callbackParams(actionPath: string, params: string | Record<string, string>): this {
|
|
33
33
|
this.runParams.callbackParams = new URLSearchParams(params);
|
|
34
34
|
this.actionPath(actionPath);
|
|
35
|
-
this.runParams.
|
|
35
|
+
this.runParams.runAsCallbackQuery = true;
|
|
36
36
|
return this;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
actionPath(path: string): this {
|
|
40
40
|
this.runParams.actionPath = path;
|
|
41
|
-
this.runParams.
|
|
41
|
+
this.runParams.runAsCallbackQuery = true;
|
|
42
42
|
return this;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -47,13 +47,13 @@ export class RunSectionRoute {
|
|
|
47
47
|
return this;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
runAsCommand(): this {
|
|
51
|
-
this.runParams.
|
|
50
|
+
runAsCommand(flag: boolean = true): this {
|
|
51
|
+
this.runParams.runAsCallbackQuery = !flag;
|
|
52
52
|
return this;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
runAsCallbackQuery(): this {
|
|
56
|
-
this.runParams.
|
|
55
|
+
runAsCallbackQuery(flag: boolean = true): this {
|
|
56
|
+
this.runParams.runAsCallbackQuery = flag;
|
|
57
57
|
return this;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -90,6 +90,6 @@ export class RunSectionRoute {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
get runIsCallbackQuery(): boolean {
|
|
93
|
-
return this.runParams.
|
|
93
|
+
return this.runParams.runAsCallbackQuery;
|
|
94
94
|
}
|
|
95
95
|
}
|
package/src/types.ts
CHANGED
|
@@ -133,7 +133,7 @@ export interface RunSectionRouteParams {
|
|
|
133
133
|
method: string | null;
|
|
134
134
|
methodArgs: any[] | null;
|
|
135
135
|
callbackParams: URLSearchParams;
|
|
136
|
-
|
|
136
|
+
runAsCallbackQuery: boolean;
|
|
137
137
|
actionPath: string | null;
|
|
138
138
|
hearsKey: string | null;
|
|
139
139
|
}
|