mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
build: test2
This commit is contained in:
parent
994ec5ac0f
commit
8ff469974c
@ -131,20 +131,53 @@ export class NTQQWebApi {
|
|||||||
// return await res.json();
|
// return await res.json();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
async setGroupNotice(GroupCode: string, Content: string) {
|
async setGroupNotice(
|
||||||
|
GroupCode: string,
|
||||||
|
Content: string,
|
||||||
|
pinned: number = 0,
|
||||||
|
type: number = 1,
|
||||||
|
is_show_edit_card: number = 1,
|
||||||
|
tip_window_type: number = 1,
|
||||||
|
confirm_required: number = 1,
|
||||||
|
picId: string = '',
|
||||||
|
imgWidth: number = 540,
|
||||||
|
imgHeight: number = 300,
|
||||||
|
) {
|
||||||
|
interface SetNoticeRetSuccess {
|
||||||
|
ec: number;
|
||||||
|
em: string;
|
||||||
|
id: number;
|
||||||
|
ltsm: number;
|
||||||
|
new_fid: string;
|
||||||
|
read_only: number;
|
||||||
|
role: number;
|
||||||
|
srv_code: number;
|
||||||
|
}
|
||||||
|
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
let ret: any = undefined;
|
|
||||||
try {
|
try {
|
||||||
ret = await RequestUtil.HttpGetJson<any>(
|
let settings = JSON.stringify({
|
||||||
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${new URLSearchParams({
|
is_show_edit_card: is_show_edit_card,
|
||||||
|
tip_window_type: tip_window_type,
|
||||||
|
confirm_required: confirm_required
|
||||||
|
});
|
||||||
|
const externalParam = {
|
||||||
|
pic: picId,
|
||||||
|
imgWidth: imgWidth.toString(),
|
||||||
|
imgHeight: imgHeight.toString(),
|
||||||
|
};
|
||||||
|
let ret: SetNoticeRetSuccess = await RequestUtil.HttpGetJson<SetNoticeRetSuccess>(
|
||||||
|
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
qid: GroupCode,
|
qid: GroupCode,
|
||||||
text: Content,
|
text: Content,
|
||||||
pinned: '0',
|
pinned: pinned.toString(),
|
||||||
type: '1',
|
type: type.toString(),
|
||||||
settings: '{"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}',
|
settings: settings,
|
||||||
|
...(picId === '' ? {} : externalParam)
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'GET',
|
'POST',
|
||||||
'',
|
'',
|
||||||
{ 'Cookie': this.cookieToString(cookieObject) }
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
|
@ -11,7 +11,10 @@ const SchemaData = {
|
|||||||
content: { type: 'string' },
|
content: { type: 'string' },
|
||||||
image: { type: 'string' },
|
image: { type: 'string' },
|
||||||
pinned: { type: ['number', 'string'] },
|
pinned: { type: ['number', 'string'] },
|
||||||
|
type: { type: ['number', 'string'] },
|
||||||
confirm_required: { type: ['number', 'string'] },
|
confirm_required: { type: ['number', 'string'] },
|
||||||
|
is_show_edit_card: { type: ['number', 'string'] },
|
||||||
|
tip_window_type: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'content'],
|
required: ['group_id', 'content'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@ -22,6 +25,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
|
|
||||||
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
||||||
if (payload.image) {
|
if (payload.image) {
|
||||||
//公告图逻辑
|
//公告图逻辑
|
||||||
@ -47,12 +51,28 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
UploadImage = ImageUploadResult.picInfo;
|
UploadImage = ImageUploadResult.picInfo;
|
||||||
}
|
}
|
||||||
const noticePinned = +(payload.pinned ?? 0);
|
|
||||||
const noticeConfirmRequired = +(payload.confirm_required ?? 0);
|
|
||||||
const publishGroupBulletinResult = await this.core.apis.GroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired);
|
|
||||||
|
|
||||||
if (publishGroupBulletinResult.result != 0) {
|
const noticeType = +(payload.type ?? 1);
|
||||||
throw `设置群公告失败,错误信息:${publishGroupBulletinResult.errMsg}`;
|
const noticePinned = +(payload.pinned ?? 0);
|
||||||
|
|
||||||
|
const noticeShowEditCard = +(payload.is_show_edit_card ?? 0);
|
||||||
|
const noticeTipWindowType = +(payload.tip_window_type ?? 0);
|
||||||
|
const noticeConfirmRequired = +(payload.confirm_required ?? 1);
|
||||||
|
//const publishGroupBulletinResult = await this.core.apis.GroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired);
|
||||||
|
const publishGroupBulletinResult = await this.core.apis.WebApi.setGroupNotice(
|
||||||
|
payload.group_id.toString(),
|
||||||
|
payload.content,
|
||||||
|
noticePinned,
|
||||||
|
noticeType,
|
||||||
|
noticeShowEditCard,
|
||||||
|
noticeTipWindowType,
|
||||||
|
noticeConfirmRequired,
|
||||||
|
UploadImage?.id,
|
||||||
|
UploadImage?.width,
|
||||||
|
UploadImage?.height
|
||||||
|
);
|
||||||
|
if (!publishGroupBulletinResult || publishGroupBulletinResult.ec != 0) {
|
||||||
|
throw `设置群公告失败,错误信息:${publishGroupBulletinResult?.em}`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user