Skip to content

Commit

Permalink
perf: 通过环境变量设置 websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 8, 2023
1 parent 7ba8e91 commit 4987b15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ COPY prisma /app/
RUN pnpm exec prisma generate
COPY --from=build /app/build /app/build

ENV TG_CONNECTION=websocket
ENV DATA_DIR=/app/data
CMD pnpm start
8 changes: 4 additions & 4 deletions src/client/Telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +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';
import { PromisedNetSockets, PromisedWebSockets } from 'telegram/extensions';
import { ConnectionTCPFull, ConnectionTCPObfuscated } from 'telegram/network';

type MessageHandler = (message: Api.Message) => Promise<boolean | void>;
type ServiceMessageHandler = (message: Api.MessageService) => Promise<boolean | void>;
Expand Down Expand Up @@ -55,8 +55,8 @@ export default class Telegram {
port: parseInt(process.env.PROXY_PORT),
} : undefined,
autoReconnect: true,
networkSocket: PromisedWebSockets,
connection: ConnectionTCPObfuscated,
networkSocket: process.env.TG_CONNECTION === 'websocket' ? PromisedWebSockets : PromisedNetSockets,
connection: process.env.TG_CONNECTION === 'websocket' ? ConnectionTCPObfuscated : ConnectionTCPFull,
},
);
// this.client.logger.setLevel(LogLevel.WARN);
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/SetupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { WorkMode } from '../types/definitions';
import OicqClient from '../client/OicqClient';
import { md5Hex } from '../utils/hashing';
import Instance from '../models/Instance';
import db from '../models/db';
import { CustomFile } from 'telegram/client/uploads';

export default class SetupController {
private readonly setupService: SetupService;
Expand Down

0 comments on commit 4987b15

Please sign in to comment.