mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
refactor: get friends, get groups, get group members, get group member
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { GroupNotify, GroupNotifyStatus } from '@/core/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { uid2UinMap } from '@/common/data';
|
||||
import { uid2UinMap } from '@/core/data';
|
||||
import { NTQQUserApi } from '@/core/apis/user';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { friends } from '../../../common/data';
|
||||
import { friends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQUserApi } from '@/core/apis';
|
||||
export class GetRobotUinRange extends BaseAction<void, Array<any>> {
|
||||
actionName = ActionName.GetRobotUinRange;
|
||||
actionName = ActionName.GetRobotUinRange;
|
||||
|
||||
protected async _handle(payload: void) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange());
|
||||
return await NTQQUserApi.getRobotUinRange();
|
||||
}
|
||||
protected async _handle(payload: void) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange());
|
||||
return await NTQQUserApi.getRobotUinRange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { friends } from '../../../common/data';
|
||||
import { friends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQUserApi } from '@/core/apis';
|
||||
@@ -11,19 +11,19 @@ interface Payload {
|
||||
batteryStatus: number;
|
||||
}
|
||||
export class SetOnlineStatus extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.SetOnlineStatus;
|
||||
actionName = ActionName.SetOnlineStatus;
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
// 可设置状态
|
||||
// { status: 10, extStatus: 1027, batteryStatus: 0 }
|
||||
// { status: 30, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 50, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 60, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 70, extStatus: 0, batteryStatus: 0 }
|
||||
let ret = await NTQQUserApi.setSelfOnlineStatus(payload.status, payload.extStatus, payload.batteryStatus);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error("设置在线状态失败");
|
||||
}
|
||||
return null;
|
||||
protected async _handle(payload: Payload) {
|
||||
// 可设置状态
|
||||
// { status: 10, extStatus: 1027, batteryStatus: 0 }
|
||||
// { status: 30, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 50, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 60, extStatus: 0, batteryStatus: 0 }
|
||||
// { status: 70, extStatus: 0, batteryStatus: 0 }
|
||||
const ret = await NTQQUserApi.setSelfOnlineStatus(payload.status, payload.extStatus, payload.batteryStatus);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('设置在线状态失败');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Message, OB11User } from '../../types';
|
||||
import { getFriend, friends, uid2UinMap, getUidByUin } from '@/common/data';
|
||||
import { getFriend, friends, uid2UinMap, getUidByUin } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType } from '@/core/entities';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Message, OB11User } from '../../types';
|
||||
import { getGroup, groups } from '@/common/data';
|
||||
import { getGroup, groups } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType } from '@/core/entities';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11User } from '../../types';
|
||||
import { getUidByUin, uid2UinMap } from '@/common/data';
|
||||
import { getUidByUin, uid2UinMap } from '@/core/data';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQUserApi } from '@/core/apis/user';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroup } from '@/common/data';
|
||||
import { getGroup } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { SendMsgElementConstructor } from '@/core/entities/constructor';
|
||||
import { ChatType, SendFileElement } from '@/core/entities';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getGroup } from '@/common/data';
|
||||
import { getGroup } from '@/core/data';
|
||||
import { OB11Group } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { OB11Group } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { groups } from '@/common/data';
|
||||
import { groups } from '@/core/data';
|
||||
import { NTQQGroupApi } from '@/core/apis';
|
||||
import { Group } from '@/core/entities';
|
||||
import { log } from '@/common/utils/log';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11GroupMember } from '../../types';
|
||||
import { getGroupMember } from '@/common/data';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { getGroup } from '@/common/data';
|
||||
import { getGroup } from '@/core/data';
|
||||
import { OB11GroupMember } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { napCatCore } from '@/core';
|
||||
import { napCatCore, NTQQGroupApi } from '@/core';
|
||||
import { WebApi } from '@/core/apis/webapi';
|
||||
import { logDebug } from '@/common/utils/log';
|
||||
|
||||
export interface PayloadType {
|
||||
group_id: number
|
||||
@@ -15,7 +16,8 @@ class GetGroupMemberList extends BaseAction<PayloadType, OB11GroupMember[]> {
|
||||
actionName = ActionName.GetGroupMemberList;
|
||||
|
||||
protected async _handle(payload: PayloadType) {
|
||||
console.log(await WebApi.getGroupMember(payload.group_id.toString()));
|
||||
// logDebug(await WebApi.getGroupMembers(payload.group_id.toString()));
|
||||
// await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||
const group = await getGroup(payload.group_id.toString());
|
||||
if (group) {
|
||||
return OB11Constructor.groupMembers(group);
|
||||
|
||||
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { GroupRequestOperateTypes } from '@/core/entities';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
import { groupNotifies } from '@/common/data';
|
||||
import { groupNotifies } from '@/core/data';
|
||||
|
||||
interface Payload {
|
||||
flag: string,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroupMember } from '@/common/data';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { GroupMemberRole } from '@/core/entities';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroupMember } from '@/common/data';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroupMember } from '@/common/data';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroupMember } from '@/common/data';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ChatType, Peer } from '@/core/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { getFriend, getUidByUin } from '@/common/data';
|
||||
import { getFriend, getUidByUin } from '@/core/data';
|
||||
|
||||
interface Payload {
|
||||
user_id: number;
|
||||
|
||||
@@ -26,7 +26,7 @@ import { dbUtil } from '@/common/utils/db';
|
||||
import { log, logDebug, logError } from '@/common/utils/log';
|
||||
import { sleep } from '@/common/utils/helper';
|
||||
import { uri2local } from '@/common/utils/file';
|
||||
import { getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '@/common/data';
|
||||
import { getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '@/core/data';
|
||||
import { NTQQMsgApi } from '../../../core/src/apis';
|
||||
import { NTQQFileApi } from '../../../core/src/apis';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Status } from '../../types';
|
||||
import { ActionName } from '../types';
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
|
||||
|
||||
export default class GetStatus extends BaseAction<any, OB11Status> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { friends } from '../../../common/data';
|
||||
import { friends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQUserApi } from '@/core/apis';
|
||||
@@ -15,7 +15,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
||||
actionName = ActionName.GetCookies;
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
let _Skey = await NTQQUserApi.getSkey();
|
||||
const _Skey = await NTQQUserApi.getSkey();
|
||||
// 取Skey
|
||||
// 先NodeIKernelTicketService.forceFetchClientKey('')
|
||||
// 返回值
|
||||
@@ -29,7 +29,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
||||
// }
|
||||
// request https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=1627126029&clientkey=key
|
||||
// &u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=keyIndex
|
||||
let _PSkey = await NTQQUserApi.getPSkey([payload.domain]);
|
||||
const _PSkey = await NTQQUserApi.getPSkey([payload.domain]);
|
||||
// 取Pskey
|
||||
// NodeIKernelTipOffService.getPskey([ 'qun.qq.com' ], true )
|
||||
// {
|
||||
@@ -40,7 +40,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
||||
// }
|
||||
// }
|
||||
if (!_PSkey || !_Skey) {
|
||||
throw new Error("获取Cookies失败");
|
||||
throw new Error('获取Cookies失败');
|
||||
}
|
||||
return { Pskey: _PSkey, Skey: _Skey };
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { friends } from '../../../common/data';
|
||||
import { friends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NTQQUserApi } from '@/core/apis';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getFriend, getUidByUin, uid2UinMap } from '@/common/data';
|
||||
import { getFriend, getUidByUin, uid2UinMap } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { log, logDebug } from '@/common/utils/log';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQFriendApi } from '@/core/apis/friend';
|
||||
import { friendRequests } from '@/common/data';
|
||||
import { friendRequests } from '@/core/data';
|
||||
|
||||
interface Payload {
|
||||
flag: string,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { logDebug, logError } from '@/common/utils/log';
|
||||
import { ConfigBase } from '@/common/utils/ConfigBase';
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent';
|
||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent';
|
||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/common/data';
|
||||
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '../core/src/apis';
|
||||
import http from 'http';
|
||||
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
|
||||
export enum EventType {
|
||||
META = 'meta_event',
|
||||
@@ -13,4 +13,4 @@ export abstract class OB11BaseEvent {
|
||||
time = Math.floor(Date.now() / 1000);
|
||||
self_id = parseInt(selfInfo.uin);
|
||||
post_type: EventType = EventType.META;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
import { selfInfo } from '../../../common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { OB11BaseEvent } from '../OB11BaseEvent';
|
||||
|
||||
class OB11PokeEvent extends OB11BaseNoticeEvent{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OB11Message } from '@/onebot11/types';
|
||||
import { log } from '@/common/utils/log';
|
||||
import { getGroup, getGroupMember } from '@/common/data';
|
||||
import { getGroup, getGroupMember } from '@/core/data';
|
||||
import exp from 'constants';
|
||||
|
||||
export async function logMessage(ob11Message: OB11Message){
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ob11Config } from '@/onebot11/config';
|
||||
import { httpHeart, ob11HTTPServer } from '@/onebot11/server/http';
|
||||
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
||||
import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
||||
import { friendRequests, getFriend, getGroup, getGroupMember, groupNotifies, selfInfo } from '@/common/data';
|
||||
import { friendRequests, getFriend, getGroup, getGroupMember, groupNotifies, selfInfo } from '@/core/data';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '../core/src/listeners';
|
||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { OB11Response } from '../action/OB11Response';
|
||||
import { HttpServerBase } from '@/common/server/http';
|
||||
import { actionHandlers, actionMap } from '../action';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { OB11HeartbeatEvent } from '@/onebot11/event/meta/OB11HeartbeatEvent';
|
||||
import { postOB11Event } from '@/onebot11/server/postOB11Event';
|
||||
import { napCatCore } from '@/core';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { OB11FriendRequestEvent } from '../event/request/OB11FriendRequest';
|
||||
import { OB11GroupRequestEvent } from '../event/request/OB11GroupRequest';
|
||||
import { isNull } from '@/common/utils/helper';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { friendRequests, getGroup, groupNotifies, selfInfo } from '@/common/data';
|
||||
import { friendRequests, getGroup, groupNotifies, selfInfo } from '@/core/data';
|
||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi } from '../../core/src/apis';
|
||||
import { logMessage, logNotice, logRequest } from '@/onebot11/log';
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { OB11HeartbeatEvent } from '../../event/meta/OB11HeartbeatEvent';
|
||||
import { log, logDebug, logError } from '../../../common/utils/log';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { napCatCore } from '@/core';
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
|
||||
export const rwsList: ReverseWebsocket[] = [];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { wsReply } from './reply';
|
||||
import { napCatCore } from '@/core';
|
||||
import { log, logDebug, logError } from '../../../common/utils/log';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { selfInfo } from '@/common/data';
|
||||
import { selfInfo } from '@/core/data';
|
||||
|
||||
const heartbeatRunning = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user