chore: i18n for packet log messages

This commit is contained in:
pk5ls20 2024-10-27 07:04:53 +08:00
parent fb09af0e64
commit 8e550e216e
No known key found for this signature in database
GPG Key ID: 6370ED7A169F493A
2 changed files with 8 additions and 8 deletions

View File

@ -49,7 +49,7 @@ export class NTQQPacketApi {
.then() .then()
.catch(this.core.context.logger.logError.bind(this.core.context.logger)); .catch(this.core.context.logger.logError.bind(this.core.context.logger));
} else { } else {
this.core.context.logger.logWarn('PacketServer is not set, will not init NapCat.Packet!'); this.core.context.logger.logWarn('PacketServer未配置NapCat.Packet将不会加载');
} }
} }
@ -158,10 +158,10 @@ export class NTQQPacketApi {
} }
} }
const res = await Promise.allSettled(reqList); const res = await Promise.allSettled(reqList);
this.logger.log(`上传资源${res.length}个, 失败${res.filter(r => r.status === 'rejected').length}`); this.logger.log(`上传资源${res.length}个,失败${res.filter(r => r.status === 'rejected').length}`);
res.forEach((result, index) => { res.forEach((result, index) => {
if (result.status === 'rejected') { if (result.status === 'rejected') {
this.logger.logError(`${index + 1}失败:${result.reason}`); this.logger.logError(`上传${index + 1}资源失败:${result.reason}`);
} }
}); });
} }

View File

@ -55,7 +55,7 @@ export class PacketClient {
this.websocket.onopen = () => { this.websocket.onopen = () => {
this.isConnected = true; this.isConnected = true;
this.reconnectAttempts = 0; this.reconnectAttempts = 0;
this.logger.log.bind(this.logger)(`[Core] [Packet Server] Connected to ${this.clientUrl}`); this.logger.log.bind(this.logger)(`[Core] [Packet Server] 已连接到 ${this.clientUrl}`);
cb(); cb();
resolve(); resolve();
}; };
@ -85,14 +85,14 @@ export class PacketClient {
this.reconnectAttempts++; this.reconnectAttempts++;
setTimeout(() => { setTimeout(() => {
this.connect(cb).catch((error) => { this.connect(cb).catch((error) => {
this.logger.logError.bind(this.logger)(`[Core] [Packet Server] Reconnecting attempt failed,${error.message}`); this.logger.logError.bind(this.logger)(`[Core] [Packet Server] 尝试重连失败:${error.message}`);
}); });
}, 5000 * this.reconnectAttempts); }, 5000 * this.reconnectAttempts);
} else { } else {
this.logger.logError.bind(this.logger)(`[Core] [Packet Server] Max reconnect attempts reached. ${this.clientUrl}`); this.logger.logError.bind(this.logger)(`[Core] [Packet Server] ${this.clientUrl} 已达到最大重连次数!`);
} }
} catch (error: any) { } catch (error: any) {
this.logger.logError.bind(this.logger)(`Error attempting to reconnect: ${error.message}`); this.logger.logError.bind(this.logger)(`[Core] [Packet Server] 重连时出错: ${error.message}`);
} }
} }
@ -165,7 +165,7 @@ export class PacketClient {
// 校验失败和异常 可能返回undefined // 校验失败和异常 可能返回undefined
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!this.available) { if (!this.available) {
this.logger.logError('NapCat.Packet is not init'); this.logger.logError('NapCat.Packet 未初始化!');
return undefined; return undefined;
} }
const md5 = crypto.createHash('md5').update(data).digest('hex'); const md5 = crypto.createHash('md5').update(data).digest('hex');