feat: More user-friendly packetServer error message

This commit is contained in:
pk5ls20 2024-10-20 07:28:55 +08:00
parent 31c4540ec6
commit 16a2e5e996
No known key found for this signature in database
GPG Key ID: 6370ED7A169F493A
3 changed files with 5 additions and 8 deletions

View File

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

View File

@ -1,6 +1,6 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import {GetPacketStatusDepends} from "@/onebot/action/packet/GetPacketStatus";
// no_cache get时传字符串
const SchemaData = {
type: 'object',
@ -12,14 +12,11 @@ const 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;
payloadSchema = SchemaData;
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);
}
}

View File

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