Skip to content

Commit

Permalink
perf: 支持指定初始 DC
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 8, 2023
1 parent a087582 commit dc67447
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/models/TelegramSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dc67447

Please sign in to comment.