Compare commits

...

19 Commits

Author SHA1 Message Date
linyuchen
dcaa07dc1c ver: 2.4.1 2024-02-04 22:19:22 +08:00
linyuchen
5194c279d8 fix: 修复上传file://格式的文件时会误删原文件 2024-02-04 22:00:23 +08:00
linyuchen
b830cfbfa0 style: syntax error 2024-02-04 10:34:57 +08:00
linyuchen
ce25c9752f ver: 2.4.0 2024-02-04 10:29:50 +08:00
linyuchen
5e00aee176 Merge branch 'dev'
# Conflicts:
#	src/renderer.ts
2024-02-04 10:29:10 +08:00
linyuchen
a25c1b24fc feat: 新增开关控制是否上报自己发送的消息 2024-02-04 10:26:20 +08:00
linyuchen
afed1b8575 Merge pull request #22 from YuChuXi/dev_report
添加上报自身消息设置项
2024-02-04 10:05:25 +08:00
linyuchen
0fe58c1965 Merge branch 'dev' into dev_report 2024-02-04 10:05:02 +08:00
linyuchen
b3cae5f1c6 feat: 新增开关控制是否上报自己发送的消息 2024-02-04 10:00:13 +08:00
YuChuXi
d09fc78747 改了文本 2024-02-04 03:04:02 +08:00
YuChuXi
19d7ecd4f0 新增设置项:上报自身消息 2024-02-04 02:54:56 +08:00
linyuchen
070eee6c1c docs: README update 2024-02-03 19:31:22 +08:00
linyuchen
fe5e0ea4e0 Merge remote-tracking branch 'origin/main' 2024-02-03 19:29:08 +08:00
linyuchen
7ba7af13a8 ver: 2.3.0 2024-02-03 19:27:31 +08:00
linyuchen
fae61fbbde fix: 夜间模式输入框颜色
feat: log开关
2024-02-03 19:25:38 +08:00
linyuchen
a249139fe0 Update README.md 2024-02-03 16:08:57 +08:00
linyuchen
ebc3968c4e fix: 不支持的消息不再上报 2024-02-03 15:46:23 +08:00
linyuchen
3d03aec976 fix: 偶尔出现不能上报 2024-02-02 21:54:31 +08:00
linyuchen
083d3ddf67 docs: update 2024-01-31 19:29:25 +08:00
6 changed files with 63 additions and 45 deletions

View File

@@ -1,6 +1,5 @@
# LLOneBot API
将NTQQLiteLoaderAPI封装成OneBot11/12标准的API, V12没有完整测试
*注意:本文档对应的是 LiteLoader 1.0.0及以上版本如果你使用的是旧版本请切换到本项目v1分支查看文档*
@@ -105,24 +104,11 @@
</details>
<br/>
<details>
<summary>撤回消息无效</summary>
<br/>
如果接口调用的传的`message`是number类型会导致精度丢失使用string类型可解决详情见<a href="https://github.com/linyuchen/LiteLoaderQQNT-OneBotApi/issues/17">issue#17</a>
</details>
<br/>
<details>
<summary>如何查看日志</summary>
<br/>
LiteLoaderQQNT/data/LLOneBot/*.log
</details>
<br/>
## TODO
- [x] 接口返回更详细的错误信息,目前消息发不出去也会返回发送成功(这河里吗)
- [ ] 转发消息记录
- [ ] 好友点赞api
- [ ] 支持websocket等个有缘人提PR实现
- [ ] 重构摆脱LLAPI目前调用LLAPI只能在renderer进程调用需重构成在main进程调用

View File

@@ -4,7 +4,7 @@
"name": "LLOneBot",
"slug": "LLOneBot",
"description": "LiteLoaderQQNT的OneBotApi",
"version": "2.2.0",
"version": "2.4.1",
"thumbnail": "./icon.png",
"authors": [{
"name": "linyuchen",

View File

@@ -181,15 +181,17 @@ export interface PostDataSendMsg {
}
export interface Config {
port: number,
hosts: string[],
port: number
hosts: string[]
enableBase64?: boolean
debug?: boolean
reportSelfMessage?: boolean
log?: boolean
}
export interface SendMsgResult {
status: number,
retcode: number,
data: any,
message: string,
status: number
retcode: number
data: any
message: string
}

View File

@@ -18,7 +18,7 @@ import {
} from "../common/IPCChannel";
import {ConfigUtil} from "./config";
import {startExpress} from "./HttpServer";
import {checkFileReceived, CONFIG_DIR, isGIF, log} from "./utils";
import {checkFileReceived, CONFIG_DIR, getConfigUtil, isGIF, log} from "./utils";
import {friends, groups, selfInfo} from "./data";
import {} from "../global";
@@ -32,10 +32,7 @@ function onLoad() {
log("main onLoaded");
// const config_dir = browserWindow.LiteLoader.plugins["LLOneBot"].path.data;
function getConfigUtil() {
const configFilePath = path.join(CONFIG_DIR, `config_${selfInfo.user_id}.json`)
return new ConfigUtil(configFilePath)
}
if (!fs.existsSync(CONFIG_DIR)) {
fs.mkdirSync(CONFIG_DIR, {recursive: true});

View File

@@ -1,11 +1,21 @@
import * as path from "path";
import {json} from "express";
import {selfInfo} from "./data";
import {ConfigUtil} from "./config";
const fs = require('fs');
export const CONFIG_DIR = global.LiteLoader.plugins["LLOneBot"].path.data;
export function getConfigUtil() {
const configFilePath = path.join(CONFIG_DIR, `config_${selfInfo.user_id}.json`)
return new ConfigUtil(configFilePath)
}
export function log(msg: any) {
if (!getConfigUtil().getConfig().log){
return
}
let currentDateTime = new Date().toLocaleString();
const date = new Date();
const year = date.getFullYear();
@@ -44,4 +54,4 @@ export function checkFileReceived(path: string, timeout: number=3000): Promise<v
check();
});
}
}

View File

@@ -1,7 +1,5 @@
/// <reference path="./global.d.ts" />
// import express from "express";
// const { ipcRenderer } = require('electron');
import {
AtType,
ChatType,
@@ -13,7 +11,6 @@ import {
SendMsgResult,
User
} from "./common/types";
import {checkFileReceived} from "./main/utils";
let self_qq: string = ""
let groups: Group[] = []
@@ -125,7 +122,7 @@ async function getGroupMember(group_qq: string, member_uid: string) {
async function handleNewMessage(messages: MessageElement[]) {
console.log("llonebot 收到消息:", messages);
const {debug, enableBase64} = await window.llonebot.getConfig();
const {debug, enableBase64, reportSelfMessage} = await window.llonebot.getConfig();
for (let message of messages) {
let onebot_message_data: any = {
self: {
@@ -236,14 +233,20 @@ async function handleNewMessage(messages: MessageElement[]) {
}
}
}
onebot_message_data.message.push(message_data)
if (message_data.type !== "unknown"){
onebot_message_data.message.push(message_data);
}
}
if (msgHistory.length > 10000) {
msgHistory.splice(0, 100)
}
msgHistory.push(message)
console.log("发送上传消息给ipc main", onebot_message_data)
window.llonebot.postData(onebot_message_data);
if (!reportSelfMessage && onebot_message_data["user_id"] == self_qq){
console.log("开启了不上传自己发送的消息,进行拦截 ", onebot_message_data);
} else {
console.log("发送上传消息给ipc main", onebot_message_data);
window.llonebot.postData(onebot_message_data);
}
}
}
@@ -297,7 +300,6 @@ async function listenSendMessage(postData: PostDataSendMsg) {
name: group.name,
uid: group.uid
}
} else {
sendMsgResult.status = -1;
sendMsgResult.retcode = -1;
@@ -357,9 +359,9 @@ async function listenSendMessage(postData: PostDataSendMsg) {
} else {
localFilePath = path;
}
sendFiles.push(localFilePath);
}
message.file = localFilePath
sendFiles.push(localFilePath);
} else if (message.type == "reply") {
let msgId = message.data?.id || message.msgId
let replyMessage = msgHistory.find(msg => msg.raw.msgId == msgId)
@@ -590,7 +592,7 @@ async function onSettingWindowCreated(view: Element) {
hostsEleStr += creatHostEleStr(host);
}
let html = `
<div class="config_view">
<div class="config_view llonebot">
<setting-section>
<setting-panel>
<setting-list class="wrap">
@@ -622,16 +624,35 @@ async function onSettingWindowCreated(view: Element) {
</div>
<setting-switch id="debug" ${config.debug ? "is-active" : ""}></setting-switch>
</setting-item>
<setting-item data-direction="row" class="hostItem vertical-list-item">
<div>
<div>上报自身消息</div>
<div class="tips">开启后上报自己发出的消息</div>
</div>
<setting-switch id="reportSelfMessage" ${config.reportSelfMessage ? "is-active" : ""}></setting-switch>
</setting-item>
<setting-item data-direction="row" class="hostItem vertical-list-item">
<div>
<div>日志</div>
<div class="tips">日志目录:${window.LiteLoader.plugins["LLOneBot"].path.data}</div>
</div>
<setting-switch id="log" ${config.log ? "is-active" : ""}></setting-switch>
</setting-item>
</setting-panel>
</setting-section>
</div>
<style>
setting-panel {
padding: 10px;
}
.tips {
font-size: 0.75rem;
<style>
setting-panel {
padding: 10px;
}
.tips {
font-size: 0.75rem;
}
@media (prefers-color-scheme: dark){
.llonebot input {
color: white;
}
}
</style>
`
@@ -665,6 +686,8 @@ async function onSettingWindowCreated(view: Element) {
switchClick("debug", "debug");
switchClick("switchBase64", "enableBase64");
switchClick("reportSelfMessage", "reportSelfMessage");
switchClick("log", "log");
doc.getElementById("save")?.addEventListener("click",
() => {
@@ -698,4 +721,4 @@ setTimeout(onLoad, 5000)
export {
onSettingWindowCreated
}
}