mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: get_group_files_by_folder
API
This commit is contained in:
parent
6c485634e1
commit
156bbaea33
@ -6,6 +6,7 @@ export interface GetFileListParam {
|
|||||||
startIndex: number
|
startIndex: number
|
||||||
sortOrder: number
|
sortOrder: number
|
||||||
showOnlinedocFolder: number
|
showOnlinedocFolder: number
|
||||||
|
folderId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ElementType {
|
export enum ElementType {
|
||||||
|
54
src/onebot11/action/go-cqhttp/GetGroupFilesByFolder.ts
Normal file
54
src/onebot11/action/go-cqhttp/GetGroupFilesByFolder.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
|
import { ActionName } from '../types'
|
||||||
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot11/types'
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
group_id: string | number
|
||||||
|
folder_id: string
|
||||||
|
file_count: string | number
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Response {
|
||||||
|
files: OB11GroupFile[]
|
||||||
|
folders: OB11GroupFileFolder[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetGroupFilesByFolder extends BaseAction<Payload, Response> {
|
||||||
|
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder
|
||||||
|
payloadSchema = Schema.object({
|
||||||
|
group_id: Schema.union([Number, String]).required(),
|
||||||
|
folder_id: Schema.string().required(),
|
||||||
|
file_count: Schema.union([Number, String]).default(50)
|
||||||
|
})
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const data = await this.ctx.ntGroupApi.getGroupFileList(payload.group_id.toString(), {
|
||||||
|
sortType: 1,
|
||||||
|
fileCount: +payload.file_count,
|
||||||
|
startIndex: 0,
|
||||||
|
sortOrder: 2,
|
||||||
|
showOnlinedocFolder: 0,
|
||||||
|
folderId: payload.folder_id
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
files: data.filter(item => item.fileInfo)
|
||||||
|
.map(item => {
|
||||||
|
const file = item.fileInfo!
|
||||||
|
return {
|
||||||
|
group_id: +item.peerId,
|
||||||
|
file_id: file.fileId,
|
||||||
|
file_name: file.fileName,
|
||||||
|
busid: file.busId,
|
||||||
|
file_size: +file.fileSize,
|
||||||
|
upload_time: file.uploadTime,
|
||||||
|
dead_time: file.deadTime,
|
||||||
|
modify_time: file.modifyTime,
|
||||||
|
download_times: file.downloadTimes,
|
||||||
|
uploader: +file.uploaderUin,
|
||||||
|
uploader_name: file.uploaderName
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
folders: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -53,7 +53,7 @@ import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
|
|||||||
import { HandleQuickOperation } from './go-cqhttp/QuickOperation'
|
import { HandleQuickOperation } from './go-cqhttp/QuickOperation'
|
||||||
import { SetEssenceMsg } from './go-cqhttp/SetEssenceMsg'
|
import { SetEssenceMsg } from './go-cqhttp/SetEssenceMsg'
|
||||||
import { DelEssenceMsg } from './go-cqhttp/DelEssenceMsg'
|
import { DelEssenceMsg } from './go-cqhttp/DelEssenceMsg'
|
||||||
import GetEvent from './llonebot/GetEvent'
|
import { GetEvent } from './llonebot/GetEvent'
|
||||||
import { DelGroupFile } from './go-cqhttp/DelGroupFile'
|
import { DelGroupFile } from './go-cqhttp/DelGroupFile'
|
||||||
import { GetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg'
|
import { GetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg'
|
||||||
import { CreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder'
|
import { CreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder'
|
||||||
@ -66,6 +66,7 @@ import { GetProfileLike } from './llonebot/GetProfileLike'
|
|||||||
import { FetchEmojiLike } from './llonebot/FetchEmojiLike'
|
import { FetchEmojiLike } from './llonebot/FetchEmojiLike'
|
||||||
import { FetchCustomFace } from './llonebot/FetchCustomFace'
|
import { FetchCustomFace } from './llonebot/FetchCustomFace'
|
||||||
import { GetFriendMsgHistory } from './llonebot/GetFriendMsgHistory'
|
import { GetFriendMsgHistory } from './llonebot/GetFriendMsgHistory'
|
||||||
|
import { GetGroupFilesByFolder } from './go-cqhttp/GetGroupFilesByFolder'
|
||||||
|
|
||||||
export function initActionMap(adapter: Adapter) {
|
export function initActionMap(adapter: Adapter) {
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
@ -80,6 +81,8 @@ export function initActionMap(adapter: Adapter) {
|
|||||||
new SetOnlineStatus(adapter),
|
new SetOnlineStatus(adapter),
|
||||||
new GetProfileLike(adapter),
|
new GetProfileLike(adapter),
|
||||||
new GetFriendMsgHistory(adapter),
|
new GetFriendMsgHistory(adapter),
|
||||||
|
new FetchEmojiLike(adapter),
|
||||||
|
new FetchCustomFace(adapter),
|
||||||
// onebot11
|
// onebot11
|
||||||
new SendLike(adapter),
|
new SendLike(adapter),
|
||||||
new GetMsg(adapter),
|
new GetMsg(adapter),
|
||||||
@ -137,8 +140,7 @@ export function initActionMap(adapter: Adapter) {
|
|||||||
new GetGroupAtAllRemain(adapter),
|
new GetGroupAtAllRemain(adapter),
|
||||||
new GetGroupRootFiles(adapter),
|
new GetGroupRootFiles(adapter),
|
||||||
new SendGroupNotice(adapter),
|
new SendGroupNotice(adapter),
|
||||||
new FetchEmojiLike(adapter),
|
new GetGroupFilesByFolder(adapter),
|
||||||
new FetchCustomFace(adapter),
|
|
||||||
]
|
]
|
||||||
const actionMap = new Map<string, BaseAction<any, unknown>>()
|
const actionMap = new Map<string, BaseAction<any, unknown>>()
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@ -11,7 +11,7 @@ interface Payload {
|
|||||||
timeout: number
|
timeout: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GetEvent extends BaseAction<Payload, PostEventType[]> {
|
export class GetEvent extends BaseAction<Payload, PostEventType[]> {
|
||||||
actionName = ActionName.GetEvent
|
actionName = ActionName.GetEvent
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<PostEventType[]> {
|
protected async _handle(payload: Payload): Promise<PostEventType[]> {
|
||||||
|
@ -81,4 +81,5 @@ export enum ActionName {
|
|||||||
GoCQHTTP_GetGroupAtAllRemain = 'get_group_at_all_remain',
|
GoCQHTTP_GetGroupAtAllRemain = 'get_group_at_all_remain',
|
||||||
GoCQHTTP_GetGroupRootFiles = 'get_group_root_files',
|
GoCQHTTP_GetGroupRootFiles = 'get_group_root_files',
|
||||||
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
||||||
|
GoCQHTTP_GetGroupFilesByFolder = 'get_group_files_by_folder'
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user