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