mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
feat: GoCQHTTPDeleteFriend
This commit is contained in:
parent
90f6896f3c
commit
7416e6caf6
@ -34,7 +34,13 @@ export class NTQQFriendApi {
|
||||
data.forEach((value) => retMap.set(value.uin!, value.uid!));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
async delBuudy(uid: string, tempBlock = false, tempBothDel = false) {
|
||||
return this.context.session.getBuddyService().delBuddy({
|
||||
friendUid: uid,
|
||||
tempBlock: tempBlock,
|
||||
tempBothDel: tempBothDel
|
||||
});
|
||||
}
|
||||
async getBuddyV2ExWithCate(refresh = false) {
|
||||
const categoryMap: Map<string, any> = new Map();
|
||||
const buddyService = this.context.session.getBuddyService();
|
||||
|
38
src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts
Normal file
38
src/onebot/action/go-cqhttp/GoCQHTTPDeleteFriend.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
friend_id: { type: ['string', 'number'] },
|
||||
temp_block: { type: 'boolean' },
|
||||
temp_both_del: { type: 'boolean' },
|
||||
},
|
||||
required: ['friend_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPDeleteFriend extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_DeleteFriend;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
let uid = await this.core.apis.UserApi.getUidByUinV2(payload.friend_id.toString());
|
||||
|
||||
if (!uid) {
|
||||
return {
|
||||
valid: false,
|
||||
message: '好友不存在',
|
||||
};
|
||||
}
|
||||
let isBuddy = this.core.apis.FriendApi.isBuddy(uid);
|
||||
if (!isBuddy) {
|
||||
return {
|
||||
valid: false,
|
||||
message: '不是好友',
|
||||
};
|
||||
}
|
||||
return await this.core.apis.FriendApi.delBuudy(uid, payload.temp_block, payload.temp_both_del);
|
||||
}
|
||||
}
|
@ -97,6 +97,7 @@ import { GoCQHTTPGetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain';
|
||||
import { GoCQHTTPCheckUrlSafely } from './go-cqhttp/GoCQHTTPCheckUrlSafely';
|
||||
import { GoCQHTTPGetModelShow } from './go-cqhttp/GoCQHTTPGetModelShow';
|
||||
import { GoCQHTTPSetModelShow } from './go-cqhttp/GoCQHTTPSetModelShow';
|
||||
import { GoCQHTTPDeleteFriend } from './go-cqhttp/GoCQHTTPDeleteFriend';
|
||||
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
@ -154,6 +155,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new GetRobotUinRange(obContext, core),
|
||||
new GetFriendWithCategory(obContext, core),
|
||||
//以下为go-cqhttp api
|
||||
new GoCQHTTPDeleteFriend(obContext, core),
|
||||
new GoCQHTTPCheckUrlSafely(obContext, core),
|
||||
new GetOnlineClient(obContext, core),
|
||||
new OCRImage(obContext, core),
|
||||
|
@ -61,7 +61,7 @@ export enum ActionName {
|
||||
GoCQHTTP_SetModelShow = '_set_model_show',
|
||||
GetOnlineClient = 'get_online_clients',
|
||||
// GetUnidirectionalFriendList = 'get_unidirectional_friend_list',
|
||||
// DeleteFriend = 'delete_friend',
|
||||
GoCQHTTP_DeleteFriend = 'delete_friend',
|
||||
// DeleteUnidirectionalFriendList = 'delete_unidirectional_friend',
|
||||
GoCQHTTP_MarkMsgAsRead = 'mark_msg_as_read',
|
||||
GoCQHTTP_SendGroupForwardMsg = 'send_group_forward_msg',
|
||||
|
Loading…
Reference in New Issue
Block a user