mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-11 23:40:24 +00:00
Refactor PacketApi status checks and fix typos
Replaced all usages of PacketApi.available with PacketApi.packetStatus for more accurate status checking. Fixed a typo in getFullQQVesion to getFullQQVersion. Updated plugin_onmessage to fetch and parse messages for a user. These changes improve reliability and consistency in API status handling.
This commit is contained in:
@@ -130,7 +130,7 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
);
|
||||
|
||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
const packetMode = this.core.apis.PacketApi.available;
|
||||
const packetMode = this.core.apis.PacketApi.packetStatus;
|
||||
let returnMsgAndResId: { message: RawMessage | null, res_id?: string } | null;
|
||||
try {
|
||||
returnMsgAndResId = packetMode
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
|
||||
export abstract class GetPacketStatusDepends<PT, RT> extends OneBotAction<PT, RT> {
|
||||
protected override async check(payload: PT): Promise<BaseCheckResult>{
|
||||
if (!this.core.apis.PacketApi.available) {
|
||||
if (!this.core.apis.PacketApi.packetStatus) {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'packetBackend不可用,请参照文档 https://napneko.github.io/config/advanced 和启动日志检查packetBackend状态或进行配置!' +
|
||||
|
||||
@@ -147,7 +147,7 @@ export class OneBotMsgApi {
|
||||
};
|
||||
FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileUuid, element.fileUuid);
|
||||
FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileUuid, element.fileName);
|
||||
if (this.core.apis.PacketApi.available) {
|
||||
if (this.core.apis.PacketApi.packetStatus) {
|
||||
let url;
|
||||
try {
|
||||
url = await this.core.apis.FileApi.getFileUrl(msg.chatType, msg.peerUid, element.fileUuid, element.file10MMd5)
|
||||
@@ -391,7 +391,7 @@ export class OneBotMsgApi {
|
||||
|
||||
//开始兜底
|
||||
if (!videoDownUrl) {
|
||||
if (this.core.apis.PacketApi.available) {
|
||||
if (this.core.apis.PacketApi.packetStatus) {
|
||||
try {
|
||||
videoDownUrl = await this.core.apis.FileApi.getVideoUrlPacket(msg.peerUid, element.fileUuid);
|
||||
} catch (e) {
|
||||
@@ -422,7 +422,7 @@ export class OneBotMsgApi {
|
||||
};
|
||||
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, '', element.fileName);
|
||||
let pttUrl = '';
|
||||
if (this.core.apis.PacketApi.available) {
|
||||
if (this.core.apis.PacketApi.packetStatus) {
|
||||
try {
|
||||
pttUrl = await this.core.apis.FileApi.getPttUrl(msg.peerUid, element.fileUuid);
|
||||
} catch (e) {
|
||||
|
||||
@@ -170,7 +170,7 @@ export class NapCatOneBot11Adapter {
|
||||
this.initBuddyListener();
|
||||
this.initGroupListener();
|
||||
|
||||
WebUiDataRuntime.setQQVersion(this.core.context.basicInfoWrapper.getFullQQVesion());
|
||||
WebUiDataRuntime.setQQVersion(this.core.context.basicInfoWrapper.getFullQQVersion());
|
||||
WebUiDataRuntime.setQQLoginInfo(selfInfo);
|
||||
WebUiDataRuntime.setQQLoginStatus(true);
|
||||
WebUiDataRuntime.setOnOB11ConfigChanged(async (newConfig) => {
|
||||
|
||||
Reference in New Issue
Block a user