Browse Source

Add top msg id param when sending messages

Painor 2 năm trước cách đây
mục cha
commit
f03d5521e9
5 tập tin đã thay đổi với 20 bổ sung5 xóa
  1. 1 1
      gramjs/Version.ts
  2. 7 0
      gramjs/client/messages.ts
  3. 8 0
      gramjs/client/uploads.ts
  4. 2 2
      package-lock.json
  5. 2 2
      package.json

+ 1 - 1
gramjs/Version.ts

@@ -1 +1 @@
-export const version = "2.15.8";
+export const version = "2.16.0";

+ 7 - 0
gramjs/client/messages.ts

@@ -519,6 +519,10 @@ export interface SendMessageParams {
      If there is no linked chat, `SG_ID_INVALID` is thrown.
      */
     commentTo?: number | Api.Message;
+    /**
+     * Used for threads to reply to a specific thread
+     */
+    topMsgId?: number | Api.Message;
 }
 
 /** interface used for forwarding messages */
@@ -706,6 +710,7 @@ export async function sendMessage(
         schedule,
         noforwards,
         commentTo,
+        topMsgId,
     }: SendMessageParams = {}
 ) {
     if (file) {
@@ -729,6 +734,7 @@ export async function sendMessage(
             buttons: buttons,
             noforwards: noforwards,
             commentTo: commentTo,
+            topMsgId: topMsgId,
         });
     }
     entity = await client.getInputEntity(entity);
@@ -766,6 +772,7 @@ export async function sendMessage(
             message: message.message || "",
             silent: silent,
             replyToMsgId: getMessageId(replyTo),
+            topMsgId: getMessageId(topMsgId),
             replyMarkup: markup,
             entities: message.entities,
             clearDraft: clearDraft,

+ 8 - 0
gramjs/client/uploads.ts

@@ -288,6 +288,10 @@ export interface SendFileInterface {
      If there is no linked chat, `SG_ID_INVALID` is thrown.
      */
     commentTo?: number | Api.Message;
+    /**
+     * Used for threads to reply to a specific thread
+     */
+    topMsgId?: number | Api.Message;
 }
 
 interface FileToMediaInterface {
@@ -514,6 +518,7 @@ export async function _sendAlbum(
         workers = 1,
         noforwards,
         commentTo,
+        topMsgId,
     }: SendFileInterface
 ) {
     entity = await client.getInputEntity(entity);
@@ -595,6 +600,7 @@ export async function _sendAlbum(
         new Api.messages.SendMultiMedia({
             peer: entity,
             replyToMsgId: replyTo,
+            topMsgId: utils.getMessageId(topMsgId),
             multiMedia: albumFiles,
             silent: silent,
             scheduleDate: scheduleDate,
@@ -631,6 +637,7 @@ export async function sendFile(
         workers = 1,
         noforwards,
         commentTo,
+        topMsgId,
     }: SendFileInterface
 ) {
     if (!file) {
@@ -695,6 +702,7 @@ export async function sendFile(
         peer: entity,
         media: media,
         replyToMsgId: replyTo,
+        topMsgId: utils.getMessageId(topMsgId),
         message: caption,
         entities: msgEntities,
         replyMarkup: markup,

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "telegram",
-  "version": "2.15.11",
+  "version": "2.16.0",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "telegram",
-      "version": "2.15.11",
+      "version": "2.16.0",
       "license": "MIT",
       "dependencies": {
         "@cryptography/aes": "^0.1.1",

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "telegram",
-  "version": "2.15.11",
+  "version": "2.16.0",
   "description": "NodeJS/Browser MTProto API Telegram client library,",
   "main": "index.js",
   "types": "index.d.ts",
@@ -68,4 +68,4 @@
     "node-localstorage": "^2.2.1",
     "socks": "^2.6.2"
   }
-}
+}