Merge pull request #2 from YDHusky/main

修改发送消息返回数据
This commit is contained in:
linyuchen 2023-12-09 14:46:16 +08:00 committed by GitHub
commit 5b4001e411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 2 deletions

View File

@ -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 {

View File

@ -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) => {
})
}
}
// @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==