mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Merge pull request #7 from Rotten-LKZ/dev
feat: github actions for automatically publishing releases
This commit is contained in:
commit
515fc8afb4
36
.github/workflows/publish.yml
vendored
Normal file
36
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: "publish"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
|
||||||
|
- name: install dependenies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: zip
|
||||||
|
run: |
|
||||||
|
sudo apt install zip -y
|
||||||
|
cp manifest.json ./dist/manifest.json
|
||||||
|
zip LLOneBot.zip ./dist/* -j
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "LLOneBot.zip"
|
||||||
|
draft: true
|
||||||
|
token: ${{ secrets.RELEASE_TOKEN }}
|
@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "LiteLoaderQQNT的OneBotApi",
|
"description": "LiteLoaderQQNT的OneBotApi",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"thumbnail": "./icon.png",
|
"thumbnail": "./icon.png",
|
||||||
"authors": [{
|
"authors": [{
|
||||||
"name": "linyuchen",
|
"name": "linyuchen",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import {log} from "./utils";
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
import {sendIPCRecallQQMsg, sendIPCSendQQMsg} from "./IPCSend";
|
import {sendIPCRecallQQMsg, sendIPCSendQQMsg} from "./IPCSend";
|
||||||
@ -45,9 +47,10 @@ function checkSendMessage(sendMsgList: SendMessage[]) {
|
|||||||
// ==end==
|
// ==end==
|
||||||
|
|
||||||
function handlePost(jsonData: any) {
|
function handlePost(jsonData: any) {
|
||||||
|
log("API receive post:" + JSON.stringify(jsonData))
|
||||||
if (!jsonData.params) {
|
if (!jsonData.params) {
|
||||||
jsonData.params = jsonData
|
jsonData.params = JSON.parse(JSON.stringify(jsonData));
|
||||||
|
delete jsonData.params.params;
|
||||||
}
|
}
|
||||||
let resData = {
|
let resData = {
|
||||||
status: 0,
|
status: 0,
|
||||||
|
@ -8,6 +8,7 @@ function sendIPCMsg(channel: string, data: any) {
|
|||||||
try {
|
try {
|
||||||
content.send(channel, data)
|
content.send(channel, data)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log("llonebot send ipc msg to render error:", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ contextBridge.exposeInMainWorld("llonebot", {
|
|||||||
ipcRenderer.send(CHANNEL_UPDATE_FRIENDS, friends);
|
ipcRenderer.send(CHANNEL_UPDATE_FRIENDS, friends);
|
||||||
},
|
},
|
||||||
listenSendMessage: (handle: (jsonData: PostDataSendMsg) => void) => {
|
listenSendMessage: (handle: (jsonData: PostDataSendMsg) => void) => {
|
||||||
|
ipcRenderer.send(CHANNEL_LOG, "发送消息API已注册");
|
||||||
ipcRenderer.on(CHANNEL_SEND_MSG, (event: any, args: PostDataSendMsg) => {
|
ipcRenderer.on(CHANNEL_SEND_MSG, (event: any, args: PostDataSendMsg) => {
|
||||||
handle(args)
|
handle(args)
|
||||||
})
|
})
|
||||||
|
228
src/renderer.ts
228
src/renderer.ts
@ -116,7 +116,9 @@ async function handleNewMessage(messages: MessageElement[]) {
|
|||||||
detail_type: message.peer.chatType,
|
detail_type: message.peer.chatType,
|
||||||
message_id: message.raw.msgId,
|
message_id: message.raw.msgId,
|
||||||
sub_type: "",
|
sub_type: "",
|
||||||
message: []
|
message: [],
|
||||||
|
raw_message: "",
|
||||||
|
font: 14
|
||||||
}
|
}
|
||||||
if (message.peer.chatType == "group") {
|
if (message.peer.chatType == "group") {
|
||||||
let group_id = message.peer.uid
|
let group_id = message.peer.uid
|
||||||
@ -179,6 +181,7 @@ async function handleNewMessage(messages: MessageElement[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function listenSendMessage(postData: PostDataSendMsg) {
|
async function listenSendMessage(postData: PostDataSendMsg) {
|
||||||
|
console.log("收到发送消息请求", postData);
|
||||||
if (postData.action == "send_private_msg" || postData.action == "send_group_msg") {
|
if (postData.action == "send_private_msg" || postData.action == "send_group_msg") {
|
||||||
let peer: Peer | null = null;
|
let peer: Peer | null = null;
|
||||||
if (!postData.params) {
|
if (!postData.params) {
|
||||||
@ -308,7 +311,7 @@ async function initAccountInfo(){
|
|||||||
let accountInfo = await window.LLAPI.getAccountInfo();
|
let accountInfo = await window.LLAPI.getAccountInfo();
|
||||||
window.llonebot.log("getAccountInfo " + JSON.stringify(accountInfo));
|
window.llonebot.log("getAccountInfo " + JSON.stringify(accountInfo));
|
||||||
if (!accountInfo.uid) {
|
if (!accountInfo.uid) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
let selfInfo = await window.LLAPI.getUserInfo(accountInfo.uid);
|
let selfInfo = await window.LLAPI.getUserInfo(accountInfo.uid);
|
||||||
window.llonebot.setSelfInfo({
|
window.llonebot.setSelfInfo({
|
||||||
@ -316,6 +319,7 @@ async function initAccountInfo(){
|
|||||||
nickname: selfInfo.nickName
|
nickname: selfInfo.nickName
|
||||||
});
|
});
|
||||||
window.llonebot.log("selfInfo " + JSON.stringify(selfInfo));
|
window.llonebot.log("selfInfo " + JSON.stringify(selfInfo));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
@ -325,7 +329,10 @@ function onLoad() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
initAccountInfo().then(
|
initAccountInfo().then(
|
||||||
()=>{
|
(initSuccess)=>{
|
||||||
|
if (!initSuccess) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (friends.length == 0) {
|
if (friends.length == 0) {
|
||||||
getFriends().then(()=>{});
|
getFriends().then(()=>{});
|
||||||
}
|
}
|
||||||
@ -346,104 +353,104 @@ function onLoad() {
|
|||||||
recallMessage(arg.message_id)
|
recallMessage(arg.message_id)
|
||||||
})
|
})
|
||||||
window.llonebot.log("llonebot loaded");
|
window.llonebot.log("llonebot loaded");
|
||||||
window.LLAPI.add_qmenu((qContextMenu: Node) => {
|
// window.LLAPI.add_qmenu((qContextMenu: Node) => {
|
||||||
let btn = document.createElement("a")
|
// let btn = document.createElement("a")
|
||||||
btn.className = "q-context-menu-item q-context-menu-item--normal vue-component"
|
// btn.className = "q-context-menu-item q-context-menu-item--normal vue-component"
|
||||||
btn.setAttribute("aria-disabled", "false")
|
// btn.setAttribute("aria-disabled", "false")
|
||||||
btn.setAttribute("role", "menuitem")
|
// btn.setAttribute("role", "menuitem")
|
||||||
btn.setAttribute("tabindex", "-1")
|
// btn.setAttribute("tabindex", "-1")
|
||||||
btn.onclick = () => {
|
// btn.onclick = () => {
|
||||||
// window.LLAPI.getPeer().then(peer => {
|
// // window.LLAPI.getPeer().then(peer => {
|
||||||
// // console.log("current peer", peer)
|
// // // console.log("current peer", peer)
|
||||||
// if (peer && peer.chatType == "group") {
|
// // if (peer && peer.chatType == "group") {
|
||||||
// getGroupMembers(peer.uid, true).then(()=> {
|
// // getGroupMembers(peer.uid, true).then(()=> {
|
||||||
// console.log("获取群成员列表成功", groups);
|
// // console.log("获取群成员列表成功", groups);
|
||||||
// alert("获取群成员列表成功")
|
// // alert("获取群成员列表成功")
|
||||||
// })
|
// // })
|
||||||
// }
|
// // }
|
||||||
// })
|
// // })
|
||||||
async function func() {
|
// async function func() {
|
||||||
for (const group of groups) {
|
// for (const group of groups) {
|
||||||
await getGroupMembers(group.uid, true)
|
// await getGroupMembers(group.uid, true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
func().then(() => {
|
// func().then(() => {
|
||||||
console.log("获取群成员列表结果", groups);
|
// console.log("获取群成员列表结果", groups);
|
||||||
// 找到members数量为空的群
|
// // 找到members数量为空的群
|
||||||
groups.map(group => {
|
// groups.map(group => {
|
||||||
if (group.members.length == 0) {
|
// if (group.members.length == 0) {
|
||||||
console.log(`${group.name}群成员为空`)
|
// console.log(`${group.name}群成员为空`)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
window.llonebot.updateGroups(groups)
|
// window.llonebot.updateGroups(groups)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
btn.innerText = "获取群成员列表"
|
// btn.innerText = "获取群成员列表"
|
||||||
console.log(qContextMenu)
|
// console.log(qContextMenu)
|
||||||
// qContextMenu.appendChild(btn)
|
// // qContextMenu.appendChild(btn)
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
window.LLAPI.on("context-msg-menu", (event, target, msgIds) => {
|
// window.LLAPI.on("context-msg-menu", (event, target, msgIds) => {
|
||||||
console.log("msg menu", event, target, msgIds);
|
// console.log("msg menu", event, target, msgIds);
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
// console.log("getAccountInfo", LLAPI.getAccountInfo());
|
// // console.log("getAccountInfo", LLAPI.getAccountInfo());
|
||||||
function getChatListEle() {
|
// function getChatListEle() {
|
||||||
chatListEle = document.getElementsByClassName("viewport-list__inner")
|
// chatListEle = document.getElementsByClassName("viewport-list__inner")
|
||||||
console.log("chatListEle", chatListEle)
|
// console.log("chatListEle", chatListEle)
|
||||||
if (chatListEle.length == 0) {
|
// if (chatListEle.length == 0) {
|
||||||
setTimeout(getChatListEle, 500)
|
// setTimeout(getChatListEle, 500)
|
||||||
} else {
|
// } else {
|
||||||
try {
|
// try {
|
||||||
// 选择要观察的目标节点
|
// // 选择要观察的目标节点
|
||||||
const targetNode = chatListEle[0];
|
// const targetNode = chatListEle[0];
|
||||||
|
//
|
||||||
// 创建一个观察器实例并传入回调函数
|
// // 创建一个观察器实例并传入回调函数
|
||||||
const observer = new MutationObserver(function (mutations) {
|
// const observer = new MutationObserver(function (mutations) {
|
||||||
mutations.forEach(function (mutation) {
|
// mutations.forEach(function (mutation) {
|
||||||
// console.log("chat list changed", mutation.type); // 输出 mutation 的类型
|
// // console.log("chat list changed", mutation.type); // 输出 mutation 的类型
|
||||||
// 获得当前聊天窗口
|
// // 获得当前聊天窗口
|
||||||
window.LLAPI.getPeer().then(peer => {
|
// window.LLAPI.getPeer().then(peer => {
|
||||||
// console.log("current peer", peer)
|
// // console.log("current peer", peer)
|
||||||
if (peer && peer.chatType == "group") {
|
// if (peer && peer.chatType == "group") {
|
||||||
getGroupMembers(peer.uid, false).then()
|
// getGroupMembers(peer.uid, false).then()
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
// 配置观察选项
|
// // 配置观察选项
|
||||||
const config = {attributes: true, childList: true, subtree: true};
|
// const config = {attributes: true, childList: true, subtree: true};
|
||||||
|
//
|
||||||
// 传入目标节点和观察选项
|
// // 传入目标节点和观察选项
|
||||||
observer.observe(targetNode, config);
|
// observer.observe(targetNode, config);
|
||||||
|
//
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
window.llonebot.log(e)
|
// window.llonebot.log(e)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// getChatListEle();
|
// // getChatListEle();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开设置界面时触发
|
// 打开设置界面时触发
|
||||||
async function onSettingWindowCreated (view: any) {
|
async function onSettingWindowCreated (view: Element) {
|
||||||
window.llonebot.log("setting window created");
|
window.llonebot.log("setting window created");
|
||||||
const {port, hosts} = await window.llonebot.getConfig()
|
const {port, hosts} = await window.llonebot.getConfig()
|
||||||
|
|
||||||
function creatHostEleStr(host: string) {
|
function creatHostEleStr(host: string) {
|
||||||
let eleStr = `
|
let eleStr = `
|
||||||
<div class="hostItem vertical-list-item">
|
<setting-item data-direction="row" class="hostItem vertical-list-item">
|
||||||
<h2>事件上报地址(http)</h2>
|
<h2>事件上报地址(http)</h2>
|
||||||
<input class="host" type="text" value="${host}"
|
<input class="host input-text" type="text" value="${host}"
|
||||||
style="width:60%;padding: 5px"
|
style="width:60%;padding: 5px"
|
||||||
placeholder="不支持localhost,如果是本机请填写局域网ip"/>
|
placeholder="如果localhost上报失败试试局域网ip"/>
|
||||||
</div>
|
</setting-item>
|
||||||
`
|
`
|
||||||
return eleStr
|
return eleStr
|
||||||
}
|
}
|
||||||
@ -452,20 +459,26 @@ async function onSettingWindowCreated (view: any) {
|
|||||||
for (const host of hosts) {
|
for (const host of hosts) {
|
||||||
hostsEleStr += creatHostEleStr(host);
|
hostsEleStr += creatHostEleStr(host);
|
||||||
}
|
}
|
||||||
const html = `
|
let html = `
|
||||||
<section class="wrap">
|
<div class="config_view">
|
||||||
<div class="vertical-list-item">
|
<setting-section>
|
||||||
<h2>监听端口</h2>
|
<setting-panel style="padding: 10px">
|
||||||
<input id="port" type="number" value="${port}"/>
|
<setting-list class="wrap">
|
||||||
</div>
|
<setting-item class="vertical-list-item" data-direction="row">
|
||||||
<div>
|
<setting-text>监听端口</setting-text>
|
||||||
<button id="addHost" class="q-button">添加上报地址</button>
|
<input id="port" type="number" value="${port}"/>
|
||||||
</div>
|
</setting-item>
|
||||||
<div id="hostItems">
|
<div>
|
||||||
${hostsEleStr}
|
<button id="addHost" class="q-button">添加上报地址</button>
|
||||||
</div>
|
</div>
|
||||||
<button id="save" class="q-button">保存(监听端口重启QQ后生效)</button>
|
<div id="hostItems">
|
||||||
</section>
|
${hostsEleStr}
|
||||||
|
</div>
|
||||||
|
<button id="save" class="q-button">保存(监听端口重启QQ后生效)</button>
|
||||||
|
</setting-list>
|
||||||
|
</setting-panel>
|
||||||
|
</setting-section>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
@ -474,7 +487,7 @@ async function onSettingWindowCreated (view: any) {
|
|||||||
|
|
||||||
function addHostEle(initValue: string = "") {
|
function addHostEle(initValue: string = "") {
|
||||||
let addressDoc = parser.parseFromString(creatHostEleStr(initValue), "text/html");
|
let addressDoc = parser.parseFromString(creatHostEleStr(initValue), "text/html");
|
||||||
let addressEle = addressDoc.querySelector("div")
|
let addressEle = addressDoc.querySelector("setting-item")
|
||||||
let hostItemsEle = document.getElementById("hostItems");
|
let hostItemsEle = document.getElementById("hostItems");
|
||||||
hostItemsEle.appendChild(addressEle);
|
hostItemsEle.appendChild(addressEle);
|
||||||
}
|
}
|
||||||
@ -502,15 +515,14 @@ async function onSettingWindowCreated (view: any) {
|
|||||||
})
|
})
|
||||||
alert("保存成功");
|
alert("保存成功");
|
||||||
})
|
})
|
||||||
doc.querySelectorAll("section").forEach((node) => view.appendChild(node));
|
doc.body.childNodes.forEach(node => {
|
||||||
|
view.appendChild(node);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(onLoad, 2000)
|
||||||
|
|
||||||
|
|
||||||
onLoad()
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
onSettingWindowCreated
|
onSettingWindowCreated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user