mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
refactor: 接口兼容
调整SetGroupHeader接口为SetGroupPortrait,使其兼容gocq标准
This commit is contained in:
parent
1bee811312
commit
0c8cf73746
@ -7,18 +7,18 @@ import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
|
||||
interface Payload {
|
||||
file: string,
|
||||
groupCode: string
|
||||
group_id: number
|
||||
}
|
||||
|
||||
export default class SetGroupHeader extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetGroupHeader;
|
||||
export default class SetGroupPortrait extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetGroupPortrait;
|
||||
|
||||
// 用不着复杂检测
|
||||
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 {
|
||||
valid: false,
|
||||
message: 'file和groupCode字段不能为空或者类型错误',
|
||||
message: 'file和group_id字段不能为空或者类型错误',
|
||||
};
|
||||
}
|
||||
return {
|
||||
@ -34,7 +34,7 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
||||
}
|
||||
if (path) {
|
||||
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) {
|
||||
fs.unlink(path, () => {
|
||||
});
|
||||
@ -43,11 +43,11 @@ export default class SetGroupHeader extends BaseAction<Payload, any> {
|
||||
throw `头像${payload.file}设置失败,api无返回`;
|
||||
}
|
||||
// log(`头像设置返回:${JSON.stringify(ret)}`)
|
||||
// if (ret['result'] == 1004022) {
|
||||
// throw `头像${payload.file}设置失败,文件可能不是图片格式`;
|
||||
// } else if (ret['result'] != 0) {
|
||||
// throw `头像${payload.file}设置失败,未知的错误,${ret['result']}:${ret['errMsg']}`;
|
||||
// }
|
||||
if (ret['result'] == 1004022) {
|
||||
throw `头像${payload.file}设置失败,文件可能不是图片格式或权限不足`;
|
||||
} else if (ret['result'] != 0) {
|
||||
throw `头像${payload.file}设置失败,未知的错误,${ret['result']}:${ret['errMsg']}`;
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
if (!isLocal) {
|
@ -69,7 +69,7 @@ import DelEssenceMsg from './group/DelEssenceMsg';
|
||||
import SetEssenceMsg from './group/SetEssenceMsg';
|
||||
import GetRecentContact from './user/GetRecentContact';
|
||||
import { GetProfileLike } from './extends/GetProfileLike';
|
||||
import SetGroupHeader from './extends/SetGroupHeader';
|
||||
import SetGroupPortrait from './go-cqhttp/SetGroupPortrait';
|
||||
import { FetchCustomFace } from './extends/FetchCustomFace';
|
||||
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
||||
import { FetchEmojiLike } from './extends/FetchEmojiLike';
|
||||
@ -161,7 +161,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
||||
new GetRecentContact(onebotContext, coreContext),
|
||||
new MarkAllMsgAsRead(onebotContext, coreContext),
|
||||
new GetProfileLike(onebotContext, coreContext),
|
||||
new SetGroupHeader(onebotContext, coreContext),
|
||||
new SetGroupPortrait(onebotContext, coreContext),
|
||||
new FetchCustomFace(onebotContext, coreContext),
|
||||
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
||||
new GetGuildProfile(onebotContext, coreContext),
|
||||
|
@ -100,7 +100,7 @@ export enum ActionName {
|
||||
GetRecentContact = 'get_recent_contact',
|
||||
_MarkAllMsgAsRead = '_mark_all_as_read',
|
||||
GetProfileLike = 'get_profile_like',
|
||||
SetGroupHeader = 'set_group_head',
|
||||
SetGroupPortrait = 'set_group_portrait',
|
||||
FetchCustomFace = 'fetch_custom_face',
|
||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||
TestApi01 = 'test_api_01',
|
||||
|
Loading…
Reference in New Issue
Block a user