perf: 使用 websocket 连接

This commit is contained in:
Clansty 2023-11-08 15:50:41 +08:00
parent a5b885273d
commit fe69be6211
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,8 @@ import TelegramSession from '../models/TelegramSession';
import { LogLevel } from 'telegram/extensions/Logger';
import { BigInteger } from 'big-integer';
import { IterMessagesParams } from 'telegram/client/messages';
import { PromisedWebSockets } from 'telegram/extensions';
import { ConnectionTCPObfuscated } from 'telegram/network';
type MessageHandler = (message: Api.Message) => Promise<boolean | void>;
type ServiceMessageHandler = (message: Api.MessageService) => Promise<boolean | void>;
@ -52,9 +54,12 @@ export default class Telegram {
ip: process.env.PROXY_IP,
port: parseInt(process.env.PROXY_PORT),
} : undefined,
autoReconnect: true,
networkSocket: PromisedWebSockets,
connection: ConnectionTCPObfuscated,
},
);
this.client.logger.setLevel(LogLevel.WARN);
// this.client.logger.setLevel(LogLevel.WARN);
}
public static async create(startArgs: UserAuthParams | BotAuthParams, appName = 'Q2TG') {