mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
@@ -1,32 +0,0 @@
|
|||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
nick: { type: 'string' },
|
|
||||||
longNick: { type: 'string' },
|
|
||||||
sex: { type: ['number', 'string'] },//传Sex值?建议传0
|
|
||||||
},
|
|
||||||
required: ['nick', 'longNick', 'sex'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class SetSelfProfile extends BaseAction<Payload, any | null> {
|
|
||||||
actionName = ActionName.SetSelfProfile;
|
|
||||||
PayloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
|
||||||
const ret = await NTQQUserApi.modifySelfProfile({
|
|
||||||
nick: payload.nick,
|
|
||||||
longNick: payload.longNick,
|
|
||||||
sex: parseInt(payload.sex.toString()),
|
|
||||||
birthday: { birthday_year: '', birthday_month: '', birthday_day: '' },
|
|
||||||
location: undefined,
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -7,18 +7,18 @@ import { checkFileReceived, uri2local } from '@/common/utils/file';
|
|||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
file: string,
|
file: string,
|
||||||
groupCode: string
|
group_id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SetGroupHeader extends BaseAction<Payload, any> {
|
export default class SetGroupPortrait extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.SetGroupHeader;
|
actionName = ActionName.SetGroupPortrait;
|
||||||
|
|
||||||
// 用不着复杂检测
|
// 用不着复杂检测
|
||||||
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
||||||
if (!payload.file || typeof payload.file != 'string' || !payload.groupCode || typeof payload.groupCode != 'string') {
|
if (!payload.file || typeof payload.file != 'string' || !payload.group_id || typeof payload.group_id != 'number') {
|
||||||
return {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: 'file和groupCode字段不能为空或者类型错误',
|
message: 'file和group_id字段不能为空或者类型错误',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -34,7 +34,7 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
|||||||
}
|
}
|
||||||
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.group_id.toString(), path) as any;
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
fs.unlink(path, () => {
|
fs.unlink(path, () => {
|
||||||
});
|
});
|
||||||
@@ -43,11 +43,11 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
|||||||
throw `头像${payload.file}设置失败,api无返回`;
|
throw `头像${payload.file}设置失败,api无返回`;
|
||||||
}
|
}
|
||||||
// log(`头像设置返回:${JSON.stringify(ret)}`)
|
// log(`头像设置返回:${JSON.stringify(ret)}`)
|
||||||
// if (ret['result'] == 1004022) {
|
if (ret['result'] == 1004022) {
|
||||||
// throw `头像${payload.file}设置失败,文件可能不是图片格式`;
|
throw `头像${payload.file}设置失败,文件可能不是图片格式或权限不足`;
|
||||||
// } else if (ret['result'] != 0) {
|
} else if (ret['result'] != 0) {
|
||||||
// throw `头像${payload.file}设置失败,未知的错误,${ret['result']}:${ret['errMsg']}`;
|
throw `头像${payload.file}设置失败,未知的错误,${ret['result']}:${ret['errMsg']}`;
|
||||||
// }
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
34
src/onebot/action/go-cqhttp/SetQQProfile.ts
Normal file
34
src/onebot/action/go-cqhttp/SetQQProfile.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
nickname: { type: 'string' },
|
||||||
|
personal_note: { type: 'string' },
|
||||||
|
sex: { type: ['number', 'string'] },//传Sex值?建议传0
|
||||||
|
},
|
||||||
|
required: ['nickname'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class SetQQProfile extends BaseAction<Payload, any | null> {
|
||||||
|
actionName = ActionName.SetQQProfile;
|
||||||
|
PayloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
|
const self = this.CoreContext.selfInfo;
|
||||||
|
const OldProfile = await NTQQUserApi.getUserDetailInfo(self.uid);
|
||||||
|
const ret = await NTQQUserApi.modifySelfProfile({
|
||||||
|
nick: payload.nickname,
|
||||||
|
longNick: payload?.personal_note ?? OldProfile?.longNick!,
|
||||||
|
sex: parseInt(payload?.sex ? payload?.sex.toString() : OldProfile?.sex!.toString()),
|
||||||
|
birthday: { birthday_year: OldProfile?.birthday_year!.toString(), birthday_month: OldProfile?.birthday_month!.toString(), birthday_day: OldProfile?.birthday_day!.toString() },
|
||||||
|
location: undefined,
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
@@ -61,7 +61,7 @@ import { TranslateEnWordToZn } from './extends/TranslateEnWordToZn';
|
|||||||
import { SetGroupFileFolder } from './file/SetGroupFileFolder';
|
import { SetGroupFileFolder } from './file/SetGroupFileFolder';
|
||||||
import { DelGroupFile } from './file/DelGroupFile';
|
import { DelGroupFile } from './file/DelGroupFile';
|
||||||
import { DelGroupFileFolder } from './file/DelGroupFileFolder';
|
import { DelGroupFileFolder } from './file/DelGroupFileFolder';
|
||||||
import { SetSelfProfile } from './extends/SetSelfProfile';
|
import { SetQQProfile } from './go-cqhttp/SetQQProfile'
|
||||||
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
import { ShareGroupEx, SharePeer } from './extends/ShareContact';
|
||||||
import { CreateCollection } from './extends/CreateCollection';
|
import { CreateCollection } from './extends/CreateCollection';
|
||||||
import { SetLongNick } from './extends/SetLongNick';
|
import { SetLongNick } from './extends/SetLongNick';
|
||||||
@@ -69,7 +69,7 @@ import DelEssenceMsg from './group/DelEssenceMsg';
|
|||||||
import SetEssenceMsg from './group/SetEssenceMsg';
|
import SetEssenceMsg from './group/SetEssenceMsg';
|
||||||
import GetRecentContact from './user/GetRecentContact';
|
import GetRecentContact from './user/GetRecentContact';
|
||||||
import { GetProfileLike } from './extends/GetProfileLike';
|
import { GetProfileLike } from './extends/GetProfileLike';
|
||||||
import SetGroupHeader from './extends/SetGroupHeader';
|
import SetGroupPortrait from './go-cqhttp/SetGroupPortrait';
|
||||||
import { FetchCustomFace } from './extends/FetchCustomFace';
|
import { FetchCustomFace } from './extends/FetchCustomFace';
|
||||||
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
||||||
import { FetchEmojiLike } from './extends/FetchEmojiLike';
|
import { FetchEmojiLike } from './extends/FetchEmojiLike';
|
||||||
@@ -86,7 +86,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
|||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
new FetchEmojiLike(onebotContext, coreContext),
|
new FetchEmojiLike(onebotContext, coreContext),
|
||||||
new GetFile(onebotContext, coreContext),
|
new GetFile(onebotContext, coreContext),
|
||||||
new SetSelfProfile(onebotContext, coreContext),
|
new SetQQProfile(onebotContext, coreContext),
|
||||||
new ShareGroupEx(onebotContext, coreContext),
|
new ShareGroupEx(onebotContext, coreContext),
|
||||||
new SharePeer(onebotContext, coreContext),
|
new SharePeer(onebotContext, coreContext),
|
||||||
new CreateCollection(onebotContext, coreContext),
|
new CreateCollection(onebotContext, coreContext),
|
||||||
@@ -161,7 +161,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
|||||||
new GetRecentContact(onebotContext, coreContext),
|
new GetRecentContact(onebotContext, coreContext),
|
||||||
new MarkAllMsgAsRead(onebotContext, coreContext),
|
new MarkAllMsgAsRead(onebotContext, coreContext),
|
||||||
new GetProfileLike(onebotContext, coreContext),
|
new GetProfileLike(onebotContext, coreContext),
|
||||||
new SetGroupHeader(onebotContext, coreContext),
|
new SetGroupPortrait(onebotContext, coreContext),
|
||||||
new FetchCustomFace(onebotContext, coreContext),
|
new FetchCustomFace(onebotContext, coreContext),
|
||||||
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
||||||
new GetGuildProfile(onebotContext, coreContext),
|
new GetGuildProfile(onebotContext, coreContext),
|
||||||
|
@@ -91,7 +91,7 @@ export enum ActionName {
|
|||||||
GetOnlineClient = 'get_online_clients',
|
GetOnlineClient = 'get_online_clients',
|
||||||
OCRImage = 'ocr_image',
|
OCRImage = 'ocr_image',
|
||||||
IOCRImage = '.ocr_image',
|
IOCRImage = '.ocr_image',
|
||||||
SetSelfProfile = 'set_self_profile',
|
SetQQProfile = 'set_qq_profile',
|
||||||
CreateCollection = 'create_collection',
|
CreateCollection = 'create_collection',
|
||||||
GetCollectionList = 'get_collection_list',
|
GetCollectionList = 'get_collection_list',
|
||||||
SetLongNick = 'set_self_longnick',
|
SetLongNick = 'set_self_longnick',
|
||||||
@@ -100,7 +100,7 @@ export enum ActionName {
|
|||||||
GetRecentContact = 'get_recent_contact',
|
GetRecentContact = 'get_recent_contact',
|
||||||
_MarkAllMsgAsRead = '_mark_all_as_read',
|
_MarkAllMsgAsRead = '_mark_all_as_read',
|
||||||
GetProfileLike = 'get_profile_like',
|
GetProfileLike = 'get_profile_like',
|
||||||
SetGroupHeader = 'set_group_head',
|
SetGroupPortrait = 'set_group_portrait',
|
||||||
FetchCustomFace = 'fetch_custom_face',
|
FetchCustomFace = 'fetch_custom_face',
|
||||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||||
TestApi01 = 'test_api_01',
|
TestApi01 = 'test_api_01',
|
||||||
|
Reference in New Issue
Block a user