mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: _get_group_notice
API
This commit is contained in:
parent
544682fe41
commit
35bf4f001b
@ -8,7 +8,8 @@ import {
|
||||
GetFileListParam,
|
||||
PublishGroupBulletinReq,
|
||||
GroupAllInfo,
|
||||
GroupFileInfo
|
||||
GroupFileInfo,
|
||||
GroupBulletinListResult
|
||||
} from '../types'
|
||||
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||
import { GeneralCallResult } from '../services'
|
||||
@ -347,4 +348,33 @@ export class NTQQGroupApi extends Service {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async getGroupBulletinList(groupCode: string) {
|
||||
invoke('nodeIKernelGroupListener/onGetGroupBulletinListResult', [], { registerEvent: true })
|
||||
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||
return await invoke<{
|
||||
groupCode: string
|
||||
context: string
|
||||
result: GroupBulletinListResult
|
||||
}>(
|
||||
'nodeIKernelGroupService/getGroupBulletinList',
|
||||
[{
|
||||
groupCode,
|
||||
psKey,
|
||||
context: '',
|
||||
req: {
|
||||
startIndex: -1,
|
||||
num: 20,
|
||||
needInstructionsForJoinGroup: 1,
|
||||
needPublisherInfo: 1
|
||||
}
|
||||
}],
|
||||
{
|
||||
cbCmd: 'nodeIKernelGroupListener/onGetGroupBulletinListResult',
|
||||
cmdCB: payload => payload.groupCode === groupCode,
|
||||
afterFirstCmd: false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ export interface Group {
|
||||
hasModifyConfGroupName: boolean
|
||||
remarkName: string
|
||||
hasMemo: boolean
|
||||
groupShutupExpireTime: string //"0",
|
||||
personShutupExpireTime: string //"0",
|
||||
discussToGroupUin: string //"0",
|
||||
groupShutupExpireTime: string
|
||||
personShutupExpireTime: string
|
||||
discussToGroupUin: string
|
||||
discussToGroupMaxMsgSeq: number
|
||||
discussToGroupTime: number
|
||||
groupFlagExt: number //1073938496,
|
||||
@ -32,8 +32,8 @@ export interface Group {
|
||||
groupCreditLevel: number //0,
|
||||
groupFlagExt3: number //0,
|
||||
groupOwnerId: {
|
||||
memberUin: string //"0",
|
||||
memberUid: string //"u_fbf8N7aeuZEnUiJAbQ9R8Q"
|
||||
memberUin: string
|
||||
memberUid: string
|
||||
}
|
||||
members: GroupMember[] // 原始数据是没有这个的,为了方便自己加了这个字段
|
||||
createTime: string
|
||||
@ -120,3 +120,55 @@ export interface GroupAllInfo {
|
||||
joinGroupAuth: string
|
||||
isAllowModifyConfGroupName: number
|
||||
}
|
||||
|
||||
export interface GroupBulletinListResult {
|
||||
groupCode: string
|
||||
srvCode: number
|
||||
readOnly: number
|
||||
role: number
|
||||
inst: unknown[]
|
||||
feeds: {
|
||||
uin: string
|
||||
feedId: string
|
||||
publishTime: string
|
||||
msg: {
|
||||
text: string
|
||||
textFace: string
|
||||
pics: {
|
||||
id: string
|
||||
width: number
|
||||
height: number
|
||||
}[]
|
||||
title: string
|
||||
}
|
||||
type: number
|
||||
fn: number
|
||||
cn: number
|
||||
vn: number
|
||||
settings: {
|
||||
isShowEditCard: number
|
||||
remindTs: number
|
||||
tipWindowType: number
|
||||
confirmRequired: number
|
||||
}
|
||||
pinned: number
|
||||
readNum: number
|
||||
is_read: number
|
||||
is_all_confirm: number
|
||||
}[]
|
||||
groupInfo: {
|
||||
groupCode: string
|
||||
classId: number
|
||||
}
|
||||
gln: number
|
||||
tst: number
|
||||
publisherInfos: {
|
||||
uin: string
|
||||
nick: string
|
||||
avatar: string
|
||||
}[]
|
||||
server_time: string
|
||||
svrt: string
|
||||
nextIndex: number
|
||||
jointime: string
|
||||
}
|
||||
|
48
src/onebot11/action/go-cqhttp/GetGroupNotice.ts
Normal file
48
src/onebot11/action/go-cqhttp/GetGroupNotice.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { BaseAction, Schema } from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
group_id: number | string
|
||||
}
|
||||
|
||||
interface Notice {
|
||||
sender_id: number
|
||||
publish_time: number
|
||||
message: {
|
||||
text: string
|
||||
images: {
|
||||
height: string
|
||||
width: string
|
||||
id: string
|
||||
}[]
|
||||
}
|
||||
}
|
||||
|
||||
export class GetGroupNotice extends BaseAction<Payload, Notice[]> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupNotice
|
||||
payloadSchema = Schema.object({
|
||||
group_id: Schema.union([Number, String]).required()
|
||||
})
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
const data = await this.ctx.ntGroupApi.getGroupBulletinList(payload.group_id.toString())
|
||||
const result: Notice[] = []
|
||||
for (const feed of data.result.feeds) {
|
||||
result.push({
|
||||
sender_id: +feed.uin,
|
||||
publish_time: +feed.publishTime,
|
||||
message: {
|
||||
text: feed.msg.text,
|
||||
images: feed.msg.pics.map(image => {
|
||||
return {
|
||||
height: String(image.height),
|
||||
width: String(image.width),
|
||||
id: image.id
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
@ -70,6 +70,7 @@ import { GetFriendWithCategory } from './llonebot/GetFriendWithCategory'
|
||||
import { UploadGroupFile } from './go-cqhttp/UploadGroupFile'
|
||||
import { UploadPrivateFile } from './go-cqhttp/UploadPrivateFile'
|
||||
import { GetGroupFileUrl } from './go-cqhttp/GetGroupFileUrl'
|
||||
import { GetGroupNotice } from './go-cqhttp/GetGroupNotice'
|
||||
|
||||
export function initActionMap(adapter: Adapter) {
|
||||
const actionHandlers = [
|
||||
@ -144,7 +145,8 @@ export function initActionMap(adapter: Adapter) {
|
||||
new GetGroupRootFiles(adapter),
|
||||
new SendGroupNotice(adapter),
|
||||
new GetGroupFilesByFolder(adapter),
|
||||
new GetGroupFileUrl(adapter)
|
||||
new GetGroupFileUrl(adapter),
|
||||
new GetGroupNotice(adapter),
|
||||
]
|
||||
const actionMap = new Map<string, BaseAction<any, unknown>>()
|
||||
for (const action of actionHandlers) {
|
||||
|
@ -82,5 +82,6 @@ export enum ActionName {
|
||||
GoCQHTTP_GetGroupRootFiles = 'get_group_root_files',
|
||||
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
||||
GoCQHTTP_GetGroupFilesByFolder = 'get_group_files_by_folder',
|
||||
GoCQHTTP_GetGroupFileUrl = 'get_group_file_url'
|
||||
GoCQHTTP_GetGroupFileUrl = 'get_group_file_url',
|
||||
GoCQHTTP_GetGroupNotice = '_get_group_notice',
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user