mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8083ae4091 | ||
![]() |
465b7eaf6e | ||
![]() |
0a6a67738e | ||
![]() |
f9a3b60192 | ||
![]() |
15ea558721 | ||
![]() |
35c9ffc0b0 | ||
![]() |
7dde7cbc2b | ||
![]() |
515fc8afb4 | ||
![]() |
f341e9f6e1 | ||
![]() |
bfdb2835c6 | ||
![]() |
05c4d693e0 |
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 }}
|
@@ -1,9 +1,10 @@
|
||||
# LLOneBot API
|
||||
|
||||
注意:本文档对应的是 LiteLoader 1.0.0及以上版本,如果你使用的是旧版本请切换到本项目v1分支查看文档
|
||||
|
||||
将NTQQLiteLoaderAPI封装成OneBot11/12标准的API, V12没有完整测试
|
||||
|
||||
*注意:本文档对应的是 LiteLoader 1.0.0及以上版本,如果你使用的是旧版本请切换到本项目v1分支查看文档*
|
||||
|
||||
## 安装方法
|
||||
|
||||
1.安装[NTQQLiteLoader](https://liteloaderqqnt.github.io/guide/install.html)
|
||||
|
@@ -4,14 +4,14 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "LiteLoaderQQNT的OneBotApi",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.4",
|
||||
"thumbnail": "./icon.png",
|
||||
"authors": [{
|
||||
"name": "linyuchen",
|
||||
"link": "https://github.com/linyuchen"
|
||||
}],
|
||||
"repository": {
|
||||
"repo": "linyuchen/LLOneBot",
|
||||
"repo": "linyuchen/LiteLoaderQQNT-OneBotApi",
|
||||
"branch": "main",
|
||||
"release": {
|
||||
"tag": "latest",
|
||||
|
@@ -44,7 +44,7 @@ export type Group = {
|
||||
}
|
||||
|
||||
export type Peer = {
|
||||
chatType: "private" | "group"
|
||||
chatType: "private" | "group" | "friend"
|
||||
name: string
|
||||
uid: string // qq号
|
||||
}
|
||||
@@ -53,6 +53,7 @@ export type MessageElement = {
|
||||
raw: {
|
||||
msgId: string,
|
||||
msgSeq: string,
|
||||
senderUin: string; // 发送者QQ号
|
||||
elements: {
|
||||
replyElement: {
|
||||
senderUid: string, // 原消息发送者QQ号
|
||||
@@ -98,7 +99,6 @@ export type MessageElement = {
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
peer: Peer,
|
||||
sender: {
|
||||
uid: string // 一串加密的字符串
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import {log} from "./utils";
|
||||
|
||||
const express = require("express");
|
||||
const bodyParser = require('body-parser');
|
||||
import {sendIPCRecallQQMsg, sendIPCSendQQMsg} from "./IPCSend";
|
||||
import {OnebotGroupMemberRole, PostDataAction, PostDataSendMsg, SendMessage} from "../common/types";
|
||||
import {friends, groups, selfInfo} from "./data";
|
||||
@@ -146,8 +145,7 @@ export function startExpress(port: number) {
|
||||
const app = express();
|
||||
// 中间件,用于解析POST请求的请求体
|
||||
app.use(express.urlencoded({extended: true, limit: "500mb"}));
|
||||
app.use(bodyParser({limit: '500mb'}))
|
||||
app.use(express.json());
|
||||
app.use(express.json({limit: '500mb'}));
|
||||
|
||||
function parseToOnebot12(action: PostDataAction) {
|
||||
app.post('/' + action, (req: any, res: any) => {
|
||||
|
@@ -102,6 +102,7 @@ async function getGroupMember(group_qq: string, member_uid: string) {
|
||||
|
||||
|
||||
async function handleNewMessage(messages: MessageElement[]) {
|
||||
// console.log("llonebot 收到消息:", messages);
|
||||
for (let message of messages) {
|
||||
let onebot_message_data: any = {
|
||||
self: {
|
||||
@@ -116,7 +117,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
|
||||
@@ -130,10 +133,10 @@ async function handleNewMessage(messages: MessageElement[]) {
|
||||
card: groupMember!.cardName,
|
||||
role: OnebotGroupMemberRole[groupMember!.role]
|
||||
}
|
||||
console.log("收到群消息", onebot_message_data)
|
||||
} else if (message.peer.chatType == "private") {
|
||||
onebot_message_data["user_id"] = message.peer.uid
|
||||
let friend = await getFriend(message.sender.uid)
|
||||
// console.log("收到群消息", onebot_message_data)
|
||||
} else if (message.peer.chatType == "private" || message.peer.chatType == "friend") {
|
||||
onebot_message_data["user_id"] = message.raw.senderUin;
|
||||
let friend = await getFriend(message.raw.senderUin)
|
||||
onebot_message_data.sender = {
|
||||
user_id: friend!.uin,
|
||||
nickname: friend!.nickName
|
||||
@@ -227,7 +230,7 @@ async function listenSendMessage(postData: PostDataSendMsg) {
|
||||
} else if (message.type == "text") {
|
||||
message.content = message.data?.text || message.content
|
||||
} else if (message.type == "image" || message.type == "voice" || message.type == "record") {
|
||||
// todo: 收到的应该是uri格式的,需要转成本地的, uri格式有三种,http, file, base64
|
||||
// 收到的是uri格式的,需要转成本地的, uri格式有三种,http, file, base64
|
||||
let url = message.data?.file || message.file
|
||||
let uri = new URL(url);
|
||||
let ext: string;
|
||||
@@ -243,9 +246,9 @@ async function listenSendMessage(postData: PostDataSendMsg) {
|
||||
localFilePath = url.split("file://")[1]
|
||||
} else {
|
||||
localFilePath = await window.llonebot.downloadFile({uri: url, localFilePath: localFilePath})
|
||||
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)
|
||||
|
Reference in New Issue
Block a user