mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6fe5cb1ffd | ||
![]() |
4d1d890f72 | ||
![]() |
fe0f82fa2b | ||
![]() |
84083a65a8 | ||
![]() |
fc91c6bc08 | ||
![]() |
09120171ba | ||
![]() |
a362f920dc | ||
![]() |
9d7729f548 | ||
![]() |
ed56e177cf | ||
![]() |
9db28bd502 | ||
![]() |
aded70eb2e | ||
![]() |
dfbad85465 | ||
![]() |
52076fe182 | ||
![]() |
5575c3cb13 | ||
![]() |
637d32efff | ||
![]() |
fd54658e53 | ||
![]() |
2f39a8d76e | ||
![]() |
6a3e793500 | ||
![]() |
3b3ffeda6b | ||
![]() |
f7d92a3b11 | ||
![]() |
d9d9ba8bf1 | ||
![]() |
f5d9090183 | ||
![]() |
705ecd1ef1 | ||
![]() |
08b5266a86 | ||
![]() |
ecc4846ba8 | ||
![]() |
4aab705d11 | ||
![]() |
4615a68bcc | ||
![]() |
bf6934e8ac | ||
![]() |
af8c304bd4 | ||
![]() |
51dac5a5a8 | ||
![]() |
56463d9e36 | ||
![]() |
a6a339dc59 | ||
![]() |
8423304ab5 | ||
![]() |
bb7408dbe9 | ||
![]() |
7eff4dcf02 | ||
![]() |
d7ee3fec3d | ||
![]() |
d66ab7d389 |
@@ -3,7 +3,7 @@ module.exports = {
|
||||
'es2021': true,
|
||||
'node': true
|
||||
},
|
||||
'ignorePatterns': ['src/core/'],
|
||||
'ignorePatterns': ['src/core/', 'src/core.lib/'],
|
||||
'extends': [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended'
|
||||
|
81
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
81
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Bug 反馈
|
||||
description: 报告可能的 NapCat 异常行为
|
||||
title: '[BUG] '
|
||||
labels: bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
欢迎来到 NapCat 的 Issue Tracker!请填写以下表格来提交 Bug。
|
||||
在提交新的 Bug 反馈前,请确保您:
|
||||
* 已经搜索了现有的 issues,并且没有找到可以解决您问题的方法
|
||||
* 不与现有的某一 issue 重复
|
||||
- type: input
|
||||
id: system-version
|
||||
attributes:
|
||||
label: 系统版本
|
||||
description: 运行 QQNT 的系统版本
|
||||
placeholder: Windows 10 Pro Workstation 22H2
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: qqnt-version
|
||||
attributes:
|
||||
label: QQNT 版本
|
||||
description: 可在 QQNT 的「关于」的设置页中找到
|
||||
placeholder: 9.9.7-21804
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: napcat-version
|
||||
attributes:
|
||||
label: NapCat 版本
|
||||
description: 可在 LiteLoaderQQNT 的设置页或是 QQNT 的设置页侧栏中找到
|
||||
placeholder: 1.0.0
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: onebot-client-version
|
||||
attributes:
|
||||
label: OneBot 客户端
|
||||
description: 连接至 NapCat 的客户端版本信息
|
||||
placeholder: Overflow 2.16.0-2cf7991-SNAPSHOT
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: 发生了什么?
|
||||
description: 填写你认为的 NapCat 的不正常行为
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: how-reproduce
|
||||
attributes:
|
||||
label: 如何复现
|
||||
description: 填写应当如何操作才能触发这个不正常行为
|
||||
placeholder: |
|
||||
1. xxx
|
||||
2. xxx
|
||||
3. xxx
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-expected
|
||||
attributes:
|
||||
label: 期望的结果?
|
||||
description: 填写你认为 NapCat 应当执行的正常行为
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: napcat-log
|
||||
attributes:
|
||||
label: NapCat 运行日志
|
||||
description: 粘贴相关日志内容到此处
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: onebot-client-log
|
||||
attributes:
|
||||
label: OneBot 客户端运行日志
|
||||
description: 粘贴 OneBot 客户端的相关日志内容到此处
|
||||
render: shell
|
67
.github/workflows/build.yml
vendored
Normal file
67
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: "Build"
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
if: ${{ startsWith(github.event.head_commit.message, 'build:') }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target_platform: [linux,darwin]
|
||||
target_arch: [x64, arm64]
|
||||
steps:
|
||||
- name: Clone Main Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'NapNeko/NapCatQQ'
|
||||
submodules: true
|
||||
token: ${{ secrets.NAPCAT_BUILD }}
|
||||
- name: Use Node.js 20.X
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
- name: Build NuCat Linux
|
||||
run: |
|
||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
npm run build:prod
|
||||
cd dist
|
||||
npm i --omit=dev --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
cd ..
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: NapCat.${{ matrix.target_platform }}.${{ matrix.target_arch }}
|
||||
path: dist
|
||||
build-win32:
|
||||
if: ${{ startsWith(github.event.head_commit.message, 'build:') }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target_platform: [win32]
|
||||
target_arch: [x64]
|
||||
steps:
|
||||
- name: Clone Main Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'NapNeko/NapCatQQ'
|
||||
submodules: true
|
||||
token: ${{ secrets.NAPCAT_BUILD }}
|
||||
- name: Use Node.js 20.X
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
- name: Build NuCat Linux
|
||||
run: |
|
||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
npm run build:prod
|
||||
cd dist
|
||||
npm i --omit=dev --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
cd ..
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: NapCat.${{ matrix.target_platform }}.${{ matrix.target_arch }}
|
||||
path: dist
|
36
.github/workflows/release.yml
vendored
36
.github/workflows/release.yml
vendored
@@ -1,10 +1,34 @@
|
||||
name: "release"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
check-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract version from tag
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||
|
||||
- name: Use Node.js 20.X
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Check Version
|
||||
run: |
|
||||
ls
|
||||
node ./script/checkVersion.cjs
|
||||
sh ./checkVersion.sh
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
@@ -16,13 +40,14 @@ jobs:
|
||||
- name: Clone Main Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'NapNeko/NapCat'
|
||||
repository: 'NapNeko/NapCatQQ'
|
||||
submodules: true
|
||||
token: ${{ secrets.NAPCAT_BUILD }}
|
||||
- name: Use Node.js 20.X
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 20.x
|
||||
|
||||
- name: Build NuCat Linux
|
||||
run: |
|
||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
@@ -46,13 +71,15 @@ jobs:
|
||||
- name: Clone Main Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'NapNeko/NapCat'
|
||||
repository: 'NapNeko/NapCatQQ'
|
||||
submodules: true
|
||||
token: ${{ secrets.NAPCAT_BUILD }}
|
||||
|
||||
- name: Use Node.js 20.X
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Build NuCat Linux
|
||||
run: |
|
||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
@@ -60,11 +87,13 @@ jobs:
|
||||
cd dist
|
||||
npm i --omit=dev --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||
cd ..
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: NapCat.${{ matrix.target_platform }}.${{ matrix.target_arch }}
|
||||
path: dist
|
||||
|
||||
release-napcat:
|
||||
needs: [build-win32,build-linux]
|
||||
runs-on: ubuntu-latest
|
||||
@@ -78,6 +107,7 @@ jobs:
|
||||
base=$(basename "$dir")
|
||||
zip -r "${base}.zip" "$dir"
|
||||
done
|
||||
|
||||
- name: Create Release Draft and Upload Artifacts
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ src/core.lib/common/
|
||||
|
||||
# Build
|
||||
*.db
|
||||
checkVersion.sh
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 NapCatQQ
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
13
README.md
13
README.md
@@ -18,7 +18,7 @@ NapCatQQ(瞌睡猫QQ,不准叫我NCQQ!),像睡着了一样在后台低
|
||||
|
||||
## 启动
|
||||
|
||||
NapCat 是基于 官方NTQQ 实现的Bot框架,因此先需要安装官方QQ
|
||||
NapCat 是基于 官方NTQQ 实现的Bot框架,因此先需要安装官方QQ,**注意同个账号不能同时登录原版 QQ 和 NapCatQQ**
|
||||
|
||||
*如果没有安装 QQ 请往后翻查看安装方法*
|
||||
|
||||
@@ -64,7 +64,9 @@ json 配置内容参数解释:
|
||||
|
||||
### Windows 启动
|
||||
|
||||
运行`powershell ./napcat.ps1`, 或者 `napcat.bat`,如果出现乱码,可以尝试运行`napcat_utf8.ps1`
|
||||
运行`powershell ./napcat.ps1`, 或者 `napcat.bat`,如果出现乱码,可以尝试运行`napcat-utf8.ps1` 或 `napcat-utf8.bat`
|
||||
|
||||
*如果出现 powershell 运行不了,以管理员身份打开 powershell,输入 `Set-ExecutionPolicy RemoteSigned`*
|
||||
|
||||
### Linux 启动
|
||||
|
||||
@@ -82,15 +84,13 @@ json 配置内容参数解释:
|
||||
|
||||
目前还在研究怎么精简安装,暂时只能安装官方QQ整体依赖
|
||||
|
||||
```bash
|
||||
下载QQ的deb包
|
||||
下载QQ
|
||||
|
||||
[deb x86版本](https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_amd64_01.deb)
|
||||
[deb arm版本](https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_arm64_01.deb)
|
||||
|
||||
[rpm x86版本](https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_x86_64_01.rpm)
|
||||
[rpm arm版本](https://dldir1.qq.com/qqfile/qq/QQNT/Linux/QQ_3.2.7_240403_aarch64_01.rpm)
|
||||
```
|
||||
|
||||
```bash
|
||||
sudo apt install ./qq.deb
|
||||
@@ -141,6 +141,9 @@ $env:FFMPEG_PATH="d:\ffmpeg\bin\ffmpeg.exe"
|
||||
|
||||
不用管,这是正常现象,是因为 QQ 本身的问题,不影响使用
|
||||
|
||||
## API 文档
|
||||
|
||||
参考 [LLOneBot](https://llonebot.github.io/zh-CN/develop/api) 的文档
|
||||
|
||||
<!--
|
||||
QQ群:545402644
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"scripts": {
|
||||
"watch:dev": "vite --mode development",
|
||||
"watch:prod": "vite --mode production",
|
||||
|
15
script/checkVersion.cjs
Normal file
15
script/checkVersion.cjs
Normal file
@@ -0,0 +1,15 @@
|
||||
let fs = require("fs");
|
||||
let process = require("process")
|
||||
console.log("[NapCat] [CheckVersion] 开始检测当前仓库版本...");
|
||||
let currentVersion = require("../package.json").version;
|
||||
let targetVersion = process.env.VERSION;
|
||||
console.log("[NapCat] [CheckVersion] currentVersion:", currentVersion, " targetVersion:", targetVersion);
|
||||
// fs.mkdirSync("./dist");
|
||||
if (currentVersion === targetVersion) {
|
||||
fs.appendFileSync("../checkVersion.sh", "#!/bin/bashe\necho \"CheckVersion Is Done\"")
|
||||
} else {
|
||||
let packageJson = JSON.parse(fs.readFileSync("./package.json"));
|
||||
packageJson.version = targetVersion;
|
||||
fs.writeFileSync("../package.json", JSON.stringify(packageJson));
|
||||
fs.appendFileSync("../checkVersion.sh", "#!/bin/bashe\ngit add .\n git commit -m \"chore:version change\"\n git push")
|
||||
}
|
21
script/gen-version.ts
Normal file
21
script/gen-version.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { version } from '../src/onebot11/version'
|
||||
|
||||
const manifestPath = path.join(__dirname, '../package.json')
|
||||
|
||||
function readManifest (): any {
|
||||
if (fs.existsSync(manifestPath)) {
|
||||
return JSON.parse(fs.readFileSync(manifestPath, 'utf-8'))
|
||||
}
|
||||
}
|
||||
|
||||
function writeManifest (manifest: any) {
|
||||
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2))
|
||||
}
|
||||
|
||||
const manifest = readManifest()
|
||||
if (version !== manifest.version) {
|
||||
manifest.version = version
|
||||
writeManifest(manifest)
|
||||
}
|
3
script/napcat-custom.bat
Normal file
3
script/napcat-custom.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
chcp 65001
|
||||
set ELECTRON_RUN_AS_NODE=1
|
||||
"H:\Program Files\QQNT最新版\QQ.exe" %~dp0/napcat.cjs %*
|
@@ -8,7 +8,6 @@ import { dbUtil } from './db';
|
||||
import * as fileType from 'file-type';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { napCatCore } from '@/core';
|
||||
import os from 'node:os';
|
||||
|
||||
export const getNapCatDir = () => {
|
||||
const p = path.join(napCatCore.wrapper.dataPath, 'NapCat');
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import crypto from 'node:crypto';
|
||||
import { resolve } from 'dns';
|
||||
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// QQ等级换算
|
||||
import { QQLevel } from '../../ntqqapi/types';
|
||||
import { QQLevel } from '@/core/qqnt/entities';
|
||||
|
||||
export function calcQQLevel(level: QQLevel) {
|
||||
const { crownNum, sunNum, moonNum, starNum } = level;
|
||||
return crownNum * 64 + sunNum * 16 + moonNum * 4 + starNum;
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +1,38 @@
|
||||
import { request } from "https";
|
||||
import { request } from 'https';
|
||||
export function noifyLoginStatus() {
|
||||
let req = request(
|
||||
{
|
||||
hostname: 'napcat.wumiao.wang',
|
||||
path: '/api/send',
|
||||
port: 443,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0`
|
||||
}
|
||||
},
|
||||
(res) => {
|
||||
//let data = '';
|
||||
res.on('data', (chunk) => {
|
||||
//data += chunk;
|
||||
});
|
||||
res.on('end', () => {
|
||||
//console.log('Response:', data);
|
||||
});
|
||||
}
|
||||
);
|
||||
let StatesData = {
|
||||
type: "event",
|
||||
payload: {
|
||||
"website": "952bf82f-8f49-4456-aec5-e17db5f27f7e",
|
||||
"hostname": "napcat.demo.cn",
|
||||
"screen": "1920x1080",
|
||||
"language": "zh-CN",
|
||||
"title": "OneBot.Login",
|
||||
"url": "/login/onebot11",
|
||||
"referrer": "https://napcat.demo.cn/login?type=onebot11"
|
||||
}
|
||||
};
|
||||
req.write(JSON.stringify(StatesData));
|
||||
req.end();
|
||||
const req = request(
|
||||
{
|
||||
hostname: 'napcat.wumiao.wang',
|
||||
path: '/api/send',
|
||||
port: 443,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0'
|
||||
}
|
||||
},
|
||||
(res) => {
|
||||
//let data = '';
|
||||
res.on('data', (chunk) => {
|
||||
//data += chunk;
|
||||
});
|
||||
res.on('end', () => {
|
||||
//console.log('Response:', data);
|
||||
});
|
||||
}
|
||||
);
|
||||
const StatesData = {
|
||||
type: 'event',
|
||||
payload: {
|
||||
'website': '952bf82f-8f49-4456-aec5-e17db5f27f7e',
|
||||
'hostname': 'napcat.demo.cn',
|
||||
'screen': '1920x1080',
|
||||
'language': 'zh-CN',
|
||||
'title': 'OneBot.Login',
|
||||
'url': '/login/onebot11',
|
||||
'referrer': 'https://napcat.demo.cn/login?type=onebot11'
|
||||
}
|
||||
};
|
||||
req.write(JSON.stringify(StatesData));
|
||||
req.end();
|
||||
}
|
@@ -1,44 +1,44 @@
|
||||
import { get as httpsGet } from "node:https";
|
||||
import { get as httpsGet } from 'node:https';
|
||||
function requestMirror(url: string): Promise<string | undefined> {
|
||||
return new Promise((resolve, reject) => {
|
||||
httpsGet(url, (response) => {
|
||||
let data = '';
|
||||
response.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
httpsGet(url, (response) => {
|
||||
let data = '';
|
||||
response.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
response.on('end', () => {
|
||||
try {
|
||||
const parsedData = JSON.parse(data);
|
||||
const version = parsedData.version;
|
||||
resolve(version);
|
||||
} catch (error) {
|
||||
// 解析失败或无法访问域名,跳过
|
||||
resolve(undefined);
|
||||
}
|
||||
});
|
||||
}).on('error', (error) => {
|
||||
// 请求失败,跳过
|
||||
resolve(undefined);
|
||||
});
|
||||
response.on('end', () => {
|
||||
try {
|
||||
const parsedData = JSON.parse(data);
|
||||
const version = parsedData.version;
|
||||
resolve(version);
|
||||
} catch (error) {
|
||||
// 解析失败或无法访问域名,跳过
|
||||
resolve(undefined);
|
||||
}
|
||||
});
|
||||
}).on('error', (error) => {
|
||||
// 请求失败,跳过
|
||||
resolve(undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function checkVersion(): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const MirrorList =
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const MirrorList =
|
||||
[
|
||||
"https://fastly.jsdelivr.net/gh/NapNeko/NapCatQQ@main/package.json",
|
||||
"https://gcore.jsdelivr.net/gh/NapNeko/NapCatQQ@main/package.json",
|
||||
"https://cdn.jsdelivr.us/gh/NapNeko/NapCatQQ@main/package.json",
|
||||
"https://jsd.cdn.zzko.cn/gh/NapNeko/NapCatQQ@main/package.json"
|
||||
'https://fastly.jsdelivr.net/gh/NapNeko/NapCatQQ@main/package.json',
|
||||
'https://gcore.jsdelivr.net/gh/NapNeko/NapCatQQ@main/package.json',
|
||||
'https://cdn.jsdelivr.us/gh/NapNeko/NapCatQQ@main/package.json',
|
||||
'https://jsd.cdn.zzko.cn/gh/NapNeko/NapCatQQ@main/package.json'
|
||||
];
|
||||
for (const url of MirrorList) {
|
||||
const version = await requestMirror(url);
|
||||
if (version) {
|
||||
resolve(version);
|
||||
}
|
||||
}
|
||||
reject("get verison error!");
|
||||
});
|
||||
for (const url of MirrorList) {
|
||||
const version = await requestMirror(url);
|
||||
if (version) {
|
||||
resolve(version);
|
||||
}
|
||||
}
|
||||
reject('get verison error!');
|
||||
});
|
||||
}
|
@@ -7,6 +7,7 @@ import { ActionName } from '../types';
|
||||
|
||||
interface Payload {
|
||||
message_id: string; // long msg id
|
||||
id?: string; // short msg id
|
||||
}
|
||||
|
||||
interface Response {
|
||||
@@ -17,7 +18,7 @@ export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
const rootMsg = await dbUtil.getMsgByLongId(payload.message_id);
|
||||
const rootMsg = await dbUtil.getMsgByLongId( payload.id || payload.message_id);
|
||||
if (!rootMsg) {
|
||||
throw Error('msg not found');
|
||||
}
|
||||
@@ -38,6 +39,6 @@ export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
(<OB11ForwardMessage>msg).content = msg.message;
|
||||
delete (<any>msg).message;
|
||||
});
|
||||
return {messages};
|
||||
return { messages };
|
||||
}
|
||||
}
|
||||
|
@@ -3,16 +3,18 @@ import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { groups } from '@/common/data';
|
||||
import {NTQQGroupApi} from "@/core/qqnt/apis";
|
||||
|
||||
|
||||
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
||||
actionName = ActionName.GetGroupList;
|
||||
|
||||
protected async _handle(payload: null) {
|
||||
// if (groups.length === 0) {
|
||||
// const groups = await NTQQGroupApi.getGroups(true)
|
||||
// log("get groups", groups)
|
||||
// }
|
||||
if (groups.size === 0) {
|
||||
//todo: get groups
|
||||
// const groups = await NTQQGroupApi.getGroups(true)
|
||||
// log("get groups", groups)
|
||||
}
|
||||
return OB11Constructor.groups(Array.from(groups.values()));
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import SendLike from './user/SendLike';
|
||||
import SetGroupAddRequest from './group/SetGroupAddRequest';
|
||||
import SetGroupLeave from './group/SetGroupLeave';
|
||||
import GetGuildList from './group/GetGuildList';
|
||||
import Debug from './llonebot/Debug';
|
||||
import Debug from '@/onebot11/action/extends/Debug';
|
||||
import SetFriendAddRequest from './user/SetFriendAddRequest';
|
||||
import SetGroupWholeBan from './group/SetGroupWholeBan';
|
||||
import SetGroupName from './group/SetGroupName';
|
||||
@@ -37,9 +37,9 @@ import GetRecord from './file/GetRecord';
|
||||
import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead';
|
||||
import CleanCache from './system/CleanCache';
|
||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||
import { GetConfigAction, SetConfigAction } from './llonebot/Config';
|
||||
import GetGroupAddRequest from './llonebot/GetGroupAddRequest';
|
||||
import SetQQAvatar from './llonebot/SetQQAvatar';
|
||||
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
|
||||
import GetGroupAddRequest from '@/onebot11/action/extends/GetGroupAddRequest';
|
||||
import SetQQAvatar from '@/onebot11/action/extends/SetQQAvatar';
|
||||
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
||||
import GoCQHTTPGetGroupMsgHistory from './go-cqhttp/GetGroupMsgHistory';
|
||||
import GetFile from './file/GetFile';
|
||||
|
@@ -160,7 +160,7 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
||||
// }
|
||||
// log("找到文件缓存", file);
|
||||
// }
|
||||
const {path, isLocal, fileName, errMsg} = (await uri2local(file));
|
||||
const { path, isLocal, fileName, errMsg } = (await uri2local(file));
|
||||
if (errMsg) {
|
||||
throw errMsg;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (this.getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
try {
|
||||
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group);
|
||||
return {message_id: returnMsg!.id!};
|
||||
return { message_id: returnMsg!.id! };
|
||||
} catch (e: any) {
|
||||
throw ('发送转发消息失败 ' + e.toString());
|
||||
}
|
||||
@@ -317,8 +317,8 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (this.getSpecialMsgNum(payload, OB11MessageDataType.music)) {
|
||||
const music: OB11MessageCustomMusic = messages[0] as OB11MessageCustomMusic;
|
||||
if (music) {
|
||||
const {url, audio, title, content, image} = music.data;
|
||||
const selfPeer: Peer = {peerUid: selfInfo.uid, chatType: ChatType.friend};
|
||||
const { url, audio, title, content, image } = music.data;
|
||||
const selfPeer: Peer = { peerUid: selfInfo.uid, chatType: ChatType.friend };
|
||||
// 搞不定!
|
||||
// const musicMsg = await this.send(selfPeer, [this.genMusicElement(url, audio, title, content, image)], [], false)
|
||||
// 转发
|
||||
@@ -329,12 +329,12 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
}
|
||||
}
|
||||
// log("send msg:", peer, sendElements)
|
||||
const {sendElements, deleteAfterSentFiles} = await createSendElements(messages, group);
|
||||
const { sendElements, deleteAfterSentFiles } = await createSendElements(messages, group);
|
||||
const returnMsg = await sendMsg(peer, sendElements, deleteAfterSentFiles);
|
||||
deleteAfterSentFiles.map(f => fs.unlink(f, () => {
|
||||
}));
|
||||
|
||||
const res = {message_id: returnMsg.id!};
|
||||
const res = { message_id: returnMsg.id! };
|
||||
// console.log(res);
|
||||
return res;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (nodeMsg) {
|
||||
nodeMsgArray.push(nodeMsg);
|
||||
if (!srcPeer) {
|
||||
srcPeer = {chatType: nodeMsg.chatType, peerUid: nodeMsg.peerUid};
|
||||
srcPeer = { chatType: nodeMsg.chatType, peerUid: nodeMsg.peerUid };
|
||||
} else if (srcPeer.peerUid !== nodeMsg.peerUid) {
|
||||
needSendSelf = true;
|
||||
srcPeer = selfPeer;
|
||||
@@ -501,7 +501,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
token: '5c1e4905f926dd3a64a4bd3841460351',
|
||||
type: 'normal'
|
||||
},
|
||||
extra: {app_type: 1, appid: 100497308, uin: selfInfo.uin},
|
||||
extra: { app_type: 1, appid: 100497308, uin: selfInfo.uin },
|
||||
meta: {
|
||||
news: {
|
||||
action: '',
|
||||
|
@@ -21,15 +21,16 @@ checkVersion().then((remoteVersion: string) => {
|
||||
const localVersion = require('./package.json').version;
|
||||
const localVersionList = localVersion.split('.');
|
||||
const remoteVersionList = remoteVersion.split('.');
|
||||
console.log('[NapCat] [Upate] 当前版本:', localVersion);
|
||||
for (const k of [0, 1, 2]) {
|
||||
if (parseInt(remoteVersionList[k]) > parseInt(localVersionList[k])) {
|
||||
console.log('检测到更新,请前往 https://github.com/NapNeko/NapCatQQ 下载 NapCatQQ V', remoteVersion);
|
||||
console.log('[NapCat] [Upate] 检测到更新,请前往 https://github.com/NapNeko/NapCatQQ 下载 NapCatQQ V', remoteVersion);
|
||||
return;
|
||||
} else if (parseInt(remoteVersionList[k]) < parseInt(localVersionList[k])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log('当前已是最新版本,版本:', localVersion);
|
||||
console.log('[NapCat] [Upate] 当前已是最新版本');
|
||||
return;
|
||||
});
|
||||
new NapCatOnebot11();
|
||||
@@ -52,7 +53,7 @@ napCatCore.on('system.login.qrcode', (qrCodeData: { url: string, base64: string
|
||||
fs.writeFile(qrcodePath, qrCodeData.base64.split('data:image/png;base64')[1], 'base64').then(() => {
|
||||
console.log('二维码已保存到', qrcodePath);
|
||||
});
|
||||
qrcode.generate(qrCodeData.url, {small: true}, (res) => {
|
||||
qrcode.generate(qrCodeData.url, { small: true }, (res) => {
|
||||
console.log(res);
|
||||
});
|
||||
});
|
||||
|
@@ -120,7 +120,7 @@ export class NapCatOnebot11 {
|
||||
}
|
||||
|
||||
async postReceiveMsg(msgList: RawMessage[]) {
|
||||
const {debug, reportSelfMessage} = ob11Config;
|
||||
const { debug, reportSelfMessage } = ob11Config;
|
||||
for (const message of msgList) {
|
||||
// console.log("ob11 收到新消息", message)
|
||||
// if (message.senderUin !== selfInfo.uin){
|
||||
@@ -298,38 +298,38 @@ export class NapCatOnebot11 {
|
||||
}
|
||||
}
|
||||
|
||||
async postGroupMemberChange(groupList: Group[]) {
|
||||
// todo: 有无更好的方法判断群成员变动
|
||||
const newGroupList = groupList;
|
||||
for (const group of newGroupList) {
|
||||
const existGroup = await getGroup(group.groupCode);
|
||||
if (existGroup) {
|
||||
if (existGroup.memberCount > group.memberCount) {
|
||||
log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
||||
const oldMembers = existGroup.members;
|
||||
const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode);
|
||||
group.members = newMembers;
|
||||
const newMembersSet = new Set<string>(); // 建立索引降低时间复杂度
|
||||
|
||||
for (const member of newMembers) {
|
||||
newMembersSet.add(member.uin);
|
||||
}
|
||||
|
||||
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||
const bot = await getGroupMember(group.groupCode, selfInfo.uin);
|
||||
if (bot!.role == GroupMemberRole.admin || bot!.role == GroupMemberRole.owner) {
|
||||
continue;
|
||||
}
|
||||
for (const member of oldMembers) {
|
||||
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), 'leave'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// async postGroupMemberChange(groupList: Group[]) {
|
||||
// // todo: 有无更好的方法判断群成员变动
|
||||
// const newGroupList = groupList;
|
||||
// for (const group of newGroupList) {
|
||||
// const existGroup = await getGroup(group.groupCode);
|
||||
// if (existGroup) {
|
||||
// if (existGroup.memberCount > group.memberCount) {
|
||||
// log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
||||
// const oldMembers = existGroup.members;
|
||||
// const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode);
|
||||
// group.members = newMembers;
|
||||
// const newMembersSet = new Set<string>(); // 建立索引降低时间复杂度
|
||||
//
|
||||
// for (const member of newMembers) {
|
||||
// newMembersSet.add(member.uin);
|
||||
// }
|
||||
//
|
||||
// // 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||
// const bot = await getGroupMember(group.groupCode, selfInfo.uin);
|
||||
// if (bot!.role == GroupMemberRole.admin || bot!.role == GroupMemberRole.owner) {
|
||||
// continue;
|
||||
// }
|
||||
// for (const member of oldMembers) {
|
||||
// if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||
// postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), 'leave'));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// export const napCatOneBot11 = new NapCatOnebot11();
|
||||
|
Reference in New Issue
Block a user