1
0
Painor 1 жил өмнө
parent
commit
13616b191b

+ 11 - 3
gramjs/client/messages.ts

@@ -744,6 +744,14 @@ export async function sendMessage(
         replyTo = discussionData.replyTo;
     }
     let markup, request;
+    let replyObject = undefined;
+    if (replyTo != undefined) {
+        replyObject = new Api.InputReplyToMessage({
+            replyToMsgId: getMessageId(replyTo)!,
+            topMsgId: getMessageId(topMsgId),
+        });
+    }
+
     if (message && message instanceof Api.Message) {
         if (buttons == undefined) {
             markup = message.replyMarkup;
@@ -753,6 +761,7 @@ export async function sendMessage(
         if (silent == undefined) {
             silent = message.silent;
         }
+
         if (
             message.media &&
             !(message.media instanceof Api.MessageMediaWebPage)
@@ -771,8 +780,7 @@ export async function sendMessage(
             peer: entity,
             message: message.message || "",
             silent: silent,
-            replyToMsgId: getMessageId(replyTo),
-            topMsgId: getMessageId(topMsgId),
+            replyTo: replyObject,
             replyMarkup: markup,
             entities: message.entities,
             clearDraft: clearDraft,
@@ -800,7 +808,7 @@ export async function sendMessage(
             message: message.toString(),
             entities: formattingEntities,
             noWebpage: !linkPreview,
-            replyToMsgId: getMessageId(replyTo),
+            replyTo: replyObject,
             clearDraft: clearDraft,
             silent: silent,
             replyMarkup: client.buildReplyMarkup(buttons),

+ 19 - 5
gramjs/client/uploads.ts

@@ -2,7 +2,7 @@ import { Api } from "../tl";
 
 import { TelegramClient } from "./TelegramClient";
 import { generateRandomBytes, readBigIntFromBuffer, sleep } from "../Helpers";
-import { getAppropriatedPartSize, getInputMedia } from "../Utils";
+import { getAppropriatedPartSize, getInputMedia, getMessageId } from "../Utils";
 import { EntityLike, FileLike, MarkupLike, MessageIDLike } from "../define";
 import path from "./path";
 import { promises as fs } from "./fs";
@@ -596,11 +596,18 @@ export async function _sendAlbum(
             })
         );
     }
+    let replyObject = undefined;
+    if (replyTo != undefined) {
+        replyObject = new Api.InputReplyToMessage({
+            replyToMsgId: getMessageId(replyTo)!,
+            topMsgId: getMessageId(topMsgId),
+        });
+    }
+
     const result = await client.invoke(
         new Api.messages.SendMultiMedia({
             peer: entity,
-            replyToMsgId: replyTo,
-            topMsgId: utils.getMessageId(topMsgId),
+            replyTo: replyObject,
             multiMedia: albumFiles,
             silent: silent,
             scheduleDate: scheduleDate,
@@ -699,11 +706,18 @@ export async function sendFile(
         throw new Error(`Cannot use ${file} as file.`);
     }
     const markup = client.buildReplyMarkup(buttons);
+    let replyObject = undefined;
+    if (replyTo != undefined) {
+        replyObject = new Api.InputReplyToMessage({
+            replyToMsgId: getMessageId(replyTo)!,
+            topMsgId: getMessageId(topMsgId),
+        });
+    }
+
     const request = new Api.messages.SendMedia({
         peer: entity,
         media: media,
-        replyToMsgId: replyTo,
-        topMsgId: utils.getMessageId(topMsgId),
+        replyTo: replyObject,
         message: caption,
         entities: msgEntities,
         replyMarkup: markup,

+ 9 - 2
gramjs/tl/custom/inlineResult.ts

@@ -4,6 +4,7 @@ import { Api } from "../api";
 import { utils } from "../../";
 import { betterConsoleLog } from "../../Helpers";
 import { inspect } from "../../inspect";
+import { getMessageId } from "../../Utils";
 
 export class InlineResult {
     private _ARTICLE = "article";
@@ -88,7 +89,13 @@ export class InlineResult {
                 "You must provide the entity where the result should be sent to"
             );
         }
-        const replyId = replyTo ? utils.getMessageId(replyTo) : undefined;
+        let replyObject = undefined;
+        if (replyTo != undefined) {
+            replyObject = new Api.InputReplyToMessage({
+                replyToMsgId: getMessageId(replyTo)!,
+            });
+        }
+
         const request = new Api.messages.SendInlineBotResult({
             peer: entity,
             queryId: this._queryId,
@@ -96,7 +103,7 @@ export class InlineResult {
             silent: silent,
             clearDraft: clearDraft,
             hideVia: hideVia,
-            replyToMsgId: replyId,
+            replyTo: replyObject,
         });
         return await this._client.invoke(request);
     }