mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
chore: 所有扩展接口就绪
This commit is contained in:
parent
4eed603d36
commit
dfb31b78d9
@ -8,7 +8,7 @@ import { MsgListener, ProfileListener } from "./listeners";
|
|||||||
import { sleep } from "@/common/utils/helper";
|
import { sleep } from "@/common/utils/helper";
|
||||||
import { SelfInfo, LineDevice, SelfStatusInfo } from "./entities";
|
import { SelfInfo, LineDevice, SelfStatusInfo } from "./entities";
|
||||||
import { LegacyNTEventWrapper } from "@/common/framework/event-legacy";
|
import { LegacyNTEventWrapper } from "@/common/framework/event-legacy";
|
||||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQWebApi } from "./apis";
|
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from "./apis";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import { NTQQCollectionApi } from "./apis/collection";
|
import { NTQQCollectionApi } from "./apis/collection";
|
||||||
export enum NapCatCoreWorkingEnv {
|
export enum NapCatCoreWorkingEnv {
|
||||||
@ -43,6 +43,7 @@ export class NapCatCore {
|
|||||||
this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session);
|
this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session);
|
||||||
this.initNapCatCoreListeners().then().catch(console.error);
|
this.initNapCatCoreListeners().then().catch(console.error);
|
||||||
this.ApiContext = {
|
this.ApiContext = {
|
||||||
|
SystemApi:new NTQQSystemApi(this.context, this),
|
||||||
CollectionApi:new NTQQCollectionApi(this.context, this),
|
CollectionApi:new NTQQCollectionApi(this.context, this),
|
||||||
WebApi: new NTQQWebApi(this.context, this),
|
WebApi: new NTQQWebApi(this.context, this),
|
||||||
FriendApi: new NTQQFriendApi(this.context, this),
|
FriendApi: new NTQQFriendApi(this.context, this),
|
||||||
|
@ -4,7 +4,7 @@ import { NapCatCoreWorkingEnv } from "@/core";
|
|||||||
import { SelfInfo } from "../entities";
|
import { SelfInfo } from "../entities";
|
||||||
import { NodeIKernelLoginService } from "../services";
|
import { NodeIKernelLoginService } from "../services";
|
||||||
import { WrapperNodeApi, NodeIQQNTWrapperSession } from "@/core";
|
import { WrapperNodeApi, NodeIQQNTWrapperSession } from "@/core";
|
||||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQWebApi } from "../apis";
|
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from "../apis";
|
||||||
import { NTQQCollectionApi } from "../apis/collection";
|
import { NTQQCollectionApi } from "../apis/collection";
|
||||||
|
|
||||||
export interface InstanceContext {
|
export interface InstanceContext {
|
||||||
@ -16,6 +16,7 @@ export interface InstanceContext {
|
|||||||
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
||||||
}
|
}
|
||||||
export interface NTApiContext {
|
export interface NTApiContext {
|
||||||
|
SystemApi: NTQQSystemApi,
|
||||||
CollectionApi: NTQQCollectionApi,
|
CollectionApi: NTQQCollectionApi,
|
||||||
WebApi: NTQQWebApi,
|
WebApi: NTQQWebApi,
|
||||||
FriendApi: NTQQFriendApi,
|
FriendApi: NTQQFriendApi,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQMsgApi } from '@/core/apis';
|
|
||||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -18,7 +18,8 @@ export class OCRImage extends BaseAction<Payload, any> {
|
|||||||
actionName = ActionName.OCRImage;
|
actionName = ActionName.OCRImage;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
const { path, isLocal, errMsg,success } = (await uri2local(payload.image));
|
const NTQQSystemApi = this.CoreContext.getApiContext().SystemApi;
|
||||||
|
const { path, isLocal, errMsg,success } = (await uri2local(this.CoreContext.NapCatTempPath,payload.image));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
|||||||
}
|
}
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||||
const { path, isLocal, errMsg,success } = (await uri2local(payload.file));
|
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.file));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||||
const ret = await NTQQGroupApi.setGroupAvatar(payload.groupCode,path);
|
const ret = await NTQQGroupApi.setGroupAvatar(payload.groupCode, path);
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
fs.unlink(path, () => { });
|
fs.unlink(path, () => { });
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName, BaseCheckResult } from '../types';
|
import { ActionName, BaseCheckResult } from '../types';
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { NTQQUserApi } from '@/core/apis/user';
|
|
||||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||||
// import { log } from "../../../common/utils";
|
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
file: string
|
file: string
|
||||||
}
|
}
|
||||||
@ -25,7 +22,7 @@ export default class SetAvatar extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||||
const { path, isLocal, errMsg,success } = (await uri2local(payload.file));
|
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.file));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQUserApi } from '@/core/apis';
|
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
|
@ -20,7 +20,7 @@ export class TranslateEnWordToZn extends BaseAction<Payload, Array<any> | null>
|
|||||||
actionName = ActionName.TranslateEnWordToZn;
|
actionName = ActionName.TranslateEnWordToZn;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
|
const NTQQSystemApi = this.CoreContext.getApiContext().SystemApi;
|
||||||
const ret = await NTQQSystemApi.translateEnWordToZn(payload.words);
|
const ret = await NTQQSystemApi.translateEnWordToZn(payload.words);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('翻译失败');
|
throw new Error('翻译失败');
|
||||||
|
@ -40,7 +40,6 @@ export class shareGroupEx extends BaseAction<PayloadGroupEx, any> {
|
|||||||
actionName = ActionName.ShareGroupEx;
|
actionName = ActionName.ShareGroupEx;
|
||||||
PayloadSchema = SchemaDataGroupEx;
|
PayloadSchema = SchemaDataGroupEx;
|
||||||
protected async _handle(payload: PayloadGroupEx) {
|
protected async _handle(payload: PayloadGroupEx) {
|
||||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
|
||||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||||
return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id);
|
return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user