teleproto 203.0.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.
- package/CryptoFile.d.ts +2 -0
- package/CryptoFile.js +23 -0
- package/Helpers.d.ts +151 -0
- package/Helpers.js +477 -0
- package/LICENSE +23 -0
- package/Password.d.ts +15 -0
- package/Password.js +271 -0
- package/README.md +111 -0
- package/Utils.d.ts +228 -0
- package/Utils.js +1248 -0
- package/Version.d.ts +1 -0
- package/Version.js +4 -0
- package/client/2fa.d.ts +48 -0
- package/client/2fa.js +109 -0
- package/client/TelegramClient.d.ts +1042 -0
- package/client/TelegramClient.js +1167 -0
- package/client/account.d.ts +0 -0
- package/client/account.js +1 -0
- package/client/auth.d.ts +93 -0
- package/client/auth.js +375 -0
- package/client/bots.d.ts +6 -0
- package/client/bots.js +24 -0
- package/client/buttons.d.ts +4 -0
- package/client/buttons.js +87 -0
- package/client/chats.d.ts +46 -0
- package/client/chats.js +350 -0
- package/client/dialogs.d.ts +52 -0
- package/client/dialogs.js +174 -0
- package/client/downloads.d.ts +157 -0
- package/client/downloads.js +598 -0
- package/client/fs.d.ts +1 -0
- package/client/fs.js +13 -0
- package/client/index.d.ts +15 -0
- package/client/index.js +50 -0
- package/client/messageParse.d.ts +17 -0
- package/client/messageParse.js +191 -0
- package/client/messages.d.ts +259 -0
- package/client/messages.js +804 -0
- package/client/os.d.ts +2 -0
- package/client/os.js +23 -0
- package/client/path.d.ts +2 -0
- package/client/path.js +7 -0
- package/client/telegramBaseClient.d.ts +238 -0
- package/client/telegramBaseClient.js +368 -0
- package/client/updates.d.ts +31 -0
- package/client/updates.js +254 -0
- package/client/uploads.d.ts +137 -0
- package/client/uploads.js +514 -0
- package/client/users.d.ts +29 -0
- package/client/users.js +491 -0
- package/crypto/AuthKey.d.ts +20 -0
- package/crypto/AuthKey.js +76 -0
- package/crypto/CTR.d.ts +6 -0
- package/crypto/CTR.js +35 -0
- package/crypto/Factorizator.d.ts +19 -0
- package/crypto/Factorizator.js +74 -0
- package/crypto/IGE.d.ts +18 -0
- package/crypto/IGE.js +34 -0
- package/crypto/RSA.d.ts +15 -0
- package/crypto/RSA.js +70 -0
- package/crypto/converters.d.ts +19 -0
- package/crypto/converters.js +52 -0
- package/crypto/crypto.d.ts +27 -0
- package/crypto/crypto.js +117 -0
- package/crypto/words.d.ts +6 -0
- package/crypto/words.js +48 -0
- package/define.d.ts +77 -0
- package/entityCache.d.ts +7 -0
- package/entityCache.js +79 -0
- package/errors/Common.d.ts +72 -0
- package/errors/Common.js +122 -0
- package/errors/RPCBaseErrors.d.ts +84 -0
- package/errors/RPCBaseErrors.js +134 -0
- package/errors/RPCErrorList.d.ts +37 -0
- package/errors/RPCErrorList.js +117 -0
- package/errors/index.d.ts +11 -0
- package/errors/index.js +29 -0
- package/events/Album.d.ts +36 -0
- package/events/Album.js +104 -0
- package/events/CallbackQuery.d.ts +74 -0
- package/events/CallbackQuery.js +193 -0
- package/events/DeletedMessage.d.ts +45 -0
- package/events/DeletedMessage.js +63 -0
- package/events/EditedMessage.d.ts +30 -0
- package/events/EditedMessage.js +41 -0
- package/events/NewMessage.d.ts +89 -0
- package/events/NewMessage.js +182 -0
- package/events/Raw.d.ts +29 -0
- package/events/Raw.js +43 -0
- package/events/common.d.ts +66 -0
- package/events/common.js +141 -0
- package/events/index.d.ts +2 -0
- package/events/index.js +8 -0
- package/extensions/AsyncQueue.d.ts +10 -0
- package/extensions/AsyncQueue.js +32 -0
- package/extensions/BinaryReader.d.ts +100 -0
- package/extensions/BinaryReader.js +242 -0
- package/extensions/BinaryWriter.d.ts +7 -0
- package/extensions/BinaryWriter.js +15 -0
- package/extensions/Deferred.d.ts +8 -0
- package/extensions/Deferred.js +16 -0
- package/extensions/Logger.d.ts +56 -0
- package/extensions/Logger.js +107 -0
- package/extensions/MessagePacker.d.ts +22 -0
- package/extensions/MessagePacker.js +154 -0
- package/extensions/PendingState.d.ts +12 -0
- package/extensions/PendingState.js +29 -0
- package/extensions/PromisedNetSockets.d.ts +25 -0
- package/extensions/PromisedNetSockets.js +178 -0
- package/extensions/PromisedWebSockets.d.ts +19 -0
- package/extensions/PromisedWebSockets.js +124 -0
- package/extensions/html.d.ts +5 -0
- package/extensions/html.js +213 -0
- package/extensions/index.d.ts +7 -0
- package/extensions/index.js +17 -0
- package/extensions/markdown.d.ts +5 -0
- package/extensions/markdown.js +76 -0
- package/extensions/markdownv2.d.ts +5 -0
- package/extensions/markdownv2.js +51 -0
- package/extensions/net.d.ts +1 -0
- package/extensions/net.js +13 -0
- package/extensions/socks.d.ts +1 -0
- package/extensions/socks.js +13 -0
- package/index.d.ts +14 -0
- package/index.js +48 -0
- package/inspect.d.ts +1 -0
- package/inspect.js +5 -0
- package/network/Authenticator.d.ts +12 -0
- package/network/Authenticator.js +193 -0
- package/network/MTProtoPlainSender.d.ts +19 -0
- package/network/MTProtoPlainSender.js +74 -0
- package/network/MTProtoSender.d.ts +291 -0
- package/network/MTProtoSender.js +854 -0
- package/network/MTProtoState.d.ts +103 -0
- package/network/MTProtoState.js +267 -0
- package/network/RequestState.d.ts +19 -0
- package/network/RequestState.js +35 -0
- package/network/connection/Connection.d.ts +71 -0
- package/network/connection/Connection.js +157 -0
- package/network/connection/TCPAbridged.d.ts +20 -0
- package/network/connection/TCPAbridged.js +58 -0
- package/network/connection/TCPFull.d.ts +17 -0
- package/network/connection/TCPFull.js +61 -0
- package/network/connection/TCPMTProxy.d.ts +50 -0
- package/network/connection/TCPMTProxy.js +121 -0
- package/network/connection/TCPObfuscated.d.ts +19 -0
- package/network/connection/TCPObfuscated.js +78 -0
- package/network/connection/index.d.ts +4 -0
- package/network/connection/index.js +11 -0
- package/network/index.d.ts +11 -0
- package/network/index.js +23 -0
- package/package.json +69 -0
- package/requestIter.d.ts +24 -0
- package/requestIter.js +107 -0
- package/sessions/Abstract.d.ts +103 -0
- package/sessions/Abstract.js +6 -0
- package/sessions/CacheApiSession.d.ts +18 -0
- package/sessions/CacheApiSession.js +99 -0
- package/sessions/Memory.d.ts +38 -0
- package/sessions/Memory.js +272 -0
- package/sessions/StoreSession.d.ts +14 -0
- package/sessions/StoreSession.js +77 -0
- package/sessions/StringSession.d.ts +33 -0
- package/sessions/StringSession.js +116 -0
- package/sessions/index.d.ts +4 -0
- package/sessions/index.js +13 -0
- package/sessions/localStorage.d.ts +1 -0
- package/sessions/localStorage.js +4 -0
- package/tl/AllTLObjects.d.ts +3 -0
- package/tl/AllTLObjects.js +17 -0
- package/tl/MTProtoRequest.d.ts +19 -0
- package/tl/MTProtoRequest.js +38 -0
- package/tl/api.d.ts +31425 -0
- package/tl/api.js +507 -0
- package/tl/apiTl.d.ts +2 -0
- package/tl/apiTl.js +2142 -0
- package/tl/core/GZIPPacked.d.ts +16 -0
- package/tl/core/GZIPPacked.js +51 -0
- package/tl/core/MessageContainer.d.ts +12 -0
- package/tl/core/MessageContainer.js +42 -0
- package/tl/core/RPCResult.d.ts +15 -0
- package/tl/core/RPCResult.js +32 -0
- package/tl/core/TLMessage.d.ts +10 -0
- package/tl/core/TLMessage.js +14 -0
- package/tl/core/index.d.ts +6 -0
- package/tl/core/index.js +16 -0
- package/tl/custom/button.d.ts +25 -0
- package/tl/custom/button.js +78 -0
- package/tl/custom/chatGetter.d.ts +30 -0
- package/tl/custom/chatGetter.js +114 -0
- package/tl/custom/dialog.d.ts +31 -0
- package/tl/custom/dialog.js +40 -0
- package/tl/custom/draft.d.ts +22 -0
- package/tl/custom/draft.js +48 -0
- package/tl/custom/file.d.ts +22 -0
- package/tl/custom/file.js +68 -0
- package/tl/custom/forward.d.ts +16 -0
- package/tl/custom/forward.js +47 -0
- package/tl/custom/index.d.ts +1 -0
- package/tl/custom/index.js +5 -0
- package/tl/custom/inlineResult.d.ts +33 -0
- package/tl/custom/inlineResult.js +87 -0
- package/tl/custom/inlineResults.d.ts +21 -0
- package/tl/custom/inlineResults.js +26 -0
- package/tl/custom/message.d.ts +428 -0
- package/tl/custom/message.js +702 -0
- package/tl/custom/messageButton.d.ts +55 -0
- package/tl/custom/messageButton.js +152 -0
- package/tl/custom/senderGetter.d.ts +29 -0
- package/tl/custom/senderGetter.js +55 -0
- package/tl/generateModule.d.ts +1 -0
- package/tl/generateModule.js +17 -0
- package/tl/generationHelpers.d.ts +12 -0
- package/tl/generationHelpers.js +289 -0
- package/tl/index.d.ts +3 -0
- package/tl/index.js +10 -0
- package/tl/patched/index.d.ts +2 -0
- package/tl/patched/index.js +77 -0
- package/tl/schemaTl.d.ts +2 -0
- package/tl/schemaTl.js +64 -0
- package/tl/types-generator/generate.d.ts +1 -0
- package/tl/types-generator/generate.js +84 -0
- package/tl/types-generator/template.d.ts +6 -0
- package/tl/types-generator/template.js +257 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BinaryReader } from "../../extensions";
|
|
3
|
+
export declare class GZIPPacked {
|
|
4
|
+
static CONSTRUCTOR_ID: number;
|
|
5
|
+
static classType: string;
|
|
6
|
+
data: Buffer;
|
|
7
|
+
private CONSTRUCTOR_ID;
|
|
8
|
+
private classType;
|
|
9
|
+
constructor(data: Buffer);
|
|
10
|
+
static gzipIfSmaller(contentRelated: boolean, data: Buffer): Promise<Buffer>;
|
|
11
|
+
static gzip(input: Buffer): Buffer;
|
|
12
|
+
static ungzip(input: Buffer): Buffer;
|
|
13
|
+
toBytes(): Promise<Buffer>;
|
|
14
|
+
static read(reader: BinaryReader): Promise<Buffer>;
|
|
15
|
+
static fromReader(reader: BinaryReader): Promise<GZIPPacked>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GZIPPacked = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const pako_1 = require("pako");
|
|
6
|
+
class GZIPPacked {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
this.data = data;
|
|
9
|
+
this.CONSTRUCTOR_ID = 0x3072cfa1;
|
|
10
|
+
this.classType = "constructor";
|
|
11
|
+
}
|
|
12
|
+
static async gzipIfSmaller(contentRelated, data) {
|
|
13
|
+
if (contentRelated && data.length > 512) {
|
|
14
|
+
const gzipped = await new GZIPPacked(data).toBytes();
|
|
15
|
+
if (gzipped.length < data.length) {
|
|
16
|
+
return gzipped;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
static gzip(input) {
|
|
22
|
+
return Buffer.from(input);
|
|
23
|
+
// TODO this usually makes it faster for large requests
|
|
24
|
+
//return Buffer.from(deflate(input, { level: 9, gzip: true }))
|
|
25
|
+
}
|
|
26
|
+
static ungzip(input) {
|
|
27
|
+
return Buffer.from((0, pako_1.inflate)(input));
|
|
28
|
+
}
|
|
29
|
+
async toBytes() {
|
|
30
|
+
const g = Buffer.alloc(4);
|
|
31
|
+
g.writeUInt32LE(GZIPPacked.CONSTRUCTOR_ID, 0);
|
|
32
|
+
return Buffer.concat([
|
|
33
|
+
g,
|
|
34
|
+
(0, __1.serializeBytes)(await GZIPPacked.gzip(this.data)),
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
static async read(reader) {
|
|
38
|
+
const constructor = reader.readInt(false);
|
|
39
|
+
if (constructor !== GZIPPacked.CONSTRUCTOR_ID) {
|
|
40
|
+
throw new Error("not equal");
|
|
41
|
+
}
|
|
42
|
+
return GZIPPacked.gzip(reader.tgReadBytes());
|
|
43
|
+
}
|
|
44
|
+
static async fromReader(reader) {
|
|
45
|
+
const data = reader.tgReadBytes();
|
|
46
|
+
return new GZIPPacked(await GZIPPacked.ungzip(data));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.GZIPPacked = GZIPPacked;
|
|
50
|
+
GZIPPacked.CONSTRUCTOR_ID = 0x3072cfa1;
|
|
51
|
+
GZIPPacked.classType = "constructor";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BinaryReader } from "../../extensions";
|
|
2
|
+
export declare class MessageContainer {
|
|
3
|
+
static CONSTRUCTOR_ID: number;
|
|
4
|
+
static classType: string;
|
|
5
|
+
static MAXIMUM_SIZE: number;
|
|
6
|
+
static MAXIMUM_LENGTH: number;
|
|
7
|
+
private CONSTRUCTOR_ID;
|
|
8
|
+
private messages;
|
|
9
|
+
private classType;
|
|
10
|
+
constructor(messages: any[]);
|
|
11
|
+
static fromReader(reader: BinaryReader): Promise<MessageContainer>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageContainer = void 0;
|
|
4
|
+
const TLMessage_1 = require("./TLMessage");
|
|
5
|
+
class MessageContainer {
|
|
6
|
+
constructor(messages) {
|
|
7
|
+
this.CONSTRUCTOR_ID = 0x73f1f8dc;
|
|
8
|
+
this.messages = messages;
|
|
9
|
+
this.classType = "constructor";
|
|
10
|
+
}
|
|
11
|
+
static async fromReader(reader) {
|
|
12
|
+
const messages = [];
|
|
13
|
+
const length = reader.readInt();
|
|
14
|
+
for (let x = 0; x < length; x++) {
|
|
15
|
+
const msgId = reader.readLong();
|
|
16
|
+
const seqNo = reader.readInt();
|
|
17
|
+
const length = reader.readInt();
|
|
18
|
+
const before = reader.tellPosition();
|
|
19
|
+
const obj = reader.tgReadObject();
|
|
20
|
+
reader.setPosition(before + length);
|
|
21
|
+
const tlMessage = new TLMessage_1.TLMessage(msgId, seqNo, obj);
|
|
22
|
+
messages.push(tlMessage);
|
|
23
|
+
}
|
|
24
|
+
return new MessageContainer(messages);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MessageContainer = MessageContainer;
|
|
28
|
+
MessageContainer.CONSTRUCTOR_ID = 0x73f1f8dc;
|
|
29
|
+
MessageContainer.classType = "constructor";
|
|
30
|
+
// Maximum size in bytes for the inner payload of the container.
|
|
31
|
+
// Telegram will close the connection if the payload is bigger.
|
|
32
|
+
// The overhead of the container itself is subtracted.
|
|
33
|
+
MessageContainer.MAXIMUM_SIZE = 1044456 - 8;
|
|
34
|
+
// Maximum amount of messages that can't be sent inside a single
|
|
35
|
+
// container, inclusive. Beyond this limit Telegram will respond
|
|
36
|
+
// with BAD_MESSAGE 64 (invalid container).
|
|
37
|
+
//
|
|
38
|
+
// This limit is not 100% accurate and may in some cases be higher.
|
|
39
|
+
// However, sending up to 100 requests at once in a single container
|
|
40
|
+
// is a reasonable conservative value, since it could also depend on
|
|
41
|
+
// other factors like size per request, but we cannot know this.
|
|
42
|
+
MessageContainer.MAXIMUM_LENGTH = 100;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Api } from "../api";
|
|
3
|
+
import type { BinaryReader } from "../../extensions";
|
|
4
|
+
import bigInt from "big-integer";
|
|
5
|
+
export declare class RPCResult {
|
|
6
|
+
static CONSTRUCTOR_ID: number;
|
|
7
|
+
static classType: string;
|
|
8
|
+
private CONSTRUCTOR_ID;
|
|
9
|
+
private reqMsgId;
|
|
10
|
+
private body?;
|
|
11
|
+
private error?;
|
|
12
|
+
private classType;
|
|
13
|
+
constructor(reqMsgId: bigInt.BigInteger, body?: Buffer, error?: Api.RpcError);
|
|
14
|
+
static fromReader(reader: BinaryReader): Promise<RPCResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RPCResult = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
class RPCResult {
|
|
7
|
+
constructor(reqMsgId, body, error) {
|
|
8
|
+
this.CONSTRUCTOR_ID = 0xf35c6d01;
|
|
9
|
+
this.reqMsgId = reqMsgId;
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.error = error;
|
|
12
|
+
this.classType = "constructor";
|
|
13
|
+
}
|
|
14
|
+
static async fromReader(reader) {
|
|
15
|
+
const msgId = reader.readLong();
|
|
16
|
+
const innerCode = reader.readInt(false);
|
|
17
|
+
if (innerCode === api_1.Api.RpcError.CONSTRUCTOR_ID) {
|
|
18
|
+
return new RPCResult(msgId, undefined, api_1.Api.RpcError.fromReader(reader));
|
|
19
|
+
}
|
|
20
|
+
if (innerCode === _1.GZIPPacked.CONSTRUCTOR_ID) {
|
|
21
|
+
return new RPCResult(msgId, (await _1.GZIPPacked.fromReader(reader)).data);
|
|
22
|
+
}
|
|
23
|
+
reader.seek(-4);
|
|
24
|
+
// This reader.read() will read more than necessary, but it's okay.
|
|
25
|
+
// We could make use of MessageContainer's length here, but since
|
|
26
|
+
// it's not necessary we don't need to care about it.
|
|
27
|
+
return new RPCResult(msgId, reader.read(), undefined);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.RPCResult = RPCResult;
|
|
31
|
+
RPCResult.CONSTRUCTOR_ID = 0xf35c6d01;
|
|
32
|
+
RPCResult.classType = "constructor";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import bigInt from "big-integer";
|
|
2
|
+
export declare class TLMessage {
|
|
3
|
+
static SIZE_OVERHEAD: number;
|
|
4
|
+
static classType: string;
|
|
5
|
+
msgId: bigInt.BigInteger;
|
|
6
|
+
private classType;
|
|
7
|
+
private seqNo;
|
|
8
|
+
obj: any;
|
|
9
|
+
constructor(msgId: bigInt.BigInteger, seqNo: number, obj: any);
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TLMessage = void 0;
|
|
4
|
+
class TLMessage {
|
|
5
|
+
constructor(msgId, seqNo, obj) {
|
|
6
|
+
this.msgId = msgId;
|
|
7
|
+
this.seqNo = seqNo;
|
|
8
|
+
this.obj = obj;
|
|
9
|
+
this.classType = "constructor";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.TLMessage = TLMessage;
|
|
13
|
+
TLMessage.SIZE_OVERHEAD = 12;
|
|
14
|
+
TLMessage.classType = "constructor";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TLMessage } from "./TLMessage";
|
|
2
|
+
import { RPCResult } from "./RPCResult";
|
|
3
|
+
import { MessageContainer } from "./MessageContainer";
|
|
4
|
+
import { GZIPPacked } from "./GZIPPacked";
|
|
5
|
+
export declare const coreObjects: Map<number, Function>;
|
|
6
|
+
export { RPCResult, TLMessage, MessageContainer, GZIPPacked };
|
package/tl/core/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GZIPPacked = exports.MessageContainer = exports.TLMessage = exports.RPCResult = exports.coreObjects = void 0;
|
|
4
|
+
const TLMessage_1 = require("./TLMessage");
|
|
5
|
+
Object.defineProperty(exports, "TLMessage", { enumerable: true, get: function () { return TLMessage_1.TLMessage; } });
|
|
6
|
+
const RPCResult_1 = require("./RPCResult");
|
|
7
|
+
Object.defineProperty(exports, "RPCResult", { enumerable: true, get: function () { return RPCResult_1.RPCResult; } });
|
|
8
|
+
const MessageContainer_1 = require("./MessageContainer");
|
|
9
|
+
Object.defineProperty(exports, "MessageContainer", { enumerable: true, get: function () { return MessageContainer_1.MessageContainer; } });
|
|
10
|
+
const GZIPPacked_1 = require("./GZIPPacked");
|
|
11
|
+
Object.defineProperty(exports, "GZIPPacked", { enumerable: true, get: function () { return GZIPPacked_1.GZIPPacked; } });
|
|
12
|
+
exports.coreObjects = new Map([
|
|
13
|
+
[RPCResult_1.RPCResult.CONSTRUCTOR_ID, RPCResult_1.RPCResult],
|
|
14
|
+
[GZIPPacked_1.GZIPPacked.CONSTRUCTOR_ID, GZIPPacked_1.GZIPPacked],
|
|
15
|
+
[MessageContainer_1.MessageContainer.CONSTRUCTOR_ID, MessageContainer_1.MessageContainer],
|
|
16
|
+
]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ButtonLike, EntityLike } from "../../define";
|
|
3
|
+
import { Api } from "../api";
|
|
4
|
+
import { inspect } from "../../inspect";
|
|
5
|
+
export declare class Button {
|
|
6
|
+
button: ButtonLike;
|
|
7
|
+
resize: boolean | undefined;
|
|
8
|
+
selective: boolean | undefined;
|
|
9
|
+
singleUse: boolean | undefined;
|
|
10
|
+
[inspect.custom](): {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
constructor(button: Api.TypeKeyboardButton, resize?: boolean, singleUse?: boolean, selective?: boolean);
|
|
14
|
+
static _isInline(button: ButtonLike): boolean;
|
|
15
|
+
static inline(text: string, data?: Buffer): Api.KeyboardButtonCallback;
|
|
16
|
+
static switchInline(text: string, query?: string, samePeer?: boolean): Api.KeyboardButtonSwitchInline;
|
|
17
|
+
static url(text: string, url?: string): Api.KeyboardButtonUrl;
|
|
18
|
+
static auth(text: string, url?: string, bot?: EntityLike, writeAccess?: boolean, fwdText?: string): Api.InputKeyboardButtonUrlAuth;
|
|
19
|
+
static text(text: string, resize?: boolean, singleUse?: boolean, selective?: boolean): Button;
|
|
20
|
+
static requestLocation(text: string, resize?: boolean, singleUse?: boolean, selective?: boolean): Button;
|
|
21
|
+
static requestPhone(text: string, resize?: boolean, singleUse?: boolean, selective?: boolean): Button;
|
|
22
|
+
static requestPoll(text: string, resize?: boolean, singleUse?: boolean, selective?: boolean): Button;
|
|
23
|
+
static clear(): Api.ReplyKeyboardHide;
|
|
24
|
+
static forceReply(): Api.ReplyKeyboardForceReply;
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Button = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const Helpers_1 = require("../../Helpers");
|
|
7
|
+
const inspect_1 = require("../../inspect");
|
|
8
|
+
class Button {
|
|
9
|
+
constructor(button, resize, singleUse, selective) {
|
|
10
|
+
this.button = button;
|
|
11
|
+
this.resize = resize;
|
|
12
|
+
this.singleUse = singleUse;
|
|
13
|
+
this.selective = selective;
|
|
14
|
+
}
|
|
15
|
+
[inspect_1.inspect.custom]() {
|
|
16
|
+
return (0, Helpers_1.betterConsoleLog)(this);
|
|
17
|
+
}
|
|
18
|
+
static _isInline(button) {
|
|
19
|
+
return (button instanceof api_1.Api.KeyboardButtonCallback ||
|
|
20
|
+
button instanceof api_1.Api.KeyboardButtonSwitchInline ||
|
|
21
|
+
button instanceof api_1.Api.KeyboardButtonUrl ||
|
|
22
|
+
button instanceof api_1.Api.KeyboardButtonUrlAuth ||
|
|
23
|
+
button instanceof api_1.Api.InputKeyboardButtonUrlAuth);
|
|
24
|
+
}
|
|
25
|
+
static inline(text, data) {
|
|
26
|
+
if (!data) {
|
|
27
|
+
data = Buffer.from(text, "utf-8");
|
|
28
|
+
}
|
|
29
|
+
if (data.length > 64) {
|
|
30
|
+
throw new Error("Too many bytes for the data");
|
|
31
|
+
}
|
|
32
|
+
return new api_1.Api.KeyboardButtonCallback({
|
|
33
|
+
text: text,
|
|
34
|
+
data: data,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
static switchInline(text, query = "", samePeer = false) {
|
|
38
|
+
return new api_1.Api.KeyboardButtonSwitchInline({
|
|
39
|
+
text,
|
|
40
|
+
query,
|
|
41
|
+
samePeer,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
static url(text, url) {
|
|
45
|
+
return new api_1.Api.KeyboardButtonUrl({
|
|
46
|
+
text: text,
|
|
47
|
+
url: url || text,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static auth(text, url, bot, writeAccess, fwdText) {
|
|
51
|
+
return new api_1.Api.InputKeyboardButtonUrlAuth({
|
|
52
|
+
text,
|
|
53
|
+
url: url || text,
|
|
54
|
+
bot: __1.utils.getInputUser(bot || new api_1.Api.InputUserSelf()),
|
|
55
|
+
requestWriteAccess: writeAccess,
|
|
56
|
+
fwdText: fwdText,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
static text(text, resize, singleUse, selective) {
|
|
60
|
+
return new this(new api_1.Api.KeyboardButton({ text }), resize, singleUse, selective);
|
|
61
|
+
}
|
|
62
|
+
static requestLocation(text, resize, singleUse, selective) {
|
|
63
|
+
return new this(new api_1.Api.KeyboardButtonRequestGeoLocation({ text }), resize, singleUse, selective);
|
|
64
|
+
}
|
|
65
|
+
static requestPhone(text, resize, singleUse, selective) {
|
|
66
|
+
return new this(new api_1.Api.KeyboardButtonRequestPhone({ text }), resize, singleUse, selective);
|
|
67
|
+
}
|
|
68
|
+
static requestPoll(text, resize, singleUse, selective) {
|
|
69
|
+
return new this(new api_1.Api.KeyboardButtonRequestPoll({ text }), resize, singleUse, selective);
|
|
70
|
+
}
|
|
71
|
+
static clear() {
|
|
72
|
+
return new api_1.Api.ReplyKeyboardHide({});
|
|
73
|
+
}
|
|
74
|
+
static forceReply() {
|
|
75
|
+
return new api_1.Api.ReplyKeyboardForceReply({});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.Button = Button;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Entity, EntityLike } from "../../define";
|
|
3
|
+
import type { TelegramClient } from "../../client/TelegramClient";
|
|
4
|
+
import { inspect } from "../../inspect";
|
|
5
|
+
export interface ChatGetterConstructorParams {
|
|
6
|
+
chatPeer?: EntityLike;
|
|
7
|
+
inputChat?: EntityLike;
|
|
8
|
+
chat?: EntityLike;
|
|
9
|
+
broadcast?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class ChatGetter {
|
|
12
|
+
_chatPeer?: EntityLike;
|
|
13
|
+
_inputChat?: EntityLike;
|
|
14
|
+
_chat?: Entity;
|
|
15
|
+
_broadcast?: boolean;
|
|
16
|
+
_client?: TelegramClient;
|
|
17
|
+
[inspect.custom](): {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
static initChatClass(c: any, { chatPeer, inputChat, chat, broadcast }: ChatGetterConstructorParams): void;
|
|
21
|
+
get chat(): Entity | undefined;
|
|
22
|
+
getChat(): Promise<Entity | undefined>;
|
|
23
|
+
get inputChat(): EntityLike | undefined;
|
|
24
|
+
getInputChat(): Promise<EntityLike | undefined>;
|
|
25
|
+
get chatId(): import("big-integer").BigInteger | undefined;
|
|
26
|
+
get isPrivate(): boolean | undefined;
|
|
27
|
+
get isGroup(): boolean | undefined;
|
|
28
|
+
get isChannel(): boolean;
|
|
29
|
+
_refetchChat(): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ChatGetter = void 0;
|
|
11
|
+
const __1 = require("../..");
|
|
12
|
+
const api_1 = require("../api");
|
|
13
|
+
const Helpers_1 = require("../../Helpers");
|
|
14
|
+
const inspect_1 = require("../../inspect");
|
|
15
|
+
class ChatGetter {
|
|
16
|
+
[inspect_1.inspect.custom]() {
|
|
17
|
+
return (0, Helpers_1.betterConsoleLog)(this);
|
|
18
|
+
}
|
|
19
|
+
static initChatClass(c, { chatPeer, inputChat, chat, broadcast }) {
|
|
20
|
+
c._chatPeer = chatPeer;
|
|
21
|
+
c._inputChat = inputChat;
|
|
22
|
+
c._chat = chat;
|
|
23
|
+
c._broadcast = broadcast;
|
|
24
|
+
c._client = undefined;
|
|
25
|
+
}
|
|
26
|
+
get chat() {
|
|
27
|
+
return this._chat;
|
|
28
|
+
}
|
|
29
|
+
async getChat() {
|
|
30
|
+
var _a;
|
|
31
|
+
if (!this._chat ||
|
|
32
|
+
("min" in this._chat && (await this.getInputChat()))) {
|
|
33
|
+
try {
|
|
34
|
+
if (this._inputChat) {
|
|
35
|
+
this._chat = await ((_a = this._client) === null || _a === void 0 ? void 0 : _a.getEntity(this._inputChat));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
await this._refetchChat();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return this._chat;
|
|
43
|
+
}
|
|
44
|
+
get inputChat() {
|
|
45
|
+
if (!this._inputChat && this._chatPeer && this._client) {
|
|
46
|
+
try {
|
|
47
|
+
this._inputChat = this._client._entityCache.get(__1.utils.getPeerId(this._chatPeer));
|
|
48
|
+
}
|
|
49
|
+
catch (e) { }
|
|
50
|
+
}
|
|
51
|
+
return this._inputChat;
|
|
52
|
+
}
|
|
53
|
+
async getInputChat() {
|
|
54
|
+
var e_1, _a;
|
|
55
|
+
if (!this.inputChat && this.chatId && this._client) {
|
|
56
|
+
try {
|
|
57
|
+
const target = this.chatId;
|
|
58
|
+
try {
|
|
59
|
+
for (var _b = __asyncValues(this._client.iterDialogs({
|
|
60
|
+
limit: 100,
|
|
61
|
+
})), _c; _c = await _b.next(), !_c.done;) {
|
|
62
|
+
const dialog = _c.value;
|
|
63
|
+
if (dialog.id.eq(target)) {
|
|
64
|
+
this._chat = dialog.entity;
|
|
65
|
+
this._inputChat = dialog.inputEntity;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
71
|
+
finally {
|
|
72
|
+
try {
|
|
73
|
+
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
|
74
|
+
}
|
|
75
|
+
finally { if (e_1) throw e_1.error; }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
// do nothing
|
|
80
|
+
}
|
|
81
|
+
return this._inputChat;
|
|
82
|
+
}
|
|
83
|
+
return this._inputChat;
|
|
84
|
+
}
|
|
85
|
+
get chatId() {
|
|
86
|
+
return this._chatPeer
|
|
87
|
+
? (0, Helpers_1.returnBigInt)(__1.utils.getPeerId(this._chatPeer))
|
|
88
|
+
: undefined;
|
|
89
|
+
}
|
|
90
|
+
get isPrivate() {
|
|
91
|
+
return this._chatPeer
|
|
92
|
+
? this._chatPeer instanceof api_1.Api.PeerUser
|
|
93
|
+
: undefined;
|
|
94
|
+
}
|
|
95
|
+
get isGroup() {
|
|
96
|
+
if (!this._broadcast && this.chat && "broadcast" in this.chat) {
|
|
97
|
+
this._broadcast = Boolean(this.chat.broadcast);
|
|
98
|
+
}
|
|
99
|
+
if (this._chatPeer instanceof api_1.Api.PeerChannel) {
|
|
100
|
+
if (this._broadcast === undefined) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return !this._broadcast;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return this._chatPeer instanceof api_1.Api.PeerChat;
|
|
108
|
+
}
|
|
109
|
+
get isChannel() {
|
|
110
|
+
return this._chatPeer instanceof api_1.Api.PeerChannel;
|
|
111
|
+
}
|
|
112
|
+
async _refetchChat() { }
|
|
113
|
+
}
|
|
114
|
+
exports.ChatGetter = ChatGetter;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { TelegramClient } from "../..";
|
|
3
|
+
import { Api } from "../api";
|
|
4
|
+
import type { Entity } from "../../define";
|
|
5
|
+
import { Draft } from "./draft";
|
|
6
|
+
import bigInt from "big-integer";
|
|
7
|
+
import { inspect } from "../../inspect";
|
|
8
|
+
export declare class Dialog {
|
|
9
|
+
_client: TelegramClient;
|
|
10
|
+
dialog: Api.Dialog;
|
|
11
|
+
pinned: boolean;
|
|
12
|
+
folderId?: number;
|
|
13
|
+
archived: boolean;
|
|
14
|
+
message?: Api.Message;
|
|
15
|
+
date: number;
|
|
16
|
+
entity?: Entity;
|
|
17
|
+
inputEntity: Api.TypeInputPeer;
|
|
18
|
+
id?: bigInt.BigInteger;
|
|
19
|
+
name?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
unreadCount: number;
|
|
22
|
+
unreadMentionsCount: number;
|
|
23
|
+
draft: Draft;
|
|
24
|
+
isUser: boolean;
|
|
25
|
+
isGroup: boolean;
|
|
26
|
+
isChannel: boolean;
|
|
27
|
+
[inspect.custom](): {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
constructor(client: TelegramClient, dialog: Api.Dialog, entities: Map<string, Entity>, message?: Api.Message);
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Dialog = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const Utils_1 = require("../../Utils");
|
|
6
|
+
const draft_1 = require("./draft");
|
|
7
|
+
const Helpers_1 = require("../../Helpers");
|
|
8
|
+
const inspect_1 = require("../../inspect");
|
|
9
|
+
class Dialog {
|
|
10
|
+
constructor(client, dialog, entities, message) {
|
|
11
|
+
this._client = client;
|
|
12
|
+
this.dialog = dialog;
|
|
13
|
+
this.pinned = !!dialog.pinned;
|
|
14
|
+
this.folderId = dialog.folderId;
|
|
15
|
+
this.archived = dialog.folderId != undefined;
|
|
16
|
+
this.message = message;
|
|
17
|
+
this.date = this.message.date;
|
|
18
|
+
this.entity = entities.get((0, Utils_1.getPeerId)(dialog.peer));
|
|
19
|
+
this.inputEntity = (0, Utils_1.getInputPeer)(this.entity);
|
|
20
|
+
if (this.entity) {
|
|
21
|
+
this.id = (0, Helpers_1.returnBigInt)((0, Utils_1.getPeerId)(this.entity)); // ^ May be InputPeerSelf();
|
|
22
|
+
this.name = this.title = (0, Utils_1.getDisplayName)(this.entity);
|
|
23
|
+
}
|
|
24
|
+
this.unreadCount = dialog.unreadCount;
|
|
25
|
+
this.unreadMentionsCount = dialog.unreadMentionsCount;
|
|
26
|
+
if (!this.entity) {
|
|
27
|
+
throw new Error("Entity not found for dialog");
|
|
28
|
+
}
|
|
29
|
+
this.draft = new draft_1.Draft(client, this.entity, this.dialog.draft);
|
|
30
|
+
this.isUser = this.entity instanceof api_1.Api.User;
|
|
31
|
+
this.isGroup = !!(this.entity instanceof api_1.Api.Chat ||
|
|
32
|
+
this.entity instanceof api_1.Api.ChatForbidden ||
|
|
33
|
+
(this.entity instanceof api_1.Api.Channel && this.entity.megagroup));
|
|
34
|
+
this.isChannel = this.entity instanceof api_1.Api.Channel;
|
|
35
|
+
}
|
|
36
|
+
[inspect_1.inspect.custom]() {
|
|
37
|
+
return (0, Helpers_1.betterConsoleLog)(this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Dialog = Dialog;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Entity } from "../../define";
|
|
3
|
+
import type { TelegramClient } from "../..";
|
|
4
|
+
import { Api } from "../api";
|
|
5
|
+
import { inspect } from "../../inspect";
|
|
6
|
+
export declare class Draft {
|
|
7
|
+
private _client;
|
|
8
|
+
private readonly _entity?;
|
|
9
|
+
private readonly _peer;
|
|
10
|
+
private _inputEntity;
|
|
11
|
+
private _text?;
|
|
12
|
+
private _rawText?;
|
|
13
|
+
private date?;
|
|
14
|
+
private linkPreview?;
|
|
15
|
+
private replyToMsgId?;
|
|
16
|
+
[inspect.custom](): {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
constructor(client: TelegramClient, entity: Entity, draft: Api.TypeDraftMessage | undefined);
|
|
20
|
+
get entity(): Entity | undefined;
|
|
21
|
+
get inputEntity(): Api.TypeInputPeer | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Draft = void 0;
|
|
4
|
+
const Utils_1 = require("../../Utils");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const Helpers_1 = require("../../Helpers");
|
|
7
|
+
const inspect_1 = require("../../inspect");
|
|
8
|
+
class Draft {
|
|
9
|
+
constructor(client, entity, draft) {
|
|
10
|
+
this._client = client;
|
|
11
|
+
this._peer = (0, Utils_1.getPeer)(entity);
|
|
12
|
+
this._entity = entity;
|
|
13
|
+
this._inputEntity = entity ? (0, Utils_1.getInputPeer)(entity) : undefined;
|
|
14
|
+
if (!draft || !(draft instanceof api_1.Api.DraftMessage)) {
|
|
15
|
+
draft = new api_1.Api.DraftMessage({
|
|
16
|
+
message: "",
|
|
17
|
+
date: -1,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (!(draft instanceof api_1.Api.DraftMessageEmpty)) {
|
|
21
|
+
this.linkPreview = !draft.noWebpage;
|
|
22
|
+
this._text = client.parseMode
|
|
23
|
+
? client.parseMode.unparse(draft.message, draft.entities || [])
|
|
24
|
+
: draft.message;
|
|
25
|
+
this._rawText = draft.message;
|
|
26
|
+
this.date = draft.date;
|
|
27
|
+
const replyTo = draft.replyTo;
|
|
28
|
+
if (replyTo != undefined) {
|
|
29
|
+
if ("replyToMsgId" in replyTo) {
|
|
30
|
+
this.replyToMsgId = replyTo.replyToMsgId;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
[inspect_1.inspect.custom]() {
|
|
36
|
+
return (0, Helpers_1.betterConsoleLog)(this);
|
|
37
|
+
}
|
|
38
|
+
get entity() {
|
|
39
|
+
return this._entity;
|
|
40
|
+
}
|
|
41
|
+
get inputEntity() {
|
|
42
|
+
if (!this._inputEntity) {
|
|
43
|
+
this._inputEntity = this._client._entityCache.get(this._peer);
|
|
44
|
+
}
|
|
45
|
+
return this._inputEntity;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Draft = Draft;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { FileLike } from "../../define";
|
|
3
|
+
import { inspect } from "../../inspect";
|
|
4
|
+
export declare class File {
|
|
5
|
+
private readonly media;
|
|
6
|
+
[inspect.custom](): {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
constructor(media: FileLike);
|
|
10
|
+
get id(): void;
|
|
11
|
+
get name(): any;
|
|
12
|
+
get mimeType(): string | undefined;
|
|
13
|
+
get width(): any;
|
|
14
|
+
get height(): any;
|
|
15
|
+
get duration(): any;
|
|
16
|
+
get title(): any;
|
|
17
|
+
get performer(): any;
|
|
18
|
+
get emoji(): any;
|
|
19
|
+
get stickerSet(): any;
|
|
20
|
+
get size(): number | import("big-integer").BigInteger | undefined;
|
|
21
|
+
_fromAttr(cls: any, field: string): any;
|
|
22
|
+
}
|