Merge branch 'dev'

# Conflicts:
#	src/renderer.ts
This commit is contained in:
linyuchen 2024-02-04 10:29:10 +08:00
commit 5e00aee176
3 changed files with 12 additions and 13 deletions

View File

@ -1,6 +1,5 @@
# LLOneBot API
将NTQQLiteLoaderAPI封装成OneBot11/12标准的API, V12没有完整测试
*注意:本文档对应的是 LiteLoader 1.0.0及以上版本如果你使用的是旧版本请切换到本项目v1分支查看文档*

View File

@ -185,6 +185,7 @@ export interface Config {
hosts: string[]
enableBase64?: boolean
debug?: boolean
reportSelfMessage?: boolean
log?: boolean
reportSelfMessage?: boolean
}

View File

@ -124,9 +124,8 @@ async function getGroupMember(group_qq: string, member_uid: string) {
}
async function handleNewMessage(messages: MessageElement[]) {
const {reportSelfMessage} = await window.llonebot.getConfig();
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: {
@ -145,7 +144,6 @@ async function handleNewMessage(messages: MessageElement[]) {
raw_message: "",
font: 14
}
if (debug) {
onebot_message_data.raw = JSON.parse(JSON.stringify(message))
}
@ -246,11 +244,12 @@ async function handleNewMessage(messages: MessageElement[]) {
msgHistory.splice(0, 100)
}
msgHistory.push(message)
if (!reportSelfMessage && onebot_message_data?.user_id == self_qq) {
continue;
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);
}
console.log("发送上传消息给ipc main", onebot_message_data)
window.llonebot.postData(onebot_message_data);
}
}
@ -631,9 +630,10 @@ async function onSettingWindowCreated(view: Element) {
</setting-item>
<setting-item data-direction="row" class="hostItem vertical-list-item">
<div>
<div></div>
<div></div>
<div class="tips"></div>
</div>
<setting-switch id="sendSelf" ${config.reportSelfMessage ? "is-active" : ""}></setting-switch>
<setting-switch id="reportSelfMessage" ${config.reportSelfMessage ? "is-active" : ""}></setting-switch>
</setting-item>
<setting-item data-direction="row" class="hostItem vertical-list-item">
<div>
@ -642,7 +642,6 @@ async function onSettingWindowCreated(view: Element) {
</div>
<setting-switch id="log" ${config.log ? "is-active" : ""}></setting-switch>
</setting-item>
</setting-panel>
</setting-section>
</div>
@ -691,8 +690,8 @@ async function onSettingWindowCreated(view: Element) {
switchClick("debug", "debug");
switchClick("switchBase64", "enableBase64");
switchClick("reportSelfMessage", "reportSelfMessage");
switchClick("log", "log");
switchClick("sendSelf", "sendSelf");
doc.getElementById("save")?.addEventListener("click",
() => {
@ -726,4 +725,4 @@ setTimeout(onLoad, 5000)
export {
onSettingWindowCreated
}
}