mirror of https://github.com/Nofated095/Q2TG.git
perf: 支持指定初始 DC
This commit is contained in:
parent
a087582979
commit
dc6744731c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue