mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
chore: ntapi
This commit is contained in:
parent
52ab93013c
commit
958709faf2
@ -1,30 +1,33 @@
|
|||||||
import { FriendRequest, FriendV2, SimpleInfo, User } from '@/core/entities';
|
import { FriendV2, User } from '@/core/entities';
|
||||||
import { BuddyListReqType, napCatCore, NodeIKernelBuddyListener, NodeIKernelProfileService, OnBuddyChangeParams } from '@/core';
|
import { BuddyListReqType, InstanceContext, NapCatCore, NodeIKernelProfileService, OnBuddyChangeParams } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
|
||||||
import { LimitedHashTable } from '@/common/utils/MessageUnique';
|
import { LimitedHashTable } from '@/common/utils/MessageUnique';
|
||||||
import { CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
|
context: InstanceContext;
|
||||||
|
core: NapCatCore;
|
||||||
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
|
this.context = context;
|
||||||
|
this.core = core;
|
||||||
|
}
|
||||||
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
let uids: string[] = [];
|
let uids: string[] = [];
|
||||||
const buddyService = napCatCore.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
);
|
);
|
||||||
return Array.from(data.values());
|
return Array.from(data.values());
|
||||||
}
|
}
|
||||||
@CacheClassFuncAsyncExtend(3600 * 1000, 'getBuddyIdMap', () => true)
|
|
||||||
async getBuddyIdMapCache(refresh = false): Promise<LimitedHashTable<string, string>> {
|
async getBuddyIdMapCache(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
return await NTQQFriendApi.getBuddyIdMap(refresh);
|
return await this.getBuddyIdMap(refresh);
|
||||||
}
|
}
|
||||||
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
let uids: string[] = [];
|
let uids: string[] = [];
|
||||||
let retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
let retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
||||||
const buddyService = napCatCore.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
);
|
);
|
||||||
data.forEach((value, key) => {
|
data.forEach((value, key) => {
|
||||||
@ -36,7 +39,7 @@ export class NTQQFriendApi {
|
|||||||
async getBuddyV2ExWithCate(refresh = false) {
|
async getBuddyV2ExWithCate(refresh = false) {
|
||||||
let uids: string[] = [];
|
let uids: string[] = [];
|
||||||
let categoryMap: Map<string, any> = new Map();
|
let categoryMap: Map<string, any> = new Map();
|
||||||
const buddyService = napCatCore.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
||||||
uids.push(
|
uids.push(
|
||||||
...buddyListV2.flatMap(item => {
|
...buddyListV2.flatMap(item => {
|
||||||
@ -45,7 +48,7 @@ export class NTQQFriendApi {
|
|||||||
});
|
});
|
||||||
return item.buddyUids
|
return item.buddyUids
|
||||||
}));
|
}));
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
);
|
);
|
||||||
return Array.from(data).map(([key, value]) => {
|
return Array.from(data).map(([key, value]) => {
|
||||||
@ -54,7 +57,7 @@ export class NTQQFriendApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async isBuddy(uid: string) {
|
async isBuddy(uid: string) {
|
||||||
return napCatCore.session.getBuddyService().isBuddy(uid);
|
return this.context.session.getBuddyService().isBuddy(uid);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -62,7 +65,7 @@ export class NTQQFriendApi {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async getFriends(forced = false): Promise<User[]> {
|
async getFriends(forced = false): Promise<User[]> {
|
||||||
let [_retData, _BuddyArg] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _BuddyArg] = await this.core.eventWrapper.CallNormalEvent
|
||||||
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
||||||
(
|
(
|
||||||
'NodeIKernelBuddyService/getBuddyList',
|
'NodeIKernelBuddyService/getBuddyList',
|
||||||
@ -88,7 +91,7 @@ export class NTQQFriendApi {
|
|||||||
}
|
}
|
||||||
let friendUid = data[0];
|
let friendUid = data[0];
|
||||||
let reqTime = data[1];
|
let reqTime = data[1];
|
||||||
napCatCore.session.getBuddyService()?.approvalFriendRequest({
|
this.context.session.getBuddyService()?.approvalFriendRequest({
|
||||||
friendUid: friendUid,
|
friendUid: friendUid,
|
||||||
reqTime: reqTime,
|
reqTime: reqTime,
|
||||||
accept
|
accept
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType, Peer, GroupListUpdateType } from '../entities';
|
import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType, Peer, GroupListUpdateType } from '../entities';
|
||||||
import { GeneralCallResult, NTQQUserApi, NodeIKernelGroupListener, NodeIKernelGroupService, napCatCore } from '@/core';
|
import { GeneralCallResult, InstanceContext, NapCatCore, NodeIKernelGroupService } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { runAllWithTimeout } from '@/common/utils/helper';
|
||||||
import { log } from '@/common/utils/log';
|
import { NodeIKernelGroupListener } from '../listeners';
|
||||||
import { groupMembers } from '../data';
|
|
||||||
import { CacheClassFuncAsyncExtend, runAllWithTimeout } from '@/common/utils/helper';
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
|
context: InstanceContext;
|
||||||
|
core: NapCatCore;
|
||||||
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
|
this.context = context;
|
||||||
|
this.core = core;
|
||||||
|
}
|
||||||
async setGroupAvatar(gc: string, filePath: string) {
|
async setGroupAvatar(gc: string, filePath: string) {
|
||||||
return napCatCore.session.getGroupService().setHeader(gc, filePath);
|
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
async getGroups(forced = false) {
|
async getGroups(forced = false) {
|
||||||
type ListenerType = NodeIKernelGroupListener['onGroupListUpdate'];
|
type ListenerType = NodeIKernelGroupListener['onGroupListUpdate'];
|
||||||
let [_retData, _updateType, groupList] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _updateType, groupList] = await this.core.eventWrapper.CallNormalEvent
|
||||||
<(force: boolean) => Promise<any>, ListenerType>
|
<(force: boolean) => Promise<any>, ListenerType>
|
||||||
(
|
(
|
||||||
'NodeIKernelGroupService/getGroupList',
|
'NodeIKernelGroupService/getGroupList',
|
||||||
@ -22,10 +26,8 @@ export class NTQQGroupApi {
|
|||||||
);
|
);
|
||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CacheClassFuncAsyncExtend(3600 * 1000, "LastestSendTime", () => true)
|
|
||||||
async getGroupMemberLastestSendTimeCache(GroupCode: string) {
|
async getGroupMemberLastestSendTimeCache(GroupCode: string) {
|
||||||
return NTQQGroupApi.getGroupMemberLastestSendTime(GroupCode);
|
return this.getGroupMemberLastestSendTime(GroupCode);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 通过QQ自带数据库获取群成员最后发言时间(仅返回有效数据 且消耗延迟大 需要进行缓存)
|
* 通过QQ自带数据库获取群成员最后发言时间(仅返回有效数据 且消耗延迟大 需要进行缓存)
|
||||||
@ -39,7 +41,7 @@ export class NTQQGroupApi {
|
|||||||
*/
|
*/
|
||||||
async getGroupMemberLastestSendTime(GroupCode: string) {
|
async getGroupMemberLastestSendTime(GroupCode: string) {
|
||||||
async function getdata(uid: string) {
|
async function getdata(uid: string) {
|
||||||
let NTRet = await NTQQGroupApi.getLastestMsgByUids(GroupCode, [uid]);
|
let NTRet = await this.getLastestMsgByUids(GroupCode, [uid]);
|
||||||
if (NTRet.result != 0 && NTRet.msgList.length < 1) {
|
if (NTRet.result != 0 && NTRet.msgList.length < 1) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -66,7 +68,7 @@ export class NTQQGroupApi {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
async getLastestMsgByUids(GroupCode: string, uids: string[]) {
|
async getLastestMsgByUids(GroupCode: string, uids: string[]) {
|
||||||
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
let ret = await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
||||||
chatInfo: {
|
chatInfo: {
|
||||||
peerUid: GroupCode,
|
peerUid: GroupCode,
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
@ -82,17 +84,17 @@ export class NTQQGroupApi {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
async getGroupMemberAll(GroupCode: string, forced = false) {
|
async getGroupMemberAll(GroupCode: string, forced = false) {
|
||||||
return napCatCore.session.getGroupService().getAllMemberList(GroupCode, forced);
|
return this.context.session.getGroupService().getAllMemberList(GroupCode, forced);
|
||||||
}
|
}
|
||||||
async getLastestMsg(GroupCode: string, uins: string[]) {
|
async getLastestMsg(GroupCode: string, uins: string[]) {
|
||||||
let uids: Array<string> = [];
|
let uids: Array<string> = [];
|
||||||
for (let uin of uins) {
|
for (let uin of uins) {
|
||||||
let uid = await NTQQUserApi.getUidByUin(uin)
|
let uid = await this.core.getApiContext().UserApi.getUidByUin(uin)
|
||||||
if (uid) {
|
if (uid) {
|
||||||
uids.push(uid);
|
uids.push(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
let ret = await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
||||||
chatInfo: {
|
chatInfo: {
|
||||||
peerUid: GroupCode,
|
peerUid: GroupCode,
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
@ -108,43 +110,43 @@ export class NTQQGroupApi {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
async getGroupRecommendContactArkJson(GroupCode: string) {
|
async getGroupRecommendContactArkJson(GroupCode: string) {
|
||||||
return napCatCore.session.getGroupService().getGroupRecommendContactArkJson(GroupCode);
|
return this.context.session.getGroupService().getGroupRecommendContactArkJson(GroupCode);
|
||||||
}
|
}
|
||||||
async CreatGroupFileFolder(groupCode: string, folderName: string) {
|
async CreatGroupFileFolder(groupCode: string, folderName: string) {
|
||||||
return napCatCore.session.getRichMediaService().createGroupFolder(groupCode, folderName);
|
return this.context.session.getRichMediaService().createGroupFolder(groupCode, folderName);
|
||||||
}
|
}
|
||||||
async DelGroupFile(groupCode: string, files: string[]) {
|
async DelGroupFile(groupCode: string, files: string[]) {
|
||||||
return napCatCore.session.getRichMediaService().deleteGroupFile(groupCode, [102], files);
|
return this.context.session.getRichMediaService().deleteGroupFile(groupCode, [102], files);
|
||||||
}
|
}
|
||||||
async DelGroupFileFolder(groupCode: string, folderId: string) {
|
async DelGroupFileFolder(groupCode: string, folderId: string) {
|
||||||
return napCatCore.session.getRichMediaService().deleteGroupFolder(groupCode, folderId);
|
return this.context.session.getRichMediaService().deleteGroupFolder(groupCode, folderId);
|
||||||
}
|
}
|
||||||
async addGroupEssence(GroupCode: string, msgId: string) {
|
async addGroupEssence(GroupCode: string, msgId: string) {
|
||||||
// 代码没测过
|
// 代码没测过
|
||||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||||
let MsgData = await napCatCore.session.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false);
|
let MsgData = await this.context.session.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false);
|
||||||
let param = {
|
let param = {
|
||||||
groupCode: GroupCode,
|
groupCode: GroupCode,
|
||||||
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
||||||
msgSeq: parseInt(MsgData.msgList[0].msgSeq)
|
msgSeq: parseInt(MsgData.msgList[0].msgSeq)
|
||||||
};
|
};
|
||||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
||||||
return napCatCore.session.getGroupService().addGroupEssence(param);
|
return this.context.session.getGroupService().addGroupEssence(param);
|
||||||
}
|
}
|
||||||
async removeGroupEssence(GroupCode: string, msgId: string) {
|
async removeGroupEssence(GroupCode: string, msgId: string) {
|
||||||
// 代码没测过
|
// 代码没测过
|
||||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||||
let MsgData = await napCatCore.session.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false);
|
let MsgData = await this.context.session.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false);
|
||||||
let param = {
|
let param = {
|
||||||
groupCode: GroupCode,
|
groupCode: GroupCode,
|
||||||
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
||||||
msgSeq: parseInt(MsgData.msgList[0].msgSeq)
|
msgSeq: parseInt(MsgData.msgList[0].msgSeq)
|
||||||
};
|
};
|
||||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
||||||
return napCatCore.session.getGroupService().removeGroupEssence(param);
|
return this.context.session.getGroupService().removeGroupEssence(param);
|
||||||
}
|
}
|
||||||
async getSingleScreenNotifies(num: number) {
|
async getSingleScreenNotifies(num: number) {
|
||||||
let [_retData, _doubt, _seq, notifies] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _doubt, _seq, notifies] = await this.core.eventWrapper.CallNormalEvent
|
||||||
<(arg1: boolean, arg2: string, arg3: number) => Promise<any>, (doubt: boolean, seq: string, notifies: GroupNotify[]) => void>
|
<(arg1: boolean, arg2: string, arg3: number) => Promise<any>, (doubt: boolean, seq: string, notifies: GroupNotify[]) => void>
|
||||||
(
|
(
|
||||||
'NodeIKernelGroupService/getSingleScreenNotifies',
|
'NodeIKernelGroupService/getSingleScreenNotifies',
|
||||||
@ -163,7 +165,7 @@ export class NTQQGroupApi {
|
|||||||
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
||||||
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
||||||
//return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
//return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
||||||
const [ret, _groupCode, _changeType, _members] = await NTEventDispatch.CallNormalEvent
|
const [ret, _groupCode, _changeType, _members] = await this.core.eventWrapper.CallNormalEvent
|
||||||
<EventType, ListenerType>
|
<EventType, ListenerType>
|
||||||
(
|
(
|
||||||
'NodeIKernelGroupService/getMemberInfo',
|
'NodeIKernelGroupService/getMemberInfo',
|
||||||
@ -178,7 +180,7 @@ export class NTQQGroupApi {
|
|||||||
return _members.get(uid);
|
return _members.get(uid);
|
||||||
}
|
}
|
||||||
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const groupService = napCatCore.session.getGroupService();
|
const groupService = this.context.session.getGroupService();
|
||||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||||
const result = await groupService.getNextMemberList(sceneId!, undefined, num);
|
const result = await groupService.getNextMemberList(sceneId!, undefined, num);
|
||||||
if (result.errCode !== 0) {
|
if (result.errCode !== 0) {
|
||||||
@ -202,12 +204,12 @@ export class NTQQGroupApi {
|
|||||||
|
|
||||||
}
|
}
|
||||||
async GetGroupFileCount(Gids: Array<string>) {
|
async GetGroupFileCount(Gids: Array<string>) {
|
||||||
return napCatCore.session.getRichMediaService().batchGetGroupFileCount(Gids);
|
return this.context.session.getRichMediaService().batchGetGroupFileCount(Gids);
|
||||||
}
|
}
|
||||||
async getGroupIgnoreNotifies() {
|
async getGroupIgnoreNotifies() {
|
||||||
}
|
}
|
||||||
async getArkJsonGroupShare(GroupCode: string) {
|
async getArkJsonGroupShare(GroupCode: string) {
|
||||||
let ret = await NTEventDispatch.CallNoListenerEvent
|
let ret = await this.core.eventWrapper.callNoListenerEvent
|
||||||
<(GroupId: string) => Promise<GeneralCallResult & { arkJson: string }>>(
|
<(GroupId: string) => Promise<GeneralCallResult & { arkJson: string }>>(
|
||||||
'NodeIKernelGroupService/getGroupRecommendContactArkJson',
|
'NodeIKernelGroupService/getGroupRecommendContactArkJson',
|
||||||
5000,
|
5000,
|
||||||
@ -217,8 +219,8 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
//需要异常处理
|
//需要异常处理
|
||||||
async uploadGroupBulletinPic(GroupCode: string, imageurl: string) {
|
async uploadGroupBulletinPic(GroupCode: string, imageurl: string) {
|
||||||
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
const _Pskey = (await this.core.getApiContext().UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||||
return napCatCore.session.getGroupService().uploadGroupBulletinPic(GroupCode, _Pskey, imageurl);
|
return this.context.session.getGroupService().uploadGroupBulletinPic(GroupCode, _Pskey, imageurl);
|
||||||
}
|
}
|
||||||
async handleGroupRequest(flag: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
async handleGroupRequest(flag: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
||||||
let flagitem = flag.split('|');
|
let flagitem = flag.split('|');
|
||||||
@ -226,7 +228,7 @@ export class NTQQGroupApi {
|
|||||||
let seq = flagitem[1];
|
let seq = flagitem[1];
|
||||||
let type = parseInt(flagitem[2]);
|
let type = parseInt(flagitem[2]);
|
||||||
|
|
||||||
return napCatCore.session.getGroupService().operateSysNotify(
|
return this.context.session.getGroupService().operateSysNotify(
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
'operateType': operateType, // 2 拒绝
|
'operateType': operateType, // 2 拒绝
|
||||||
@ -240,32 +242,32 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async quitGroup(groupQQ: string) {
|
async quitGroup(groupQQ: string) {
|
||||||
return napCatCore.session.getGroupService().quitGroup(groupQQ);
|
return this.context.session.getGroupService().quitGroup(groupQQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
async kickMember(groupQQ: string, kickUids: string[], refuseForever: boolean = false, kickReason: string = '') {
|
async kickMember(groupQQ: string, kickUids: string[], refuseForever: boolean = false, kickReason: string = '') {
|
||||||
return napCatCore.session.getGroupService().kickMember(groupQQ, kickUids, refuseForever, kickReason);
|
return this.context.session.getGroupService().kickMember(groupQQ, kickUids, refuseForever, kickReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
async banMember(groupQQ: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
async banMember(groupQQ: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
||||||
// timeStamp为秒数, 0为解除禁言
|
// timeStamp为秒数, 0为解除禁言
|
||||||
return napCatCore.session.getGroupService().setMemberShutUp(groupQQ, memList);
|
return this.context.session.getGroupService().setMemberShutUp(groupQQ, memList);
|
||||||
}
|
}
|
||||||
|
|
||||||
async banGroup(groupQQ: string, shutUp: boolean) {
|
async banGroup(groupQQ: string, shutUp: boolean) {
|
||||||
return napCatCore.session.getGroupService().setGroupShutUp(groupQQ, shutUp);
|
return this.context.session.getGroupService().setGroupShutUp(groupQQ, shutUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
||||||
return napCatCore.session.getGroupService().modifyMemberCardName(groupQQ, memberUid, cardName);
|
return this.context.session.getGroupService().modifyMemberCardName(groupQQ, memberUid, cardName);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) {
|
async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) {
|
||||||
return napCatCore.session.getGroupService().modifyMemberRole(groupQQ, memberUid, role);
|
return this.context.session.getGroupService().modifyMemberRole(groupQQ, memberUid, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupName(groupQQ: string, groupName: string) {
|
async setGroupName(groupQQ: string, groupName: string) {
|
||||||
return napCatCore.session.getGroupService().modifyGroupName(groupQQ, groupName, false);
|
return this.context.session.getGroupService().modifyGroupName(groupQQ, groupName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 头衔不可用
|
// 头衔不可用
|
||||||
@ -274,7 +276,7 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async publishGroupBulletin(groupQQ: string, content: string, picInfo: { id: string, width: number, height: number } | undefined = undefined, pinned: number = 0, confirmRequired: number = 0,) {
|
async publishGroupBulletin(groupQQ: string, content: string, picInfo: { id: string, width: number, height: number } | undefined = undefined, pinned: number = 0, confirmRequired: number = 0,) {
|
||||||
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com');
|
const _Pskey = (await this.core.getApiContext().UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com');
|
||||||
//text是content内容url编码
|
//text是content内容url编码
|
||||||
let data = {
|
let data = {
|
||||||
text: encodeURI(content),
|
text: encodeURI(content),
|
||||||
@ -283,14 +285,14 @@ export class NTQQGroupApi {
|
|||||||
pinned: pinned,
|
pinned: pinned,
|
||||||
confirmRequired: confirmRequired
|
confirmRequired: confirmRequired
|
||||||
};
|
};
|
||||||
return napCatCore.session.getGroupService().publishGroupBulletin(groupQQ, _Pskey!, data);
|
return this.context.session.getGroupService().publishGroupBulletin(groupQQ, _Pskey!, data);
|
||||||
}
|
}
|
||||||
async getGroupRemainAtTimes(GroupCode: string) {
|
async getGroupRemainAtTimes(GroupCode: string) {
|
||||||
napCatCore.session.getGroupService().getGroupRemainAtTimes(GroupCode);
|
this.context.session.getGroupService().getGroupRemainAtTimes(GroupCode);
|
||||||
}
|
}
|
||||||
async getMemberExtInfo(groupCode: string, uin: string) {
|
async getMemberExtInfo(groupCode: string, uin: string) {
|
||||||
// 仅NTQQ 9.9.11 24568测试 容易炸开谨慎使用
|
// 仅NTQQ 9.9.11 24568测试 容易炸开谨慎使用
|
||||||
return napCatCore.session.getGroupService().getMemberExtInfo(
|
return this.context.session.getGroupService().getMemberExtInfo(
|
||||||
{
|
{
|
||||||
groupCode: groupCode,
|
groupCode: groupCode,
|
||||||
sourceType: MemberExtSourceType.TITLETYPE,
|
sourceType: MemberExtSourceType.TITLETYPE,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export * from './core';
|
export * from './core';
|
||||||
export * from './wrapper';
|
export * from './wrapper';
|
||||||
export * from './entities';
|
export * from './entities';
|
||||||
|
export * from './services';
|
Loading…
Reference in New Issue
Block a user