Merge pull request #443 from pk5ls20/feat/i18n-packet-server-error-msg

feat: More user-friendly packetServer error message
This commit is contained in:
手瓜一十雪 2024-10-20 08:14:33 +08:00 committed by GitHub
commit 43f1d8c88c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 8 deletions

View File

@ -49,8 +49,8 @@ export class PacketHighwaySession {
private async checkAvailable() { private async checkAvailable() {
if (!this.packetClient.available) { if (!this.packetClient.available) {
this.logger.logError('[Highway] packetClient not available!'); this.logger.logError('[Highway] packetServer not available!');
throw new Error('packetClient not available!'); throw new Error('packetServer不可用请参照文档 https://napneko.github.io/config/advanced 检查packetServer状态或进行配置');
} }
if (this.sig.sigSession === null || this.sig.sessionKey === null) { if (this.sig.sigSession === null || this.sig.sessionKey === null) {
this.logger.logWarn('[Highway] sigSession or sessionKey not available!'); this.logger.logWarn('[Highway] sigSession or sessionKey not available!');

View File

@ -1,6 +1,6 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import {GetPacketStatusDepends} from "@/onebot/action/packet/GetPacketStatus";
// no_cache get时传字符串 // no_cache get时传字符串
const SchemaData = { const SchemaData = {
type: 'object', type: 'object',
@ -12,14 +12,11 @@ const SchemaData = {
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
export class GetUserStatus extends BaseAction<Payload, { status: number; ext_status: number; } | undefined> { export class GetUserStatus extends GetPacketStatusDepends<Payload, { status: number; ext_status: number; } | undefined> {
actionName = ActionName.GetUserStatus; actionName = ActionName.GetUserStatus;
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {
if (!this.core.apis.PacketApi?.available) {
throw new Error('PacketClient is not init');
}
return await this.core.apis.PacketApi.sendStatusPacket(+payload.user_id); return await this.core.apis.PacketApi.sendStatusPacket(+payload.user_id);
} }
} }

View File

@ -9,7 +9,7 @@ export abstract class GetPacketStatusDepends<PT, RT> extends BaseAction<PT, RT>
if (!this.core.apis.PacketApi.available) { if (!this.core.apis.PacketApi.available) {
return { return {
valid: false, valid: false,
message: "PacketClient is not available!", message: "packetServer不可用请参照文档 https://napneko.github.io/config/advanced 检查packetServer状态或进行配置",
} }
} }
return { return {