Skip to content

Commit

Permalink
fix: check msgElement
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed May 16, 2024
1 parent 217bdf8 commit 430221c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/onebot11/action/msg/SendMsg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { ActionName, BaseCheckResult } from '@/onebot11/action/types';
import { getFriend, getGroup, getUidByUin } from '@/core/data';
import { dbUtil } from '@/core/utils/db';
import { ChatType, Group, NTQQMsgApi, Peer, SendMessageElement, } from '@/core';
import { ChatType, Group, NTQQMsgApi, Peer, SendMessageElement, } from '@/core';
import fs from 'node:fs';
import { logDebug } from '@/common/utils/log';
import { decodeCQCode } from '@/onebot11/cqcode';
Expand Down Expand Up @@ -101,7 +101,8 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {

protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
const messages = normalize(payload.message);
if (getSpecialMsgNum(payload, OB11MessageDataType.node) != messages.length) {
const nodeElementLength = getSpecialMsgNum(payload, OB11MessageDataType.node);
if (nodeElementLength > 0 && nodeElementLength != messages.length) {
return { valid: false, message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素' };
}
if (payload.message_type !== 'private' && payload.group_id && !(await getGroup(payload.group_id))) {
Expand Down

0 comments on commit 430221c

Please sign in to comment.