mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
refactor: inline getApiContext()
This commit is contained in:
@@ -18,7 +18,7 @@ export class CreateCollection extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
return await this.CoreContext.getApiContext().CollectionApi.createCollection(
|
||||
return await this.CoreContext.apis.CollectionApi.createCollection(
|
||||
this.CoreContext.selfInfo.uin,
|
||||
this.CoreContext.selfInfo.uid,
|
||||
this.CoreContext.selfInfo.nick,
|
||||
|
||||
@@ -17,7 +17,7 @@ export class FetchCustomFace extends BaseAction<Payload, string[]> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
//48 可能正好是QQ需要的一个页面的数量 Tagged Mlikiowa
|
||||
const ret = await this.CoreContext.getApiContext().MsgApi.fetchFavEmojiList(payload.count || 48);
|
||||
const ret = await this.CoreContext.apis.MsgApi.fetchFavEmojiList(payload.count || 48);
|
||||
return ret.emojiInfoList.map(e => e.url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export class FetchEmojiLike extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
||||
if (!msgIdPeer) throw new Error('消息不存在');
|
||||
const msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
||||
|
||||
@@ -18,7 +18,7 @@ export class GetCollectionList extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQCollectionApi = this.CoreContext.getApiContext().CollectionApi;
|
||||
const NTQQCollectionApi = this.CoreContext.apis.CollectionApi;
|
||||
return await NTQQCollectionApi.getAllCollection(payload.category, payload.count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
async _handle(payload: void) {
|
||||
if (this.CoreContext.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
|
||||
//全新逻辑
|
||||
return OB11Constructor.friendsV2(await this.CoreContext.getApiContext().FriendApi.getBuddyV2ExWithCate(true));
|
||||
return OB11Constructor.friendsV2(await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true));
|
||||
} else {
|
||||
throw new Error('this ntqq version not support, must be 26702 or later');
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class GetGroupAddRequest extends BaseAction<null, OB11GroupReques
|
||||
actionName = ActionName.GetGroupIgnoreAddRequest;
|
||||
|
||||
async _handle(payload: null): Promise<OB11GroupRequestNotify[] | null> {
|
||||
const data = await this.CoreContext.getApiContext().GroupApi.getGroupIgnoreNotifies();
|
||||
const data = await this.CoreContext.apis.GroupApi.getGroupIgnoreNotifies();
|
||||
// log(data);
|
||||
// const notifies: GroupNotify[] = data.notifies.filter(notify => notify.status === GroupNotifyStatus.WAIT_HANDLE);
|
||||
// const returnData: OB11GroupRequestNotify[] = [];
|
||||
|
||||
@@ -5,7 +5,7 @@ export class GetProfileLike extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetProfileLike;
|
||||
|
||||
async _handle(payload: void) {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const ret = await NTQQUserApi.getProfileLike(this.CoreContext.selfInfo.uid);
|
||||
const listdata: any[] = ret.info.userLikeInfos[0].favoriteInfo.userInfos;
|
||||
for (let i = 0; i < listdata.length; i++) {
|
||||
|
||||
@@ -6,7 +6,7 @@ export class GetRobotUinRange extends BaseAction<void, Array<any>> {
|
||||
|
||||
async _handle(payload: void) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange());
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
return await NTQQUserApi.getRobotUinRange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class OCRImage extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQSystemApi = this.CoreContext.getApiContext().SystemApi;
|
||||
const NTQQSystemApi = this.CoreContext.apis.SystemApi;
|
||||
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.image));
|
||||
if (!success) {
|
||||
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
||||
|
||||
@@ -27,7 +27,7 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
||||
}
|
||||
|
||||
async _handle(payload: Payload): Promise<any> {
|
||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.file));
|
||||
if (!success) {
|
||||
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
||||
|
||||
@@ -17,7 +17,7 @@ export class SetLongNick extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const ret = await NTQQUserApi.setLongNick(payload.longNick);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class SetOnlineStatus extends BaseAction<Payload, null> {
|
||||
// { status: 50, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 60, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 70, extStatus: 0, batteryStatus: 0 }
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const ret = await NTQQUserApi.setSelfOnlineStatus(payload.status, payload.extStatus, payload.batteryStatus);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('设置在线状态失败');
|
||||
|
||||
@@ -24,7 +24,7 @@ export default class SetAvatar extends BaseAction<Payload, null> {
|
||||
}
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const { path, isLocal, errMsg, success } = (await uri2local(this.CoreContext.NapCatTempPath, payload.file));
|
||||
if (!success) {
|
||||
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
||||
|
||||
@@ -19,7 +19,7 @@ export class SetSelfProfile extends BaseAction<Payload, any | null> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const ret = await NTQQUserApi.modifySelfProfile({
|
||||
nick: payload.nick,
|
||||
longNick: payload.longNick,
|
||||
|
||||
@@ -19,8 +19,8 @@ export class SharePeer extends BaseAction<Payload, any> {
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
|
||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||
if (payload.group_id) {
|
||||
return await NTQQGroupApi.getGroupRecommendContactArkJson(payload.group_id);
|
||||
} else if (payload.user_id) {
|
||||
@@ -44,7 +44,7 @@ export class ShareGroupEx extends BaseAction<PayloadGroupEx, any> {
|
||||
PayloadSchema = SchemaDataGroupEx;
|
||||
|
||||
async _handle(payload: PayloadGroupEx) {
|
||||
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
|
||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||
return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class TranslateEnWordToZn extends BaseAction<Payload, Array<any> | null>
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQSystemApi = this.CoreContext.getApiContext().SystemApi;
|
||||
const NTQQSystemApi = this.CoreContext.apis.SystemApi;
|
||||
const ret = await NTQQSystemApi.translateEnWordToZn(payload.words);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('翻译失败');
|
||||
|
||||
Reference in New Issue
Block a user