From dc6744731c761bf88ac75f2c316ccfcbe6815ec1 Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 8 Nov 2023 16:43:32 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=20DC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/TelegramSession.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/models/TelegramSession.ts b/src/models/TelegramSession.ts index 8628d47a..8ed78a3a 100644 --- a/src/models/TelegramSession.ts +++ b/src/models/TelegramSession.ts @@ -19,10 +19,21 @@ export default class TelegramSession extends MemorySession { async load() { this.log.trace('load'); + if (process.env.TG_INITIAL_DCID) { + this._dcId = Number(process.env.TG_INITIAL_DCID); + } + if (process.env.TG_INITIAL_SERVER) { + this._serverAddress = process.env.TG_INITIAL_SERVER; + } if (!this._dbId) { this.log.debug('Session 不存在,创建'); // 创建并返回 - const newDbEntry = await db.session.create({ data: {} }); + const newDbEntry = await db.session.create({ + data: { + dcId: process.env.TG_INITIAL_DCID ? Number(process.env.TG_INITIAL_DCID) : null, + serverAddress: process.env.TG_INITIAL_SERVER, + }, + }); this._dbId = newDbEntry.id; this.log = getLogger(`TelegramSession - ${this._dbId}`); return;