mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
commit
d5875c9e5b
@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||||
"version": "3.33.8",
|
"version": "3.33.9",
|
||||||
"icon": "./icon.webp",
|
"icon": "./icon.webp",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -6,9 +6,9 @@ import {
|
|||||||
GroupNotifies,
|
GroupNotifies,
|
||||||
GroupRequestOperateTypes,
|
GroupRequestOperateTypes,
|
||||||
GetFileListParam,
|
GetFileListParam,
|
||||||
OnGroupFileInfoUpdateParams,
|
|
||||||
PublishGroupBulletinReq,
|
PublishGroupBulletinReq,
|
||||||
GroupAllInfo
|
GroupAllInfo,
|
||||||
|
GroupFileInfo
|
||||||
} from '../types'
|
} from '../types'
|
||||||
import { invoke, NTClass, NTMethod } from '../ntcall'
|
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
@ -274,7 +274,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
|
|
||||||
async getGroupFileList(groupId: string, fileListForm: GetFileListParam) {
|
async getGroupFileList(groupId: string, fileListForm: GetFileListParam) {
|
||||||
invoke('nodeIKernelMsgListener/onGroupFileInfoUpdate', [], { registerEvent: true })
|
invoke('nodeIKernelMsgListener/onGroupFileInfoUpdate', [], { registerEvent: true })
|
||||||
const data = await invoke<{ fileInfo: OnGroupFileInfoUpdateParams }>(
|
const data = await invoke<{ fileInfo: GroupFileInfo }>(
|
||||||
'nodeIKernelRichMediaService/getGroupFileList',
|
'nodeIKernelRichMediaService/getGroupFileList',
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -159,9 +159,9 @@ export function invoke<
|
|||||||
afterFirstCmd && secondCallback()
|
afterFirstCmd && secondCallback()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log('ntqq api call failed,', method, res)
|
log('ntqq api call failed,', method, args, res)
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
reject(`ntqq api call failed, ${method}, ${res.errMsg}`)
|
reject(`ntqq api call failed, ${method}, ${res?.errMsg}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ export interface OnRichMediaDownloadCompleteParams {
|
|||||||
userUsedSpacePerDay: unknown
|
userUsedSpacePerDay: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OnGroupFileInfoUpdateParams {
|
export interface GroupFileInfo {
|
||||||
retCode: number
|
retCode: number
|
||||||
retMsg: string
|
retMsg: string
|
||||||
clientWording: string
|
clientWording: string
|
||||||
|
@ -34,25 +34,23 @@ export class GetForwardMsg extends BaseAction<Payload, Response> {
|
|||||||
if (data?.result !== 0) {
|
if (data?.result !== 0) {
|
||||||
throw Error('找不到相关的聊天记录' + data?.errMsg)
|
throw Error('找不到相关的聊天记录' + data?.errMsg)
|
||||||
}
|
}
|
||||||
const msgList = data.msgList
|
const messages: (OB11ForwardMessage | undefined)[] = await Promise.all(
|
||||||
const messages = await Promise.all(
|
data.msgList.map(async (msg) => {
|
||||||
msgList.map(async (msg) => {
|
const res = await OB11Entities.message(this.ctx, msg)
|
||||||
const resMsg = await OB11Entities.message(this.ctx, msg)
|
if (res) {
|
||||||
if (!resMsg) return
|
return {
|
||||||
resMsg.message_id = this.ctx.store.createMsgShortId({
|
content: res.message,
|
||||||
chatType: msg.chatType,
|
sender: {
|
||||||
peerUid: msg.peerUid,
|
nickname: res.sender.nickname,
|
||||||
}, msg.msgId)
|
user_id: res.sender.user_id
|
||||||
return resMsg
|
},
|
||||||
|
time: res.time,
|
||||||
|
message_format: res.message_format,
|
||||||
|
message_type: res.message_type
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const forwardMessages = filterNullable(messages)
|
return { messages: filterNullable(messages) }
|
||||||
.map(v => {
|
|
||||||
const msg = v as Partial<OB11ForwardMessage>
|
|
||||||
msg.content = msg.message
|
|
||||||
delete msg.message
|
|
||||||
return msg as OB11ForwardMessage
|
|
||||||
})
|
|
||||||
return { messages: forwardMessages }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { BaseAction, Schema } from '../BaseAction'
|
|||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import { ChatType } from '@/ntqqapi/types'
|
import { ChatType } from '@/ntqqapi/types'
|
||||||
|
import { GroupFileInfo } from '@/ntqqapi/types'
|
||||||
|
|
||||||
export interface Payload {
|
export interface Payload {
|
||||||
group_id: number | string
|
group_id: number | string
|
||||||
@ -30,23 +31,7 @@ export class GetGroupFileUrl extends BaseAction<Payload, Response> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const groupId = payload.group_id.toString()
|
const groupId = payload.group_id.toString()
|
||||||
let modelId: string | undefined
|
const modelId = await this.search(groupId, payload.file_id)
|
||||||
let nextIndex: number | undefined
|
|
||||||
while (nextIndex !== 0) {
|
|
||||||
const res = await this.ctx.ntGroupApi.getGroupFileList(groupId, {
|
|
||||||
sortType: 1,
|
|
||||||
fileCount: 50,
|
|
||||||
startIndex: nextIndex ?? 0,
|
|
||||||
sortOrder: 2,
|
|
||||||
showOnlinedocFolder: 0,
|
|
||||||
})
|
|
||||||
const file = res.item.find(item => item.fileInfo?.fileId === payload.file_id)
|
|
||||||
if (file) {
|
|
||||||
modelId = file.fileInfo?.fileModelId
|
|
||||||
break
|
|
||||||
}
|
|
||||||
nextIndex = res.nextIndex
|
|
||||||
}
|
|
||||||
if (modelId) {
|
if (modelId) {
|
||||||
const peer = {
|
const peer = {
|
||||||
chatType: ChatType.Group,
|
chatType: ChatType.Group,
|
||||||
@ -61,4 +46,37 @@ export class GetGroupFileUrl extends BaseAction<Payload, Response> {
|
|||||||
throw new Error('file not found')
|
throw new Error('file not found')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async search(groupId: string, fileId: string, folderId?: string) {
|
||||||
|
let modelId: string | undefined
|
||||||
|
let nextIndex: number | undefined
|
||||||
|
let folders: GroupFileInfo['item'] = []
|
||||||
|
while (nextIndex !== 0) {
|
||||||
|
const res = await this.ctx.ntGroupApi.getGroupFileList(groupId, {
|
||||||
|
sortType: 1,
|
||||||
|
fileCount: 100,
|
||||||
|
startIndex: nextIndex ?? 0,
|
||||||
|
sortOrder: 2,
|
||||||
|
showOnlinedocFolder: 0,
|
||||||
|
folderId
|
||||||
|
})
|
||||||
|
const file = res.item.find(item => item.fileInfo?.fileId === fileId)
|
||||||
|
if (file) {
|
||||||
|
modelId = file.fileInfo?.fileModelId
|
||||||
|
break
|
||||||
|
}
|
||||||
|
folders.push(...res.item.filter(item => item.folderInfo?.totalFileCount))
|
||||||
|
nextIndex = res.nextIndex
|
||||||
|
}
|
||||||
|
if (!modelId) {
|
||||||
|
for (const item of folders) {
|
||||||
|
const res = await this.search(groupId, fileId, item.folderInfo?.folderId)
|
||||||
|
if (res) {
|
||||||
|
modelId = res
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BaseAction, Schema } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot11/types'
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot11/types'
|
||||||
import { OnGroupFileInfoUpdateParams } from '@/ntqqapi/types'
|
import { GroupFileInfo } from '@/ntqqapi/types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number | string
|
group_id: number | string
|
||||||
@ -22,7 +22,7 @@ export class GetGroupFilesByFolder extends BaseAction<Payload, Response> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const groupId = payload.group_id.toString()
|
const groupId = payload.group_id.toString()
|
||||||
const data: OnGroupFileInfoUpdateParams['item'] = []
|
const data: GroupFileInfo['item'] = []
|
||||||
|
|
||||||
let nextIndex: number | undefined
|
let nextIndex: number | undefined
|
||||||
while (nextIndex !== 0) {
|
while (nextIndex !== 0) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BaseAction, Schema } from '../BaseAction'
|
import { BaseAction, Schema } from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { OB11GroupFile, OB11GroupFileFolder } from '../../types'
|
import { OB11GroupFile, OB11GroupFileFolder } from '../../types'
|
||||||
import { OnGroupFileInfoUpdateParams } from '@/ntqqapi/types'
|
import { GroupFileInfo } from '@/ntqqapi/types'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number | string
|
group_id: number | string
|
||||||
@ -20,7 +20,7 @@ export class GetGroupRootFiles extends BaseAction<Payload, Response> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const groupId = payload.group_id.toString()
|
const groupId = payload.group_id.toString()
|
||||||
const data: OnGroupFileInfoUpdateParams['item'] = []
|
const data: GroupFileInfo['item'] = []
|
||||||
|
|
||||||
let nextIndex: number | undefined
|
let nextIndex: number | undefined
|
||||||
while (nextIndex !== 0) {
|
while (nextIndex !== 0) {
|
||||||
|
@ -72,7 +72,3 @@ export function encodeCQCode(input: OB11MessageData) {
|
|||||||
result += ']'
|
result += ']'
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// const result = parseCQCode("[CQ:at,qq=114514]早上好啊[CQ:image,file=http://baidu.com/1.jpg,type=show,id=40004]")
|
|
||||||
// const result = parseCQCode("好好好")
|
|
||||||
// console.log(JSON.stringify(result))
|
|
||||||
|
@ -98,8 +98,15 @@ export interface OB11Message {
|
|||||||
temp_source?: 0 | 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9
|
temp_source?: 0 | 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OB11ForwardMessage extends OB11Message {
|
export interface OB11ForwardMessage {
|
||||||
content: OB11MessageData[] | string
|
content: OB11MessageData[] | string
|
||||||
|
sender: {
|
||||||
|
nickname: string
|
||||||
|
user_id: number
|
||||||
|
}
|
||||||
|
time: number
|
||||||
|
message_format: string //扩展
|
||||||
|
message_type: string //扩展
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OB11Return<DataType> {
|
export interface OB11Return<DataType> {
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = '3.33.8'
|
export const version = '3.33.9'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user