teleproto 1.214.0

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.
Files changed (222) hide show
  1. package/CryptoFile.d.ts +2 -0
  2. package/CryptoFile.js +37 -0
  3. package/Helpers.d.ts +150 -0
  4. package/Helpers.js +477 -0
  5. package/LICENSE +23 -0
  6. package/Password.d.ts +14 -0
  7. package/Password.js +270 -0
  8. package/README.md +98 -0
  9. package/Utils.d.ts +227 -0
  10. package/Utils.js +1247 -0
  11. package/Version.d.ts +1 -0
  12. package/Version.js +4 -0
  13. package/client/2fa.d.ts +48 -0
  14. package/client/2fa.js +108 -0
  15. package/client/TelegramClient.d.ts +1043 -0
  16. package/client/TelegramClient.js +1181 -0
  17. package/client/account.d.ts +0 -0
  18. package/client/account.js +1 -0
  19. package/client/auth.d.ts +92 -0
  20. package/client/auth.js +388 -0
  21. package/client/bots.d.ts +6 -0
  22. package/client/bots.js +23 -0
  23. package/client/buttons.d.ts +4 -0
  24. package/client/buttons.js +86 -0
  25. package/client/chats.d.ts +45 -0
  26. package/client/chats.js +350 -0
  27. package/client/dialogs.d.ts +52 -0
  28. package/client/dialogs.js +174 -0
  29. package/client/downloads.d.ts +156 -0
  30. package/client/downloads.js +614 -0
  31. package/client/fs.d.ts +1 -0
  32. package/client/fs.js +17 -0
  33. package/client/index.d.ts +15 -0
  34. package/client/index.js +64 -0
  35. package/client/messageParse.d.ts +17 -0
  36. package/client/messageParse.js +191 -0
  37. package/client/messages.d.ts +263 -0
  38. package/client/messages.js +813 -0
  39. package/client/os.d.ts +2 -0
  40. package/client/os.js +37 -0
  41. package/client/path.d.ts +2 -0
  42. package/client/path.js +7 -0
  43. package/client/telegramBaseClient.d.ts +237 -0
  44. package/client/telegramBaseClient.js +368 -0
  45. package/client/updates.d.ts +33 -0
  46. package/client/updates.js +260 -0
  47. package/client/uploads.d.ts +136 -0
  48. package/client/uploads.js +514 -0
  49. package/client/users.d.ts +29 -0
  50. package/client/users.js +490 -0
  51. package/crypto/AuthKey.d.ts +19 -0
  52. package/crypto/AuthKey.js +76 -0
  53. package/crypto/CTR.d.ts +5 -0
  54. package/crypto/CTR.js +16 -0
  55. package/crypto/Factorizator.d.ts +19 -0
  56. package/crypto/Factorizator.js +74 -0
  57. package/crypto/IGE.d.ts +11 -0
  58. package/crypto/IGE.js +115 -0
  59. package/crypto/RSA.d.ts +14 -0
  60. package/crypto/RSA.js +70 -0
  61. package/crypto/converters.d.ts +19 -0
  62. package/crypto/converters.js +52 -0
  63. package/crypto/crypto.d.ts +19 -0
  64. package/crypto/crypto.js +58 -0
  65. package/crypto/words.d.ts +6 -0
  66. package/crypto/words.js +47 -0
  67. package/define.d.ts +77 -0
  68. package/entityCache.d.ts +7 -0
  69. package/entityCache.js +79 -0
  70. package/errors/Common.d.ts +71 -0
  71. package/errors/Common.js +122 -0
  72. package/errors/RPCBaseErrors.d.ts +84 -0
  73. package/errors/RPCBaseErrors.js +134 -0
  74. package/errors/RPCErrorList.d.ts +37 -0
  75. package/errors/RPCErrorList.js +117 -0
  76. package/errors/index.d.ts +11 -0
  77. package/errors/index.js +32 -0
  78. package/events/Album.d.ts +36 -0
  79. package/events/Album.js +104 -0
  80. package/events/CallbackQuery.d.ts +73 -0
  81. package/events/CallbackQuery.js +193 -0
  82. package/events/DeletedMessage.d.ts +45 -0
  83. package/events/DeletedMessage.js +63 -0
  84. package/events/EditedMessage.d.ts +30 -0
  85. package/events/EditedMessage.js +41 -0
  86. package/events/NewMessage.d.ts +89 -0
  87. package/events/NewMessage.js +182 -0
  88. package/events/Raw.d.ts +29 -0
  89. package/events/Raw.js +43 -0
  90. package/events/common.d.ts +66 -0
  91. package/events/common.js +141 -0
  92. package/events/index.d.ts +2 -0
  93. package/events/index.js +8 -0
  94. package/extensions/AsyncQueue.d.ts +10 -0
  95. package/extensions/AsyncQueue.js +32 -0
  96. package/extensions/BinaryReader.d.ts +99 -0
  97. package/extensions/BinaryReader.js +242 -0
  98. package/extensions/BinaryWriter.d.ts +6 -0
  99. package/extensions/BinaryWriter.js +15 -0
  100. package/extensions/Deferred.d.ts +8 -0
  101. package/extensions/Deferred.js +16 -0
  102. package/extensions/Logger.d.ts +54 -0
  103. package/extensions/Logger.js +128 -0
  104. package/extensions/MessagePacker.d.ts +21 -0
  105. package/extensions/MessagePacker.js +154 -0
  106. package/extensions/PendingState.d.ts +12 -0
  107. package/extensions/PendingState.js +29 -0
  108. package/extensions/PromisedNetSockets.d.ts +24 -0
  109. package/extensions/PromisedNetSockets.js +192 -0
  110. package/extensions/PromisedWebSockets.d.ts +18 -0
  111. package/extensions/PromisedWebSockets.js +124 -0
  112. package/extensions/html.d.ts +5 -0
  113. package/extensions/html.js +228 -0
  114. package/extensions/index.d.ts +7 -0
  115. package/extensions/index.js +17 -0
  116. package/extensions/markdown.d.ts +5 -0
  117. package/extensions/markdown.js +76 -0
  118. package/extensions/markdownv2.d.ts +5 -0
  119. package/extensions/markdownv2.js +51 -0
  120. package/extensions/net.d.ts +1 -0
  121. package/extensions/net.js +17 -0
  122. package/extensions/socks.d.ts +1 -0
  123. package/extensions/socks.js +17 -0
  124. package/index.d.ts +14 -0
  125. package/index.js +62 -0
  126. package/inspect.d.ts +1 -0
  127. package/inspect.js +5 -0
  128. package/network/Authenticator.d.ts +12 -0
  129. package/network/Authenticator.js +192 -0
  130. package/network/MTProtoPlainSender.d.ts +19 -0
  131. package/network/MTProtoPlainSender.js +74 -0
  132. package/network/MTProtoSender.d.ts +290 -0
  133. package/network/MTProtoSender.js +873 -0
  134. package/network/MTProtoState.d.ts +102 -0
  135. package/network/MTProtoState.js +267 -0
  136. package/network/RequestState.d.ts +18 -0
  137. package/network/RequestState.js +35 -0
  138. package/network/connection/Connection.d.ts +69 -0
  139. package/network/connection/Connection.js +162 -0
  140. package/network/connection/TCPAbridged.d.ts +19 -0
  141. package/network/connection/TCPAbridged.js +58 -0
  142. package/network/connection/TCPFull.d.ts +16 -0
  143. package/network/connection/TCPFull.js +61 -0
  144. package/network/connection/TCPMTProxy.d.ts +49 -0
  145. package/network/connection/TCPMTProxy.js +121 -0
  146. package/network/connection/TCPObfuscated.d.ts +18 -0
  147. package/network/connection/TCPObfuscated.js +78 -0
  148. package/network/connection/index.d.ts +4 -0
  149. package/network/connection/index.js +11 -0
  150. package/network/index.d.ts +11 -0
  151. package/network/index.js +23 -0
  152. package/package.json +50 -0
  153. package/requestIter.d.ts +24 -0
  154. package/requestIter.js +109 -0
  155. package/sessions/Abstract.d.ts +103 -0
  156. package/sessions/Abstract.js +6 -0
  157. package/sessions/Memory.d.ts +38 -0
  158. package/sessions/Memory.js +272 -0
  159. package/sessions/StoreSession.d.ts +14 -0
  160. package/sessions/StoreSession.js +77 -0
  161. package/sessions/StringSession.d.ts +32 -0
  162. package/sessions/StringSession.js +116 -0
  163. package/sessions/index.d.ts +4 -0
  164. package/sessions/index.js +11 -0
  165. package/sessions/localStorage.d.ts +1 -0
  166. package/sessions/localStorage.js +4 -0
  167. package/tl/AllTLObjects.d.ts +3 -0
  168. package/tl/AllTLObjects.js +17 -0
  169. package/tl/MTProtoRequest.d.ts +18 -0
  170. package/tl/MTProtoRequest.js +38 -0
  171. package/tl/api.d.ts +32488 -0
  172. package/tl/api.js +507 -0
  173. package/tl/apiTl.d.ts +2 -0
  174. package/tl/apiTl.js +2209 -0
  175. package/tl/core/GZIPPacked.d.ts +15 -0
  176. package/tl/core/GZIPPacked.js +51 -0
  177. package/tl/core/MessageContainer.d.ts +12 -0
  178. package/tl/core/MessageContainer.js +42 -0
  179. package/tl/core/RPCResult.d.ts +14 -0
  180. package/tl/core/RPCResult.js +32 -0
  181. package/tl/core/TLMessage.d.ts +10 -0
  182. package/tl/core/TLMessage.js +14 -0
  183. package/tl/core/index.d.ts +6 -0
  184. package/tl/core/index.js +16 -0
  185. package/tl/custom/button.d.ts +24 -0
  186. package/tl/custom/button.js +78 -0
  187. package/tl/custom/chatGetter.d.ts +29 -0
  188. package/tl/custom/chatGetter.js +116 -0
  189. package/tl/custom/dialog.d.ts +30 -0
  190. package/tl/custom/dialog.js +40 -0
  191. package/tl/custom/draft.d.ts +21 -0
  192. package/tl/custom/draft.js +48 -0
  193. package/tl/custom/file.d.ts +21 -0
  194. package/tl/custom/file.js +68 -0
  195. package/tl/custom/forward.d.ts +15 -0
  196. package/tl/custom/forward.js +47 -0
  197. package/tl/custom/index.d.ts +1 -0
  198. package/tl/custom/index.js +5 -0
  199. package/tl/custom/inlineResult.d.ts +32 -0
  200. package/tl/custom/inlineResult.js +87 -0
  201. package/tl/custom/inlineResults.d.ts +20 -0
  202. package/tl/custom/inlineResults.js +26 -0
  203. package/tl/custom/message.d.ts +427 -0
  204. package/tl/custom/message.js +716 -0
  205. package/tl/custom/messageButton.d.ts +54 -0
  206. package/tl/custom/messageButton.js +152 -0
  207. package/tl/custom/senderGetter.d.ts +28 -0
  208. package/tl/custom/senderGetter.js +55 -0
  209. package/tl/generateModule.d.ts +1 -0
  210. package/tl/generateModule.js +17 -0
  211. package/tl/generationHelpers.d.ts +11 -0
  212. package/tl/generationHelpers.js +289 -0
  213. package/tl/index.d.ts +3 -0
  214. package/tl/index.js +10 -0
  215. package/tl/patched/index.d.ts +2 -0
  216. package/tl/patched/index.js +76 -0
  217. package/tl/schemaTl.d.ts +2 -0
  218. package/tl/schemaTl.js +64 -0
  219. package/tl/types-generator/generate.d.ts +1 -0
  220. package/tl/types-generator/generate.js +84 -0
  221. package/tl/types-generator/template.d.ts +6 -0
  222. package/tl/types-generator/template.js +257 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.users = exports.uploads = exports.updates = exports.tgClient = exports.telegramBaseClient = exports.message = exports.messageParse = exports.downloads = exports.dialogs = exports.chats = exports.buttons = exports.bots = exports.auth = exports.twoFA = void 0;
37
+ const twoFA = __importStar(require("./2fa"));
38
+ exports.twoFA = twoFA;
39
+ const auth = __importStar(require("./auth"));
40
+ exports.auth = auth;
41
+ const bots = __importStar(require("./bots"));
42
+ exports.bots = bots;
43
+ const buttons = __importStar(require("./buttons"));
44
+ exports.buttons = buttons;
45
+ const chats = __importStar(require("./chats"));
46
+ exports.chats = chats;
47
+ const dialogs = __importStar(require("./dialogs"));
48
+ exports.dialogs = dialogs;
49
+ const downloads = __importStar(require("./downloads"));
50
+ exports.downloads = downloads;
51
+ const messageParse = __importStar(require("./messageParse"));
52
+ exports.messageParse = messageParse;
53
+ const message = __importStar(require("./messages"));
54
+ exports.message = message;
55
+ const telegramBaseClient = __importStar(require("./telegramBaseClient"));
56
+ exports.telegramBaseClient = telegramBaseClient;
57
+ const tgClient = __importStar(require("./TelegramClient"));
58
+ exports.tgClient = tgClient;
59
+ const updates = __importStar(require("./updates"));
60
+ exports.updates = updates;
61
+ const uploads = __importStar(require("./uploads"));
62
+ exports.uploads = uploads;
63
+ const users = __importStar(require("./users"));
64
+ exports.users = users;
@@ -0,0 +1,17 @@
1
+ import { Api } from "../tl/api";
2
+ import type { EntityLike } from "../define";
3
+ import type { TelegramClient } from "./TelegramClient";
4
+ export type messageEntities = typeof Api.MessageEntityBold | typeof Api.MessageEntityItalic | typeof Api.MessageEntityStrike | typeof Api.MessageEntityCode | typeof Api.MessageEntityPre;
5
+ export declare const DEFAULT_DELIMITERS: {
6
+ [key: string]: messageEntities;
7
+ };
8
+ export interface ParseInterface {
9
+ parse: (message: string) => [string, Api.TypeMessageEntity[]];
10
+ unparse: (text: string, entities: Api.TypeMessageEntity[]) => string;
11
+ }
12
+ /** @hidden */
13
+ export declare function _replaceWithMention(client: TelegramClient, entities: Api.TypeMessageEntity[], i: number, user: EntityLike): Promise<boolean>;
14
+ /** @hidden */
15
+ export declare function _parseMessageText(client: TelegramClient, message: string, parseMode: false | string | ParseInterface): Promise<[string, Api.TypeMessageEntity[]]>;
16
+ /** @hidden */
17
+ export declare function _getResponseMessage(client: TelegramClient, request: any, result: any, inputChat: any): Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined;
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_DELIMITERS = void 0;
7
+ exports._replaceWithMention = _replaceWithMention;
8
+ exports._parseMessageText = _parseMessageText;
9
+ exports._getResponseMessage = _getResponseMessage;
10
+ const Utils_1 = require("../Utils");
11
+ const api_1 = require("../tl/api");
12
+ const index_1 = require("../index");
13
+ const Helpers_1 = require("../Helpers");
14
+ const big_integer_1 = __importDefault(require("big-integer"));
15
+ exports.DEFAULT_DELIMITERS = {
16
+ "**": api_1.Api.MessageEntityBold,
17
+ __: api_1.Api.MessageEntityItalic,
18
+ "~~": api_1.Api.MessageEntityStrike,
19
+ "`": api_1.Api.MessageEntityCode,
20
+ "```": api_1.Api.MessageEntityPre,
21
+ };
22
+ /** @hidden */
23
+ async function _replaceWithMention(client, entities, i, user) {
24
+ try {
25
+ entities[i] = new api_1.Api.InputMessageEntityMentionName({
26
+ offset: entities[i].offset,
27
+ length: entities[i].length,
28
+ userId: (await client.getInputEntity(user)),
29
+ });
30
+ return true;
31
+ }
32
+ catch (e) {
33
+ return false;
34
+ }
35
+ }
36
+ /** @hidden */
37
+ async function _parseMessageText(client, message, parseMode) {
38
+ if (parseMode == false) {
39
+ return [message, []];
40
+ }
41
+ if (parseMode == undefined) {
42
+ if (client.parseMode == undefined) {
43
+ return [message, []];
44
+ }
45
+ parseMode = client.parseMode;
46
+ }
47
+ else if (typeof parseMode === "string") {
48
+ parseMode = (0, Utils_1.sanitizeParseMode)(parseMode);
49
+ }
50
+ const [rawMessage, msgEntities] = parseMode.parse(message);
51
+ for (let i = msgEntities.length - 1; i >= 0; i--) {
52
+ const e = msgEntities[i];
53
+ if (e instanceof api_1.Api.MessageEntityTextUrl) {
54
+ const m = /^@|\+|tg:\/\/user\?id=(\d+)/.exec(e.url);
55
+ if (m) {
56
+ const userIdOrUsername = m[1] ? Number(m[1]) : e.url;
57
+ const isMention = await _replaceWithMention(client, msgEntities, i, userIdOrUsername);
58
+ if (!isMention) {
59
+ msgEntities.splice(i, 1);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ return [rawMessage, msgEntities];
65
+ }
66
+ /** @hidden */
67
+ function _getResponseMessage(client, request, result, inputChat) {
68
+ let updates = [];
69
+ let entities = new Map();
70
+ if (result instanceof api_1.Api.UpdateShort) {
71
+ updates = [result.update];
72
+ }
73
+ else if (result instanceof api_1.Api.Updates ||
74
+ result instanceof api_1.Api.UpdatesCombined) {
75
+ updates = result.updates;
76
+ for (const x of [...result.users, ...result.chats]) {
77
+ entities.set(index_1.utils.getPeerId(x), x);
78
+ }
79
+ }
80
+ else {
81
+ return;
82
+ }
83
+ const randomToId = new Map();
84
+ const idToMessage = new Map();
85
+ let schedMessage;
86
+ for (const update of updates) {
87
+ if (update instanceof api_1.Api.UpdateMessageID) {
88
+ randomToId.set(update.randomId.toString(), update.id);
89
+ }
90
+ else if (update instanceof api_1.Api.UpdateNewChannelMessage ||
91
+ update instanceof api_1.Api.UpdateNewMessage) {
92
+ update.message._finishInit(client, entities, inputChat);
93
+ if ("randomId" in request || (0, Helpers_1.isArrayLike)(request)) {
94
+ idToMessage.set(update.message.id, update.message);
95
+ }
96
+ else {
97
+ return update.message;
98
+ }
99
+ }
100
+ else if (update instanceof api_1.Api.UpdateEditMessage &&
101
+ "peer" in request &&
102
+ (0, Helpers_1._entityType)(request.peer) != Helpers_1._EntityType.CHANNEL) {
103
+ update.message._finishInit(client, entities, inputChat);
104
+ if ("randomId" in request) {
105
+ idToMessage.set(update.message.id, update.message);
106
+ }
107
+ else if ("id" in request && request.id === update.message.id) {
108
+ return update.message;
109
+ }
110
+ }
111
+ else if (update instanceof api_1.Api.UpdateEditChannelMessage &&
112
+ "peer" in request &&
113
+ (0, Utils_1.getPeerId)(request.peer) ==
114
+ (0, Utils_1.getPeerId)(update.message.peerId)) {
115
+ if (request.id == update.message.id) {
116
+ update.message._finishInit(client, entities, inputChat);
117
+ return update.message;
118
+ }
119
+ }
120
+ else if (update instanceof api_1.Api.UpdateNewScheduledMessage) {
121
+ update.message._finishInit(client, entities, inputChat);
122
+ schedMessage = update.message;
123
+ idToMessage.set(update.message.id, update.message);
124
+ }
125
+ else if (update instanceof api_1.Api.UpdateMessagePoll) {
126
+ if (request.media.poll.id == update.pollId) {
127
+ const m = new api_1.Api.Message({
128
+ id: request.id,
129
+ peerId: index_1.utils.getPeerId(request.peer),
130
+ media: new api_1.Api.MessageMediaPoll({
131
+ poll: update.poll,
132
+ results: update.results,
133
+ }),
134
+ message: "",
135
+ date: 0,
136
+ });
137
+ m._finishInit(client, entities, inputChat);
138
+ return m;
139
+ }
140
+ }
141
+ }
142
+ if (request == undefined) {
143
+ return idToMessage;
144
+ }
145
+ let randomId;
146
+ if ((0, Helpers_1.isArrayLike)(request) ||
147
+ typeof request == "number" ||
148
+ big_integer_1.default.isInstance(request)) {
149
+ randomId = request;
150
+ }
151
+ else {
152
+ randomId = request.randomId;
153
+ }
154
+ if (!randomId) {
155
+ if (schedMessage) {
156
+ return schedMessage;
157
+ }
158
+ client._log.warn(`No randomId in ${request} to map to. returning undefined for ${result} (Message was empty)`);
159
+ return undefined;
160
+ }
161
+ if (!(0, Helpers_1.isArrayLike)(randomId)) {
162
+ let msg = idToMessage.get(randomToId.get(randomId.toString()));
163
+ if (!msg) {
164
+ client._log.warn(`Request ${request.className} had missing message mapping ${result.className} (Message was empty)`);
165
+ }
166
+ return msg;
167
+ }
168
+ const final = [];
169
+ let warned = false;
170
+ for (const rnd of randomId) {
171
+ const tmp = randomToId.get(rnd.toString());
172
+ if (!tmp) {
173
+ warned = true;
174
+ break;
175
+ }
176
+ const tmp2 = idToMessage.get(tmp);
177
+ if (!tmp2) {
178
+ warned = true;
179
+ break;
180
+ }
181
+ final.push(tmp2);
182
+ }
183
+ if (warned) {
184
+ client._log.warn(`Request ${request.className} had missing message mapping ${result.className} (Message was empty)`);
185
+ }
186
+ const finalToReturn = [];
187
+ for (const rnd of randomId) {
188
+ finalToReturn.push(idToMessage.get(randomToId.get(rnd.toString())));
189
+ }
190
+ return finalToReturn;
191
+ }
@@ -0,0 +1,263 @@
1
+ import { Api } from "../tl";
2
+ import type { DateLike, EntityLike, FileLike, MarkupLike, MessageIDLike, MessageLike } from "../define";
3
+ import { RequestIter } from "../requestIter";
4
+ import { TotalList } from "../Helpers";
5
+ import type { TelegramClient } from "..";
6
+ interface MessageIterParams {
7
+ entity: EntityLike;
8
+ offsetId: number;
9
+ minId: number;
10
+ maxId: number;
11
+ fromUser?: EntityLike;
12
+ offsetDate: DateLike;
13
+ addOffset: number;
14
+ filter: any;
15
+ search: string;
16
+ replyTo: MessageIDLike;
17
+ }
18
+ export declare class _MessagesIter extends RequestIter {
19
+ entity?: Api.TypeInputPeer;
20
+ request?: Api.messages.SearchGlobal | Api.messages.GetReplies | Api.messages.GetHistory | Api.messages.Search;
21
+ addOffset?: number;
22
+ maxId?: number;
23
+ minId?: number;
24
+ lastId?: number;
25
+ _init({ entity, offsetId, minId, maxId, fromUser, offsetDate, addOffset, filter, search, replyTo, }: MessageIterParams): Promise<false | undefined>;
26
+ _loadNextChunk(): Promise<true | undefined>;
27
+ _messageInRange(message: Api.Message): boolean;
28
+ [Symbol.asyncIterator](): AsyncIterator<Api.Message, any, undefined>;
29
+ _updateOffset(lastMessage: Api.Message, response: any): void;
30
+ }
31
+ interface IDsIterInterface {
32
+ entity: EntityLike;
33
+ ids: Api.TypeInputMessage[];
34
+ }
35
+ export declare class _IDsIter extends RequestIter {
36
+ _ids?: Api.TypeInputMessage[];
37
+ _offset?: number;
38
+ _ty: number | undefined;
39
+ private _entity;
40
+ _init({ entity, ids }: IDsIterInterface): Promise<void>;
41
+ [Symbol.asyncIterator](): AsyncIterator<Api.Message, any, undefined>;
42
+ _loadNextChunk(): Promise<false | undefined>;
43
+ }
44
+ /**
45
+ * Interface for iterating over messages. used in both {@link iterMessages} and {@link getMessages}.
46
+ */
47
+ export interface IterMessagesParams {
48
+ /** Number of messages to be retrieved.<br/>
49
+ * Due to limitations with the API retrieving more than 3000 messages will take longer than half a minute. (might even take longer)<br/>
50
+ * if undefined is passed instead of a number the library will try to retrieve all the messages.*/
51
+ limit?: number;
52
+ /** Offset date (messages previous to this date will be retrieved). Exclusive. */
53
+ offsetDate?: DateLike;
54
+ /** Offset message ID (only messages previous to the given ID will be retrieved). Exclusive. */
55
+ offsetId: number;
56
+ /** All the messages with a higher (newer) ID or equal to this will be excluded. */
57
+ maxId: number;
58
+ /** All the messages with a lower (older) ID or equal to this will be excluded. */
59
+ minId: number;
60
+ /** Additional message offset (all of the specified offsets + this offset = older messages). */
61
+ addOffset: number;
62
+ /** The string to be used as a search query. */
63
+ search?: string;
64
+ /** The filter to use when returning messages.<br/>
65
+ * For instance, InputMessagesFilterPhotos would yield only messages containing photos.
66
+ */
67
+ filter?: Api.TypeMessagesFilter | Api.TypeMessagesFilter[];
68
+ /** Only messages from this user will be returned. */
69
+ fromUser?: EntityLike;
70
+ /** Wait time (in seconds) between different GetHistory requests.<br/>
71
+ * Use this parameter to avoid hitting the FloodWaitError as needed.<br/>
72
+ * If left to undefined, it will default to 1 second only if the number of messages is higher than 3000.
73
+ * If the ids parameter is used, this time will default to 10 seconds only if the amount of IDs is higher than 300.
74
+ */
75
+ waitTime?: number;
76
+ /** A single integer ID (or several IDs) for the message that should be returned.<br/>
77
+ * This parameter takes precedence over the rest (which will be ignored if this is set).<br/>
78
+ * This can for instance be used to get the message with ID 123 from a channel.<br/>
79
+ * **Note** that if the message doesn"t exist, undefined will appear in its place.
80
+ */
81
+ ids?: number | number[] | Api.TypeInputMessage | Api.TypeInputMessage[];
82
+ /** If set to `true`, the messages will be returned in reverse order (from oldest to newest, instead of the default newest to oldest).<br/>
83
+ * This also means that the meaning of offsetId and offsetDate parameters is reversed, although they will still be exclusive.<br/>
84
+ * `minId` becomes equivalent to `offsetId` instead of being `maxId` as well since messages are returned in ascending order.<br/>
85
+ * You cannot use this if both entity and ids are undefined.
86
+ */
87
+ reverse?: boolean;
88
+ /** If set to a message ID, the messages that reply to this ID will be returned.<br/>
89
+ * This feature is also known as comments in posts of broadcast channels, or viewing threads in groups.<br/>
90
+ * This feature can only be used in broadcast channels and their linked supergroups. Using it in a chat or private conversation will result in PEER_ID_INVALID error.<br/>
91
+ * When using this parameter, the filter and search parameters have no effect, since Telegram's API doesn't support searching messages in replies.
92
+ */
93
+ replyTo?: number;
94
+ /** If set to `true`, messages which are scheduled will be returned.
95
+ * All other parameters will be ignored for this, except `entity`.
96
+ */
97
+ scheduled: boolean;
98
+ }
99
+ /**
100
+ * Interface for sending a message. only message is required
101
+ */
102
+ export interface SendMessageParams {
103
+ /** The message to be sent, or another message object to resend as a copy.<br/>
104
+ * The maximum length for a message is 35,000 bytes or 4,096 characters.<br/>
105
+ * Longer messages will not be sliced automatically, and you should slice them manually if the text to send is longer than said length. */
106
+ message?: MessageLike;
107
+ /** Whether to reply to a message or not. If an integer is provided, it should be the ID of the message that it should reply to. */
108
+ replyTo?: number | Api.Message;
109
+ /** Optional attributes that override the inferred ones, like DocumentAttributeFilename and so on. */
110
+ attributes?: Api.TypeDocumentAttribute[];
111
+ /** See the {@link parseMode} property for allowed values. Markdown parsing will be used by default. */
112
+ parseMode?: any;
113
+ /** A list of message formatting entities. When provided, the parseMode is ignored. */
114
+ formattingEntities?: Api.TypeMessageEntity[];
115
+ /** Should the link preview be shown? */
116
+ linkPreview?: boolean;
117
+ /** Sends a message with a file attached (e.g. a photo, video, audio or document). The message may be empty. */
118
+ file?: FileLike | FileLike[];
119
+ /** Optional JPEG thumbnail (for documents). Telegram will ignore this parameter unless you pass a .jpg file!<br/>
120
+ * The file must also be small in dimensions and in disk size. Successful thumbnails were files below 20kB and 320x320px.<br/>
121
+ * Width/height and dimensions/size ratios may be important.
122
+ * For Telegram to accept a thumbnail, you must provide the dimensions of the underlying media through `attributes:` with DocumentAttributesVideo.
123
+ */
124
+ thumb?: FileLike;
125
+ /** Whether to send the given file as a document or not. */
126
+ forceDocument?: false;
127
+ /** Whether the existing draft should be cleared or not. */
128
+ clearDraft?: false;
129
+ /** The matrix (list of lists), row list or button to be shown after sending the message.<br/>
130
+ * This parameter will only work if you have signed in as a bot. You can also pass your own ReplyMarkup here.<br/>
131
+ * <br/>
132
+ * All the following limits apply together:
133
+ * - There can be 100 buttons at most (any more are ignored).
134
+ * - There can be 8 buttons per row at most (more are ignored).
135
+ * - The maximum callback data per button is 64 bytes.
136
+ * - The maximum data that can be embedded in total is just over 4KB, shared between inline callback data and text.
137
+ */
138
+ buttons?: MarkupLike;
139
+ /** Whether the message should notify people in a broadcast channel or not. Defaults to false, which means it will notify them. Set it to True to alter this behaviour. */
140
+ silent?: boolean;
141
+ /** Whether the sent video supports streaming or not.<br/>
142
+ * Note that Telegram only recognizes as streamable some formats like MP4, and others like AVI or MKV will not work.<br/>
143
+ * You should convert these to MP4 before sending if you want them to be streamable. Unsupported formats will result in VideoContentTypeError. */
144
+ supportStreaming?: boolean;
145
+ /** If set, the message won't send immediately, and instead it will be scheduled to be automatically sent at a later time. */
146
+ schedule?: DateLike;
147
+ noforwards?: boolean;
148
+ /** Similar to ``replyTo``, but replies in the linked group of a broadcast channel instead (effectively leaving a "comment to" the specified message).
149
+
150
+ This parameter takes precedence over ``replyTo``.
151
+ If there is no linked chat, `SG_ID_INVALID` is thrown.
152
+ */
153
+ commentTo?: number | Api.Message;
154
+ /**
155
+ * Used for threads to reply to a specific thread
156
+ */
157
+ topMsgId?: number | Api.Message;
158
+ }
159
+ /** interface used for forwarding messages */
160
+ export interface ForwardMessagesParams {
161
+ /** The message(s) to forward, or their integer IDs. */
162
+ messages: MessageIDLike | MessageIDLike[];
163
+ /** If the given messages are integer IDs and not instances of the Message class, this must be specified in order for the forward to work.<br/> */
164
+ fromPeer: EntityLike;
165
+ /** Whether the message should notify people with sound or not.<br/>
166
+ * Defaults to false (send with a notification sound unless the person has the chat muted). Set it to true to alter this behaviour. */
167
+ silent?: boolean;
168
+ /** If set, the message(s) won't forward immediately, and instead they will be scheduled to be automatically sent at a later time. */
169
+ schedule?: DateLike;
170
+ dropAuthor?: boolean;
171
+ noforwards?: boolean;
172
+ /** Used for threads to reply to a specific thread */
173
+ topMsgId?: number | Api.Message;
174
+ }
175
+ /** Interface for editing messages */
176
+ export interface EditMessageParams {
177
+ /** The ID of the message (or Message itself) to be edited. If the entity was a Message, then this message will be treated as the new text. */
178
+ message: Api.Message | number;
179
+ /** The new text of the message. Does nothing if the entity was a Message. */
180
+ text?: string;
181
+ /** See the {@link TelegramClient.parseMode} property for allowed values. Markdown parsing will be used by default. */
182
+ parseMode?: any;
183
+ /** A list of message formatting entities. When provided, the parseMode is ignored. */
184
+ formattingEntities?: Api.TypeMessageEntity[];
185
+ /** Should the link preview be shown? */
186
+ linkPreview?: boolean;
187
+ /** The file object that should replace the existing media in the message. Does nothing if entity was a Message */
188
+ file?: FileLike;
189
+ /** Whether to send the given file as a document or not. */
190
+ forceDocument?: false;
191
+ /** The matrix (list of lists), row list or button to be shown after sending the message.<br/>
192
+ * This parameter will only work if you have signed in as a bot. You can also pass your own ReplyMarkup here.<br/>
193
+ * <br/>
194
+ * All the following limits apply together:
195
+ * - There can be 100 buttons at most (any more are ignored).
196
+ * - There can be 8 buttons per row at most (more are ignored).
197
+ * - The maximum callback data per button is 64 bytes.
198
+ * - The maximum data that can be embedded in total is just over 4KB, shared between inline callback data and text.
199
+ */
200
+ buttons?: MarkupLike;
201
+ /** If set, the message won't be edited immediately, and instead it will be scheduled to be automatically edited at a later time. */
202
+ schedule?: DateLike;
203
+ }
204
+ /** Interface for editing messages */
205
+ export interface UpdatePinMessageParams {
206
+ /** Whether the pin should notify people or not. <br />
207
+ * By default it has the opposite behavior of official clients, it will not notify members.
208
+ */
209
+ notify?: boolean;
210
+ /** Whether the message should be pinned for everyone or not. <br />
211
+ * By default it has the opposite behavior of official clients, and it will pin the message for both sides, in private chats.
212
+ */
213
+ pmOneSide?: boolean;
214
+ }
215
+ /** Interface for mark message as read */
216
+ export interface MarkAsReadParams {
217
+ /**
218
+ * Until which message should the read acknowledge be sent for. <br />
219
+ * This has priority over the `message` parameter.
220
+ */
221
+ maxId?: number;
222
+ /**
223
+ * Whether the mention badge should be cleared (so that there are no more mentions) or not for the given entity. <br />
224
+ * If no message is provided, this will be the only action taken.
225
+ */
226
+ clearMentions?: boolean;
227
+ }
228
+ /** @hidden */
229
+ export declare function iterMessages(client: TelegramClient, entity: EntityLike | undefined, options: Partial<IterMessagesParams>): _MessagesIter | _IDsIter;
230
+ /** @hidden */
231
+ export declare function getMessages(client: TelegramClient, entity: EntityLike | undefined, params: Partial<IterMessagesParams>): Promise<TotalList<Api.Message>>;
232
+ /** @hidden */
233
+ export declare function sendMessage(client: TelegramClient,
234
+ /** To who will it be sent. */
235
+ entity: EntityLike,
236
+ /** The message to be sent, or another message object to resend as a copy.<br/>
237
+ * The maximum length for a message is 35,000 bytes or 4,096 characters.<br/>
238
+ * Longer messages will not be sliced automatically, and you should slice them manually if the text to send is longer than said length. */
239
+ { message, replyTo, attributes, parseMode, formattingEntities, linkPreview, file, thumb, forceDocument, clearDraft, buttons, silent, supportStreaming, schedule, noforwards, commentTo, topMsgId, }?: SendMessageParams): Promise<Api.Message>;
240
+ /** @hidden */
241
+ export declare function forwardMessages(client: TelegramClient, entity: EntityLike, { messages, fromPeer, silent, schedule, noforwards, dropAuthor, topMsgId, }: ForwardMessagesParams & {
242
+ topMsgId?: number | Api.Message;
243
+ }): Promise<Api.Message[]>;
244
+ /** @hidden */
245
+ export declare function editMessage(client: TelegramClient, entity: EntityLike, { message, text, parseMode, formattingEntities, linkPreview, file, forceDocument, buttons, schedule, }: EditMessageParams): Promise<Api.Message>;
246
+ /** @hidden */
247
+ export declare function deleteMessages(client: TelegramClient, entity: EntityLike | undefined, messageIds: MessageIDLike[], { revoke }: {
248
+ revoke?: boolean | undefined;
249
+ }): Promise<Api.messages.AffectedMessages[]>;
250
+ /** @hidden */
251
+ export declare function pinMessage(client: TelegramClient, entity: EntityLike, message?: MessageIDLike, pinMessageParams?: UpdatePinMessageParams): Promise<Api.Message | Api.messages.AffectedHistory | undefined>;
252
+ /** @hidden */
253
+ export declare function unpinMessage(client: TelegramClient, entity: EntityLike, message?: MessageIDLike, unpinMessageParams?: UpdatePinMessageParams): Promise<Api.Message | Api.messages.AffectedHistory | undefined>;
254
+ /** @hidden */
255
+ export declare function _pin(client: TelegramClient, entity: EntityLike, message: MessageIDLike | undefined, unpin: boolean, notify?: boolean, pmOneSide?: boolean): Promise<Api.Message | Api.messages.AffectedHistory | undefined>;
256
+ /** @hidden */
257
+ export declare function markAsRead(client: TelegramClient, entity: EntityLike, message?: MessageIDLike | MessageIDLike[], markAsReadParams?: MarkAsReadParams): Promise<boolean>;
258
+ /** @hidden */
259
+ export declare function getCommentData(client: TelegramClient, entity: EntityLike, message: number | Api.Message): Promise<{
260
+ entity: Api.TypeInputPeer;
261
+ replyTo: number;
262
+ }>;
263
+ export {};