try send markdown

This commit is contained in:
linyuchen 2024-04-18 18:23:20 +08:00
parent 5a00d14f94
commit 22f74be4cd
2 changed files with 25 additions and 15 deletions

View File

@ -152,13 +152,11 @@ export async function createSendElements(messageData: OB11MessageData[], group:
if (cache) {
if (fs.existsSync(cache.path)) {
file = 'file://' + cache.path;
}
else if (cache.url) {
} else if (cache.url) {
file = cache.url;
}
else{
} else {
const fileMsg = await dbUtil.getMsgByLongId(cache.msgId);
if (fileMsg){
if (fileMsg) {
const downloadPath = await NTQQFileApi.downloadMedia(fileMsg.msgId, fileMsg.chatType, fileMsg.peerUid,
cache.elementId, '', '');
cache.path = downloadPath!;
@ -209,14 +207,20 @@ export async function createSendElements(messageData: OB11MessageData[], group:
sendElements.push(SendMsgElementConstructor.ark(sendMsg.data.data));
}
break;
case OB11MessageDataType.dice:{
case OB11MessageDataType.dice: {
const resultId = sendMsg.data?.result;
sendElements.push(SendMsgElementConstructor.dice(resultId));
}break;
case OB11MessageDataType.RPS:{
}
break;
case OB11MessageDataType.RPS: {
const resultId = sendMsg.data?.result;
sendElements.push(SendMsgElementConstructor.rps(resultId));
}break;
}
break;
case OB11MessageDataType.markdown: {
const content = sendMsg.data?.content;
sendElements.push(SendMsgElementConstructor.markdown(content));
}
}
}
@ -332,11 +336,10 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
if (this.getSpecialMsgNum(payload, OB11MessageDataType.node)) {
try {
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group);
if (returnMsg){
const msgShortId =await dbUtil.addMsg(returnMsg!, false);
if (returnMsg) {
const msgShortId = await dbUtil.addMsg(returnMsg!, false);
return { message_id: msgShortId };
}
else{
} else {
throw Error('发送转发消息失败');
}
} catch (e: any) {
@ -511,7 +514,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
// nodeIds.push(nodeMsg.msgId)
// await sleep(500);
// 开发转发
if (nodeMsgIds.length === 0){
if (nodeMsgIds.length === 0) {
throw Error('转发消息失败,生成节点为空');
}
try {

View File

@ -229,13 +229,20 @@ export interface OB11MessageRPS{
}
}
export interface OB11MessageMarkdown {
type: OB11MessageDataType.markdown
data: {
content: string
}
}
export type OB11MessageData =
OB11MessageText |
OB11MessageFace | OB11MessageMFace |
OB11MessageAt | OB11MessageReply |
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson |
OB11MessageDice | OB11MessageRPS
OB11MessageDice | OB11MessageRPS | OB11MessageMarkdown
export interface OB11PostSendMsg {
message_type?: 'private' | 'group'