mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: report forward msg,get_forward_msg
This commit is contained in:
parent
ca0a6cfb22
commit
b55f35549d
@ -16,6 +16,17 @@ export interface Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
|
static async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
||||||
|
return await callNTQQApi<GeneralCallResult & {msgList: RawMessage[]}>({
|
||||||
|
methodName: NTQQApiMethod.GET_MULTI_MSG,
|
||||||
|
args: [{
|
||||||
|
peer,
|
||||||
|
rootMsgId,
|
||||||
|
parentMsgId
|
||||||
|
}, null]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
static async activateGroupChat(groupCode: string) {
|
static async activateGroupChat(groupCode: string) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
|
@ -25,6 +25,8 @@ export enum NTQQApiMethod {
|
|||||||
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
|
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
|
||||||
HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
||||||
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
|
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
|
||||||
|
GET_MULTI_MSG = "nodeIKernelMsgService/getMultiMsg",
|
||||||
|
|
||||||
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
|
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
|
||||||
SELF_INFO = "fetchAuthData",
|
SELF_INFO = "fetchAuthData",
|
||||||
FRIENDS = "nodeIKernelBuddyService/getBuddyList",
|
FRIENDS = "nodeIKernelBuddyService/getBuddyList",
|
||||||
|
@ -279,6 +279,34 @@ export interface VideoElement {
|
|||||||
"sourceVideoCodecFormat"?: number
|
"sourceVideoCodecFormat"?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MarkdownElement {
|
||||||
|
content: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InlineKeyboardElementRowButton{
|
||||||
|
"id": "",
|
||||||
|
"label": string,
|
||||||
|
"visitedLabel": string,
|
||||||
|
"style": 1, // 未知
|
||||||
|
"type": 2, // 未知
|
||||||
|
"clickLimit": 0, // 未知
|
||||||
|
"unsupportTips": "请升级新版手机QQ",
|
||||||
|
"data": string,
|
||||||
|
"atBotShowChannelList": false,
|
||||||
|
"permissionType": 2,
|
||||||
|
"specifyRoleIds": [],
|
||||||
|
"specifyTinyids": [],
|
||||||
|
"isReply": false,
|
||||||
|
"anchor": 0,
|
||||||
|
"enter": false,
|
||||||
|
"subscribeDataTemplateIds": []
|
||||||
|
}
|
||||||
|
export interface InlineKeyboardElement {
|
||||||
|
rows: [{
|
||||||
|
buttons: InlineKeyboardElementRowButton[]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
export interface TipAioOpGrayTipElement { // 这是什么提示来着?
|
||||||
operateType: number,
|
operateType: number,
|
||||||
peerUid: string,
|
peerUid: string,
|
||||||
@ -329,6 +357,11 @@ export interface TipGroupElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MultiForwardMsgElement{
|
||||||
|
xmlContent: string, // xml格式的消息内容
|
||||||
|
resId: string,
|
||||||
|
fileName: string,
|
||||||
|
}
|
||||||
|
|
||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
msgId: string;
|
msgId: string;
|
||||||
@ -367,5 +400,8 @@ export interface RawMessage {
|
|||||||
videoElement: VideoElement;
|
videoElement: VideoElement;
|
||||||
fileElement: FileElement;
|
fileElement: FileElement;
|
||||||
marketFaceElement: MarketFaceElement;
|
marketFaceElement: MarketFaceElement;
|
||||||
|
inlineKeyboardElement: InlineKeyboardElement;
|
||||||
|
markdownElement: MarkdownElement;
|
||||||
|
multiForwardMsgElement: MultiForwardMsgElement;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
39
src/onebot11/action/go-cqhttp/GetForwardMsg.ts
Normal file
39
src/onebot11/action/go-cqhttp/GetForwardMsg.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import BaseAction from "../BaseAction";
|
||||||
|
import {OB11ForwardMessage, OB11Message, OB11MessageData} from "../../types";
|
||||||
|
import {NTQQMsgApi, Peer} from "../../../ntqqapi/api";
|
||||||
|
import {dbUtil} from "../../../common/db";
|
||||||
|
import {OB11Constructor} from "../../constructor";
|
||||||
|
import {ActionName} from "../types";
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
message_id: string; // long msg id
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Response{
|
||||||
|
messages: (OB11Message & {content: OB11MessageData})[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any>{
|
||||||
|
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
||||||
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
const rootMsg = await dbUtil.getMsgByLongId(payload.message_id)
|
||||||
|
if (!rootMsg){
|
||||||
|
throw Error("msg not found")
|
||||||
|
}
|
||||||
|
let data = await NTQQMsgApi.getMultiMsg({chatType: rootMsg.chatType, peerUid: rootMsg.peerUid}, rootMsg.msgId, rootMsg.msgId)
|
||||||
|
if (data.result !== 0){
|
||||||
|
throw Error("找不到相关的聊天记录" + data.errMsg)
|
||||||
|
}
|
||||||
|
let msgList = data.msgList
|
||||||
|
let messages = await Promise.all(msgList.map(async msg => {
|
||||||
|
let resMsg = await OB11Constructor.message(msg)
|
||||||
|
resMsg.message_id = await dbUtil.addMsg(msg);
|
||||||
|
return resMsg
|
||||||
|
}))
|
||||||
|
messages.map(msg => {
|
||||||
|
(<OB11ForwardMessage>msg).content = msg.message;
|
||||||
|
delete msg.message;
|
||||||
|
})
|
||||||
|
return {messages}
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,7 @@ import SetQQAvatar from './llonebot/SetQQAvatar'
|
|||||||
import GoCQHTTPDownloadFile from "./go-cqhttp/DownloadFile";
|
import GoCQHTTPDownloadFile from "./go-cqhttp/DownloadFile";
|
||||||
import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
|
import GoCQHTTPGetGroupMsgHistory from "./go-cqhttp/GetGroupMsgHistory";
|
||||||
import GetFile from "./file/GetFile";
|
import GetFile from "./file/GetFile";
|
||||||
|
import {GoCQHTTGetForwardMsgAction} from "./go-cqhttp/GetForwardMsg";
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new GetFile(),
|
new GetFile(),
|
||||||
@ -82,6 +83,7 @@ export const actionHandlers = [
|
|||||||
new GoCQHTTPMarkMsgAsRead(),
|
new GoCQHTTPMarkMsgAsRead(),
|
||||||
new GoCQHTTPUploadGroupFile(),
|
new GoCQHTTPUploadGroupFile(),
|
||||||
new GoCQHTTPGetGroupMsgHistory(),
|
new GoCQHTTPGetGroupMsgHistory(),
|
||||||
|
new GoCQHTTGetForwardMsgAction(),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -60,4 +60,5 @@ export enum ActionName {
|
|||||||
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
GoCQHTTP_UploadGroupFile = "upload_group_file",
|
||||||
GoCQHTTP_DownloadFile = "download_file",
|
GoCQHTTP_DownloadFile = "download_file",
|
||||||
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
GoCQHTTP_GetGroupMsgHistory = "get_group_msg_history",
|
||||||
|
GoCQHTTP_GetForwardMsg = "get_forward_msg",
|
||||||
}
|
}
|
@ -206,6 +206,12 @@ export class OB11Constructor {
|
|||||||
} else if (element.marketFaceElement) {
|
} else if (element.marketFaceElement) {
|
||||||
message_data["type"] = OB11MessageDataType.mface;
|
message_data["type"] = OB11MessageDataType.mface;
|
||||||
message_data["data"]["text"] = element.marketFaceElement.faceName;
|
message_data["data"]["text"] = element.marketFaceElement.faceName;
|
||||||
|
} else if (element.markdownElement){
|
||||||
|
message_data["type"] = OB11MessageDataType.markdown;
|
||||||
|
message_data["data"]["data"] = element.markdownElement.content;
|
||||||
|
} else if (element.multiForwardMsgElement){
|
||||||
|
message_data["type"] = OB11MessageDataType.forward;
|
||||||
|
message_data["data"]["id"] = msg.msgId
|
||||||
}
|
}
|
||||||
if (message_data.type !== "unknown" && message_data.data) {
|
if (message_data.type !== "unknown" && message_data.data) {
|
||||||
const cqCode = encodeCQCode(message_data);
|
const cqCode = encodeCQCode(message_data);
|
||||||
|
@ -88,6 +88,10 @@ export interface OB11Message {
|
|||||||
raw?: RawMessage
|
raw?: RawMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OB11ForwardMessage extends OB11Message {
|
||||||
|
content: OB11MessageData[] | string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface OB11Return<DataType> {
|
export interface OB11Return<DataType> {
|
||||||
status: string
|
status: string
|
||||||
retcode: number
|
retcode: number
|
||||||
@ -109,7 +113,10 @@ export enum OB11MessageDataType {
|
|||||||
json = "json",
|
json = "json",
|
||||||
face = "face",
|
face = "face",
|
||||||
mface = "mface", // 商城表情
|
mface = "mface", // 商城表情
|
||||||
node = "node", // 合并转发消息
|
markdown = "markdown",
|
||||||
|
node = "node", // 合并转发消息节点
|
||||||
|
forward = "forward", // 合并转发消息,用于上报
|
||||||
|
xml = "xml"
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OB11MessageMFace{
|
export interface OB11MessageMFace{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user