@mtkruto/node 0.0.956 → 0.0.957

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.
@@ -59,6 +59,14 @@ export interface ClientParams {
59
59
  */
60
60
  systemVersion?: string;
61
61
  }
62
+ export interface ForwardMessagesParams {
63
+ messageThreadId?: number;
64
+ disableNotification?: boolean;
65
+ protectContent?: boolean;
66
+ sendAs?: number | string;
67
+ dropSenderName?: boolean;
68
+ dropCaption?: boolean;
69
+ }
62
70
  export declare class Client extends ClientAbstract {
63
71
  readonly storage: Storage;
64
72
  readonly apiId: number;
@@ -152,6 +160,7 @@ export declare class Client extends ClientAbstract {
152
160
  [getEntity](peer: types.PeerChat): Promise<types.Chat | null>;
153
161
  [getEntity](peer: types.PeerChannel): Promise<types.Channel | null>;
154
162
  processResult(result: ReadObject): Promise<void>;
163
+ private updatesToMessages;
155
164
  sendMessage(chatId: number | string, text: string, params?: {
156
165
  parseMode?: ParseMode;
157
166
  entities?: MessageEntity[];
@@ -162,10 +171,12 @@ export declare class Client extends ClientAbstract {
162
171
  messageThreadId?: number;
163
172
  sendAs?: number | string;
164
173
  replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
165
- }): Promise<Omit<Message, "replyToMessage">>;
174
+ }): Promise<Message>;
166
175
  getMessages(chatId: number | string, messageIds: number[]): Promise<Omit<Message, "replyToMessage">[]>;
167
176
  getMessage(chatId: number | string, messageId: number): Promise<Omit<Message, "replyToMessage"> | null>;
168
177
  private downloadInner;
169
178
  download(fileId_: string): Promise<AsyncGenerator<Uint8Array, void, unknown>>;
170
179
  [getStickerSetName](inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
180
+ forwardMessages(from: number | string, to: number | string, messageIds: number[], params?: ForwardMessagesParams): Promise<Message[]>;
181
+ forwardMessage(from: number | string, to: number | string, messageId: number, params?: ForwardMessagesParams): Promise<Message[]>;
171
182
  }
@@ -1041,6 +1041,26 @@ export class Client extends ClientAbstract {
1041
1041
  await this.processUsers(result.users);
1042
1042
  }
1043
1043
  }
1044
+ async updatesToMessages(chatId, updates) {
1045
+ const messages = new Array();
1046
+ if (updates instanceof types.Updates) {
1047
+ for (const update of updates.updates) {
1048
+ if (update instanceof types.UpdateNewMessage) {
1049
+ messages.push(await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
1050
+ }
1051
+ else if (update instanceof types.UpdateNewChannelMessage) {
1052
+ messages.push(await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
1053
+ }
1054
+ }
1055
+ }
1056
+ else if (updates instanceof types.UpdateShortSentMessage || updates instanceof types.UpdateShortSentMessage) {
1057
+ const message = await this.getMessage(chatId, updates.id);
1058
+ if (message != null) {
1059
+ messages.push(message);
1060
+ }
1061
+ }
1062
+ return messages;
1063
+ }
1044
1064
  async sendMessage(chatId, text, params) {
1045
1065
  const entities_ = params?.entities ?? [];
1046
1066
  const parseMode = params?.parseMode ?? this.parseMode;
@@ -1099,23 +1119,7 @@ export class Client extends ClientAbstract {
1099
1119
  entities,
1100
1120
  replyMarkup,
1101
1121
  }));
1102
- if (result instanceof types.Updates) {
1103
- for (const update of result.updates) {
1104
- if (update instanceof types.UpdateNewMessage) {
1105
- return constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
1106
- }
1107
- else if (update instanceof types.UpdateNewChannelMessage) {
1108
- return constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
1109
- }
1110
- }
1111
- }
1112
- else if (result instanceof types.UpdateShortSentMessage || result instanceof types.UpdateShortSentMessage) {
1113
- const message = await this.getMessage(chatId, result.id);
1114
- if (message != null) {
1115
- return message;
1116
- }
1117
- }
1118
- UNREACHABLE();
1122
+ return await this.updatesToMessages(chatId, result).then((v) => v[0]);
1119
1123
  }
1120
1124
  async getMessages(chatId, messageIds) {
1121
1125
  const peer = await this.getInputPeer(chatId);
@@ -1217,4 +1221,22 @@ export class Client extends ClientAbstract {
1217
1221
  return name;
1218
1222
  }
1219
1223
  }
1224
+ async forwardMessages(from, to, messageIds, params) {
1225
+ const result = await this.invoke(new functions.MessagesForwardMessages({
1226
+ fromPeer: await this.getInputPeer(from),
1227
+ toPeer: await this.getInputPeer(to),
1228
+ id: messageIds,
1229
+ randomId: messageIds.map(() => getRandomId()),
1230
+ silent: params?.disableNotification || undefined,
1231
+ topMsgId: params?.messageThreadId,
1232
+ noforwards: params?.disableNotification || undefined,
1233
+ sendAs: params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined,
1234
+ dropAuthor: params?.dropSenderName || undefined,
1235
+ dropMediaCaptions: params?.dropCaption || undefined,
1236
+ }));
1237
+ return await this.updatesToMessages(to, result);
1238
+ }
1239
+ forwardMessage(from, to, messageId, params) {
1240
+ return this.forwardMessages(from, to, [messageId], params);
1241
+ }
1220
1242
  }
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
4
4
  export declare const VECTOR_CONSTRUCTOR = 481674261;
5
5
  export declare const DEFAULT_INITIAL_DC: DC;
6
6
  export declare const LAYER = 158;
7
- export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.956";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.957";
8
8
  export declare const DEFAULT_DEVICE_MODEL: string;
9
9
  export declare const DEFAULT_LANG_CODE: string;
10
10
  export declare const DEFAULT_LANG_PACK = "";
package/esm/constants.js CHANGED
@@ -62,7 +62,7 @@ export const publicKeys = new Map([
62
62
  export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
63
63
  export const DEFAULT_INITIAL_DC = "2-test";
64
64
  export const LAYER = 158;
65
- export const DEFAULT_APP_VERSION = "MTKruto 0.0.956";
65
+ export const DEFAULT_APP_VERSION = "MTKruto 0.0.957";
66
66
  // @ts-ignore: lib
67
67
  export const DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
68
68
  export const DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.956",
5
+ "version": "0.0.957",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -59,6 +59,14 @@ export interface ClientParams {
59
59
  */
60
60
  systemVersion?: string;
61
61
  }
62
+ export interface ForwardMessagesParams {
63
+ messageThreadId?: number;
64
+ disableNotification?: boolean;
65
+ protectContent?: boolean;
66
+ sendAs?: number | string;
67
+ dropSenderName?: boolean;
68
+ dropCaption?: boolean;
69
+ }
62
70
  export declare class Client extends ClientAbstract {
63
71
  readonly storage: Storage;
64
72
  readonly apiId: number;
@@ -152,6 +160,7 @@ export declare class Client extends ClientAbstract {
152
160
  [getEntity](peer: types.PeerChat): Promise<types.Chat | null>;
153
161
  [getEntity](peer: types.PeerChannel): Promise<types.Channel | null>;
154
162
  processResult(result: ReadObject): Promise<void>;
163
+ private updatesToMessages;
155
164
  sendMessage(chatId: number | string, text: string, params?: {
156
165
  parseMode?: ParseMode;
157
166
  entities?: MessageEntity[];
@@ -162,10 +171,12 @@ export declare class Client extends ClientAbstract {
162
171
  messageThreadId?: number;
163
172
  sendAs?: number | string;
164
173
  replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
165
- }): Promise<Omit<Message, "replyToMessage">>;
174
+ }): Promise<Message>;
166
175
  getMessages(chatId: number | string, messageIds: number[]): Promise<Omit<Message, "replyToMessage">[]>;
167
176
  getMessage(chatId: number | string, messageId: number): Promise<Omit<Message, "replyToMessage"> | null>;
168
177
  private downloadInner;
169
178
  download(fileId_: string): Promise<AsyncGenerator<Uint8Array, void, unknown>>;
170
179
  [getStickerSetName](inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
180
+ forwardMessages(from: number | string, to: number | string, messageIds: number[], params?: ForwardMessagesParams): Promise<Message[]>;
181
+ forwardMessage(from: number | string, to: number | string, messageId: number, params?: ForwardMessagesParams): Promise<Message[]>;
171
182
  }
@@ -1067,6 +1067,26 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1067
1067
  await this.processUsers(result.users);
1068
1068
  }
1069
1069
  }
1070
+ async updatesToMessages(chatId, updates) {
1071
+ const messages = new Array();
1072
+ if (updates instanceof types.Updates) {
1073
+ for (const update of updates.updates) {
1074
+ if (update instanceof types.UpdateNewMessage) {
1075
+ messages.push(await (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1076
+ }
1077
+ else if (update instanceof types.UpdateNewChannelMessage) {
1078
+ messages.push(await (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1079
+ }
1080
+ }
1081
+ }
1082
+ else if (updates instanceof types.UpdateShortSentMessage || updates instanceof types.UpdateShortSentMessage) {
1083
+ const message = await this.getMessage(chatId, updates.id);
1084
+ if (message != null) {
1085
+ messages.push(message);
1086
+ }
1087
+ }
1088
+ return messages;
1089
+ }
1070
1090
  async sendMessage(chatId, text, params) {
1071
1091
  const entities_ = params?.entities ?? [];
1072
1092
  const parseMode = params?.parseMode ?? this.parseMode;
@@ -1125,23 +1145,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1125
1145
  entities,
1126
1146
  replyMarkup,
1127
1147
  }));
1128
- if (result instanceof types.Updates) {
1129
- for (const update of result.updates) {
1130
- if (update instanceof types.UpdateNewMessage) {
1131
- return (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1132
- }
1133
- else if (update instanceof types.UpdateNewChannelMessage) {
1134
- return (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1135
- }
1136
- }
1137
- }
1138
- else if (result instanceof types.UpdateShortSentMessage || result instanceof types.UpdateShortSentMessage) {
1139
- const message = await this.getMessage(chatId, result.id);
1140
- if (message != null) {
1141
- return message;
1142
- }
1143
- }
1144
- (0, _0_control_js_1.UNREACHABLE)();
1148
+ return await this.updatesToMessages(chatId, result).then((v) => v[0]);
1145
1149
  }
1146
1150
  async getMessages(chatId, messageIds) {
1147
1151
  const peer = await this.getInputPeer(chatId);
@@ -1243,5 +1247,23 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1243
1247
  return name;
1244
1248
  }
1245
1249
  }
1250
+ async forwardMessages(from, to, messageIds, params) {
1251
+ const result = await this.invoke(new functions.MessagesForwardMessages({
1252
+ fromPeer: await this.getInputPeer(from),
1253
+ toPeer: await this.getInputPeer(to),
1254
+ id: messageIds,
1255
+ randomId: messageIds.map(() => (0, _0_bigint_js_1.getRandomId)()),
1256
+ silent: params?.disableNotification || undefined,
1257
+ topMsgId: params?.messageThreadId,
1258
+ noforwards: params?.disableNotification || undefined,
1259
+ sendAs: params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined,
1260
+ dropAuthor: params?.dropSenderName || undefined,
1261
+ dropMediaCaptions: params?.dropCaption || undefined,
1262
+ }));
1263
+ return await this.updatesToMessages(to, result);
1264
+ }
1265
+ forwardMessage(from, to, messageId, params) {
1266
+ return this.forwardMessages(from, to, [messageId], params);
1267
+ }
1246
1268
  }
1247
1269
  exports.Client = Client;
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
4
4
  export declare const VECTOR_CONSTRUCTOR = 481674261;
5
5
  export declare const DEFAULT_INITIAL_DC: DC;
6
6
  export declare const LAYER = 158;
7
- export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.956";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.957";
8
8
  export declare const DEFAULT_DEVICE_MODEL: string;
9
9
  export declare const DEFAULT_LANG_CODE: string;
10
10
  export declare const DEFAULT_LANG_PACK = "";
@@ -88,7 +88,7 @@ exports.publicKeys = new Map([
88
88
  exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
89
89
  exports.DEFAULT_INITIAL_DC = "2-test";
90
90
  exports.LAYER = 158;
91
- exports.DEFAULT_APP_VERSION = "MTKruto 0.0.956";
91
+ exports.DEFAULT_APP_VERSION = "MTKruto 0.0.957";
92
92
  // @ts-ignore: lib
93
93
  exports.DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
94
94
  exports.DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];