@imessaging/telegram-mtproto 0.8.9 → 0.8.10
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
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
EditResult,
|
|
22
22
|
MessageReaction,
|
|
23
23
|
MessageRecipient,
|
|
24
|
+
OutboundButton,
|
|
24
25
|
OutboundMessage,
|
|
25
26
|
ReactionTransport,
|
|
26
27
|
ResolvedPeer,
|
|
@@ -36,6 +37,7 @@ import { peerToChat, unmarkPeerId } from "./incoming";
|
|
|
36
37
|
import bigInt from "big-integer";
|
|
37
38
|
import { Api, TelegramClient } from "telegram";
|
|
38
39
|
import { CustomFile } from "telegram/client/uploads";
|
|
40
|
+
import { Button } from "telegram/tl/custom/button";
|
|
39
41
|
import { CallbackQuery } from "telegram/events/CallbackQuery";
|
|
40
42
|
import { NewMessage } from "telegram/events/NewMessage";
|
|
41
43
|
import { EditedMessage } from "telegram/events/EditedMessage";
|
|
@@ -112,6 +114,17 @@ function inputPeerChatId(peer: Api.TypeInputPeer): string {
|
|
|
112
114
|
throw new Error(`Unsupported input peer: ${peer.className}`);
|
|
113
115
|
}
|
|
114
116
|
|
|
117
|
+
function toGramJsButtons(buttons?: OutboundButton[][]) {
|
|
118
|
+
if (!buttons || buttons.length === 0) return undefined;
|
|
119
|
+
return buttons.map((row) =>
|
|
120
|
+
row.map((button) => {
|
|
121
|
+
if (button.url) return Button.url(button.text, button.url);
|
|
122
|
+
if (button.callbackData) return Button.inline(button.text, Buffer.from(button.callbackData));
|
|
123
|
+
return Button.text(button.text);
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
115
128
|
export class TelegramMtprotoTransport
|
|
116
129
|
implements
|
|
117
130
|
ContactTransport,
|
|
@@ -856,6 +869,7 @@ export class TelegramMtprotoTransport
|
|
|
856
869
|
parseMode,
|
|
857
870
|
formattingEntities,
|
|
858
871
|
replyTo: message.replyToMessageId ?? message.threadId,
|
|
872
|
+
buttons: toGramJsButtons(message.buttons),
|
|
859
873
|
});
|
|
860
874
|
this.rememberOwn(this.ownSent, peer, sent.id);
|
|
861
875
|
for (const document of message.documents ?? []) {
|
|
@@ -1022,13 +1036,12 @@ export class TelegramMtprotoTransport
|
|
|
1022
1036
|
const text = ft ? ft.text : message.text;
|
|
1023
1037
|
const parseMode = ft ? undefined : message.parseMode?.toLowerCase();
|
|
1024
1038
|
const formattingEntities = ft ? toTelegramEntities(ft) : undefined;
|
|
1025
|
-
// Кнопки здесь не передаются — ровно как и при отправке этим транспортом: inline-клавиатуру
|
|
1026
|
-
// MTProto-аккаунт не рисует. Передать их сюда значило бы обещать разметку, которой не будет.
|
|
1027
1039
|
await this.client.editMessage(peer, {
|
|
1028
1040
|
message: messageId,
|
|
1029
1041
|
text,
|
|
1030
1042
|
parseMode,
|
|
1031
1043
|
formattingEntities,
|
|
1044
|
+
buttons: toGramJsButtons(message.buttons),
|
|
1032
1045
|
});
|
|
1033
1046
|
this.lastActivityAt = new Date();
|
|
1034
1047
|
return {
|