diff --git a/src/main/HttpServer.ts b/src/main/HttpServer.ts index e496cc9..9df055e 100644 --- a/src/main/HttpServer.ts +++ b/src/main/HttpServer.ts @@ -4,6 +4,7 @@ const express = require("express"); const bodyParser = require('body-parser'); import {OnebotGroupMemberRole, PostDataAction, PostDataSendMsg} from "../common/types"; import {friends, groups, selfInfo} from "./data"; +import judgeMessage from "./utils"; function handlePost(jsonData: any) { if (!jsonData.params) { @@ -25,7 +26,18 @@ function handlePost(jsonData: any) { else { jsonData.message_type = "group" } - sendIPCSendQQMsg(jsonData); + // @SiberianHuskY 2021-10-20 22:00:00 + resData.status=judgeMessage(jsonData.message)||0; + if(resData.status==200){ + resData.message="发送成功"; + resData.data=jsonData.message; + sendIPCSendQQMsg(jsonData); + } + else{ + resData.message="发送失败"; + resData.data=jsonData.message; + } + // == end == } else if (jsonData.action == "get_group_list") { resData["data"] = groups.map(group => { return { diff --git a/src/main/utils.ts b/src/main/utils.ts index 50b4845..9960f46 100644 --- a/src/main/utils.ts +++ b/src/main/utils.ts @@ -1,3 +1,5 @@ +import { text } from "express"; + const fs = require('fs'); export function log(msg: any) { @@ -5,4 +7,39 @@ export function log(msg: any) { fs.appendFile("./llonebot.log", currentDateTime + ":" + msg + "\n", (err: any) => { }) -} \ No newline at end of file +} + +// @SiberianHusky 2021-08-15 +export default function judgeMessage(msg) { + if(msg[0]!=null&&msg[0]["type"]!=null&&msg[0]["data"]!=null){ + let type = msg[0]["type"]; + let data = msg[0]["data"]; + if(type == "text"){ + if (data["text"]!=""&&data["text"]!=null){ + return 200; + } + else if(type==="image"){ + if(data["file"]!=""&&data["file"]!=null){ + return 200; + } + } + else if(type==="voice"){ + if(data["file"]!=""&&data["file"]!=null){ + return 200; + } + } + else if(type==="at"){ + if(data["qq"]!=""&&data["qq"]!=null){ + return 200; + } + } + else if(type==="reply"){ + if(data["id"]!=""&&data["id"]!=null){ + return 200; + } + } + } + return 400; + } +} +// ==end== \ No newline at end of file