fix(album): refactor group album like payload and implement cancel like action (#1844)
This commit is contained in:
1 parent
285ba9cf2d
commit
1c703a60ed
6 files changed
+71
-32
No files matched your search
@@ -507,20 +507,36 @@ export class NTQQWebApi {
|
|||||||
async doAlbumMediaLikeByNTQQ (
|
async doAlbumMediaLikeByNTQQ (
|
||||||
qunId: string,
|
qunId: string,
|
||||||
albumId: string,
|
albumId: string,
|
||||||
lloc: string,
|
batchId: string,
|
||||||
id: string) {
|
lloc: string | undefined,
|
||||||
|
isLike: boolean
|
||||||
|
) {
|
||||||
const random_seq = Math.floor(Math.random() * 9000) + 1000;
|
const random_seq = Math.floor(Math.random() * 9000) + 1000;
|
||||||
const uin = this.core.selfInfo.uin || '10001';
|
const uin = this.core.selfInfo.uin || '10001';
|
||||||
|
|
||||||
|
const type = isLike ? 2 : 1;
|
||||||
|
const status = isLike ? 0 : 1;
|
||||||
|
|
||||||
|
let id = '';
|
||||||
|
if (lloc) {
|
||||||
|
id = `421_1_0_${qunId}|${albumId}|${batchId}^||^421_1_0_${qunId}|${albumId}|${lloc}^||^0`;
|
||||||
|
} else {
|
||||||
|
id = `421_1_0_${qunId}|${albumId}|${batchId}`;
|
||||||
|
}
|
||||||
|
|
||||||
return await this.context.session.getAlbumService().doQunLike(
|
return await this.context.session.getAlbumService().doQunLike(
|
||||||
random_seq, {
|
random_seq,
|
||||||
|
{
|
||||||
map_info: [],
|
map_info: [],
|
||||||
map_bytes_info: [],
|
map_bytes_info: [],
|
||||||
map_user_account: [],
|
map_user_account: [],
|
||||||
}, {
|
|
||||||
id,
|
|
||||||
status: 1,
|
|
||||||
},
|
},
|
||||||
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
type,
|
||||||
|
{
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
},
|
||||||
|
createAlbumFeedPublish(qunId, uin, albumId, batchId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,14 +163,14 @@ export interface AlbumFeedLikePublish {
|
|||||||
};
|
};
|
||||||
cell_media: {
|
cell_media: {
|
||||||
album_id: string;
|
album_id: string;
|
||||||
batch_id: number;
|
batch_id: string | number;
|
||||||
media_items: Array<{
|
media_items?: {
|
||||||
type: number;
|
type: number;
|
||||||
image: {
|
image: {
|
||||||
lloc: string;
|
lloc: string;
|
||||||
sloc: string;
|
sloc: string;
|
||||||
};
|
};
|
||||||
}>;
|
}[];
|
||||||
};
|
};
|
||||||
cell_qun_info: {
|
cell_qun_info: {
|
||||||
qun_id: string;
|
qun_id: string;
|
||||||
@@ -182,21 +182,19 @@ export interface AlbumFeedLikePublish {
|
|||||||
* @param qunId 群号
|
* @param qunId 群号
|
||||||
* @param uin 用户QQ号
|
* @param uin 用户QQ号
|
||||||
* @param albumId 相册ID
|
* @param albumId 相册ID
|
||||||
* @param lloc 信息
|
* @param batchId 批次ID
|
||||||
* @param sloc 信息(可选,默认与lloc相同)
|
|
||||||
* @returns 动态发布请求参数对象
|
* @returns 动态发布请求参数对象
|
||||||
*/
|
*/
|
||||||
export function createAlbumFeedPublish (
|
export function createAlbumFeedPublish (
|
||||||
qunId: string,
|
qunId: string,
|
||||||
uin: string,
|
uin: string,
|
||||||
albumId: string,
|
albumId: string,
|
||||||
lloc: string,
|
batchId: string
|
||||||
sloc?: string
|
) {
|
||||||
): AlbumFeedLikePublish {
|
|
||||||
return {
|
return {
|
||||||
cell_common: {
|
cell_common: {
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
feed_id: '',
|
feed_id: `422_0_${batchId}`, // 需要补全feed_id
|
||||||
},
|
},
|
||||||
cell_user_info: {
|
cell_user_info: {
|
||||||
user: {
|
user: {
|
||||||
@@ -205,14 +203,7 @@ export function createAlbumFeedPublish (
|
|||||||
},
|
},
|
||||||
cell_media: {
|
cell_media: {
|
||||||
album_id: albumId,
|
album_id: albumId,
|
||||||
batch_id: 0,
|
batch_id: batchId,
|
||||||
media_items: [{
|
|
||||||
type: 0,
|
|
||||||
image: {
|
|
||||||
lloc,
|
|
||||||
sloc: sloc || lloc,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
},
|
},
|
||||||
cell_qun_info: {
|
cell_qun_info: {
|
||||||
qun_id: qunId,
|
qun_id: qunId,
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export interface NodeIKernelAlbumService {
|
|||||||
map_bytes_info: unknown[],
|
map_bytes_info: unknown[],
|
||||||
map_user_account: unknown[];
|
map_user_account: unknown[];
|
||||||
},
|
},
|
||||||
|
type: number, // type : number 1 取消 2 点赞
|
||||||
param: {
|
param: {
|
||||||
// {"id":"421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|V5bCgAxMDEyOTU5MjU3e*KqaLVYdic!^||^421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|17560336594^||^1","status":1}
|
// {"id":"421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|V5bCgAxMDEyOTU5MjU3e*KqaLVYdic!^||^421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|17560336594^||^1","status":1}
|
||||||
id: string,
|
id: string,
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
const PayloadSchema = Type.Object({
|
const PayloadSchema = Type.Object({
|
||||||
group_id: Type.String({ description: '群号' }),
|
group_id: Type.String({ description: '群号' }),
|
||||||
album_id: Type.String({ description: '相册ID' }),
|
album_id: Type.String({ description: '相册ID' }),
|
||||||
lloc: Type.String({ description: '媒体ID (lloc)' }),
|
batch_id: Type.String({ description: 'batch_id' }),
|
||||||
id: Type.String({ description: '点赞ID' }), // 421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|V5bCgAxMDEyOTU5MjU3.PyqaPndPxg!^||^421_1_0_1012959257|V61Yiali4PELg90bThrH4Bo2iI1M5Kab|17560363448^||^1
|
lloc: Type.Optional(Type.String({ description: 'lloc,若对整个上传操作则不填' })),
|
||||||
set: Type.Boolean({ default: true, description: '是否点赞' }), // true=点赞 false=取消点赞 未实现
|
|
||||||
});
|
});
|
||||||
|
|
||||||
type PayloadType = Static<typeof PayloadSchema>;
|
type PayloadType = Static<typeof PayloadSchema>;
|
||||||
@@ -22,9 +21,9 @@ export class SetGroupAlbumMediaLike extends OneBotAction<PayloadType, ReturnType
|
|||||||
override actionTags = ['群组扩展'];
|
override actionTags = ['群组扩展'];
|
||||||
override payloadExample = {
|
override payloadExample = {
|
||||||
group_id: '123456',
|
group_id: '123456',
|
||||||
album_id: 'album_id_1',
|
album_id: 'album_id_123',
|
||||||
lloc: 'media_id_1',
|
batch_id: '112233',
|
||||||
id: '123456',
|
lloc: 'aabbcc12213123',
|
||||||
};
|
};
|
||||||
|
|
||||||
override returnExample = {
|
override returnExample = {
|
||||||
@@ -38,8 +37,38 @@ export class SetGroupAlbumMediaLike extends OneBotAction<PayloadType, ReturnType
|
|||||||
return await this.core.apis.WebApi.doAlbumMediaLikeByNTQQ(
|
return await this.core.apis.WebApi.doAlbumMediaLikeByNTQQ(
|
||||||
payload.group_id,
|
payload.group_id,
|
||||||
payload.album_id,
|
payload.album_id,
|
||||||
|
payload.batch_id,
|
||||||
payload.lloc,
|
payload.lloc,
|
||||||
payload.id
|
true // isLike = true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CancelGroupAlbumMediaLike extends OneBotAction<PayloadType, ReturnType> {
|
||||||
|
override actionName = ActionName.CancelGroupAlbumMediaLike; // 注意:需要在 router/index.ts 的 ActionName 枚举中补充该定义
|
||||||
|
override actionSummary = '取消点赞群相册媒体';
|
||||||
|
override actionTags = ['群组扩展'];
|
||||||
|
override payloadExample = {
|
||||||
|
group_id: '123456',
|
||||||
|
album_id: 'album_id',
|
||||||
|
batch_id: '112233',
|
||||||
|
lloc: 'aabbcc',
|
||||||
|
};
|
||||||
|
|
||||||
|
override returnExample = {
|
||||||
|
result: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
override payloadSchema = PayloadSchema;
|
||||||
|
override returnSchema = ReturnSchema;
|
||||||
|
|
||||||
|
async _handle (payload: PayloadType) {
|
||||||
|
return await this.core.apis.WebApi.doAlbumMediaLikeByNTQQ(
|
||||||
|
payload.group_id,
|
||||||
|
payload.album_id,
|
||||||
|
payload.batch_id,
|
||||||
|
payload.lloc,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ import { GetQunAlbumList } from './extends/GetQunAlbumList';
|
|||||||
import { UploadImageToQunAlbum } from './extends/UploadImageToQunAlbum';
|
import { UploadImageToQunAlbum } from './extends/UploadImageToQunAlbum';
|
||||||
import { DoGroupAlbumComment } from './extends/DoGroupAlbumComment';
|
import { DoGroupAlbumComment } from './extends/DoGroupAlbumComment';
|
||||||
import { GetGroupAlbumMediaList } from './extends/GetGroupAlbumMediaList';
|
import { GetGroupAlbumMediaList } from './extends/GetGroupAlbumMediaList';
|
||||||
import { SetGroupAlbumMediaLike } from './extends/SetGroupAlbumMediaLike';
|
import { SetGroupAlbumMediaLike, CancelGroupAlbumMediaLike } from './extends/SetGroupAlbumMediaLike';
|
||||||
import { DelGroupAlbumMedia } from './extends/DelGroupAlbumMedia';
|
import { DelGroupAlbumMedia } from './extends/DelGroupAlbumMedia';
|
||||||
import { CleanStreamTempFile } from './stream/CleanStreamTempFile';
|
import { CleanStreamTempFile } from './stream/CleanStreamTempFile';
|
||||||
import { DownloadFileStream } from './stream/DownloadFileStream';
|
import { DownloadFileStream } from './stream/DownloadFileStream';
|
||||||
@@ -169,6 +169,7 @@ export function getAllHandlers (obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new UploadFileStream(obContext, core),
|
new UploadFileStream(obContext, core),
|
||||||
new DelGroupAlbumMedia(obContext, core),
|
new DelGroupAlbumMedia(obContext, core),
|
||||||
new SetGroupAlbumMediaLike(obContext, core),
|
new SetGroupAlbumMediaLike(obContext, core),
|
||||||
|
new CancelGroupAlbumMediaLike(obContext, core),
|
||||||
new DoGroupAlbumComment(obContext, core),
|
new DoGroupAlbumComment(obContext, core),
|
||||||
new GetGroupAlbumMediaList(obContext, core),
|
new GetGroupAlbumMediaList(obContext, core),
|
||||||
new GetQunAlbumList(obContext, core),
|
new GetQunAlbumList(obContext, core),
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const ActionName = {
|
|||||||
|
|
||||||
DelGroupAlbumMedia: 'del_group_album_media',
|
DelGroupAlbumMedia: 'del_group_album_media',
|
||||||
SetGroupAlbumMediaLike: 'set_group_album_media_like',
|
SetGroupAlbumMediaLike: 'set_group_album_media_like',
|
||||||
|
CancelGroupAlbumMediaLike: 'cancel_group_album_media_like',
|
||||||
DoGroupAlbumComment: 'do_group_album_comment',
|
DoGroupAlbumComment: 'do_group_album_comment',
|
||||||
GetGroupAlbumMediaList: 'get_group_album_media_list',
|
GetGroupAlbumMediaList: 'get_group_album_media_list',
|
||||||
UploadImageToQunAlbum: 'upload_image_to_qun_album',
|
UploadImageToQunAlbum: 'upload_image_to_qun_album',
|
||||||
|
|||||||
Reference in new issue
Block a user