mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
22 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 | ||
![]() |
d66ab7d389 |
30
.github/workflows/release.yml
vendored
30
.github/workflows/release.yml
vendored
@@ -1,10 +1,34 @@
|
|||||||
name: "release"
|
name: "release"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
|
permissions: write-all
|
||||||
|
|
||||||
jobs:
|
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:
|
build-linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
@@ -23,6 +47,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
|
||||||
- name: Build NuCat Linux
|
- name: Build NuCat Linux
|
||||||
run: |
|
run: |
|
||||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||||
@@ -49,10 +74,12 @@ jobs:
|
|||||||
repository: 'NapNeko/NapCatQQ'
|
repository: 'NapNeko/NapCatQQ'
|
||||||
submodules: true
|
submodules: true
|
||||||
token: ${{ secrets.NAPCAT_BUILD }}
|
token: ${{ secrets.NAPCAT_BUILD }}
|
||||||
|
|
||||||
- name: Use Node.js 20.X
|
- name: Use Node.js 20.X
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
|
||||||
- name: Build NuCat Linux
|
- name: Build NuCat Linux
|
||||||
run: |
|
run: |
|
||||||
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
npm i --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||||
@@ -60,11 +87,13 @@ jobs:
|
|||||||
cd dist
|
cd dist
|
||||||
npm i --omit=dev --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
npm i --omit=dev --arch=${{ matrix.target_arch }} --platform=${{ matrix.target_platform }}
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: NapCat.${{ matrix.target_platform }}.${{ matrix.target_arch }}
|
name: NapCat.${{ matrix.target_platform }}.${{ matrix.target_arch }}
|
||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
release-napcat:
|
release-napcat:
|
||||||
needs: [build-win32,build-linux]
|
needs: [build-win32,build-linux]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -78,6 +107,7 @@ jobs:
|
|||||||
base=$(basename "$dir")
|
base=$(basename "$dir")
|
||||||
zip -r "${base}.zip" "$dir"
|
zip -r "${base}.zip" "$dir"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Create Release Draft and Upload Artifacts
|
- name: Create Release Draft and Upload Artifacts
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ src/core.lib/common/
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
*.db
|
*.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.
|
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 * as fileType from 'file-type';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { napCatCore } from '@/core';
|
import { napCatCore } from '@/core';
|
||||||
import os from 'node:os';
|
|
||||||
|
|
||||||
export const getNapCatDir = () => {
|
export const getNapCatDir = () => {
|
||||||
const p = path.join(napCatCore.wrapper.dataPath, 'NapCat');
|
const p = path.join(napCatCore.wrapper.dataPath, 'NapCat');
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import crypto from 'node:crypto';
|
import crypto from 'node:crypto';
|
||||||
import { resolve } from 'dns';
|
|
||||||
|
|
||||||
export function sleep(ms: number): Promise<void> {
|
export function sleep(ms: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// QQ等级换算
|
// QQ等级换算
|
||||||
import { QQLevel } from '../../ntqqapi/types';
|
import { QQLevel } from '@/core/qqnt/entities';
|
||||||
|
|
||||||
export function calcQQLevel(level: QQLevel) {
|
export function calcQQLevel(level: QQLevel) {
|
||||||
const { crownNum, sunNum, moonNum, starNum } = level;
|
const { crownNum, sunNum, moonNum, starNum } = level;
|
||||||
|
@@ -7,6 +7,7 @@ import { ActionName } from '../types';
|
|||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
message_id: string; // long msg id
|
message_id: string; // long msg id
|
||||||
|
id?: string; // short msg id
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
@@ -17,7 +18,7 @@ export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any> {
|
|||||||
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
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) {
|
if (!rootMsg) {
|
||||||
throw Error('msg not found');
|
throw Error('msg not found');
|
||||||
}
|
}
|
||||||
|
@@ -3,16 +3,18 @@ import { OB11Constructor } from '../../constructor';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { groups } from '@/common/data';
|
import { groups } from '@/common/data';
|
||||||
|
import {NTQQGroupApi} from "@/core/qqnt/apis";
|
||||||
|
|
||||||
|
|
||||||
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
||||||
actionName = ActionName.GetGroupList;
|
actionName = ActionName.GetGroupList;
|
||||||
|
|
||||||
protected async _handle(payload: null) {
|
protected async _handle(payload: null) {
|
||||||
// if (groups.length === 0) {
|
if (groups.size === 0) {
|
||||||
|
//todo: get groups
|
||||||
// const groups = await NTQQGroupApi.getGroups(true)
|
// const groups = await NTQQGroupApi.getGroups(true)
|
||||||
// log("get groups", groups)
|
// log("get groups", groups)
|
||||||
// }
|
}
|
||||||
return OB11Constructor.groups(Array.from(groups.values()));
|
return OB11Constructor.groups(Array.from(groups.values()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ import SendLike from './user/SendLike';
|
|||||||
import SetGroupAddRequest from './group/SetGroupAddRequest';
|
import SetGroupAddRequest from './group/SetGroupAddRequest';
|
||||||
import SetGroupLeave from './group/SetGroupLeave';
|
import SetGroupLeave from './group/SetGroupLeave';
|
||||||
import GetGuildList from './group/GetGuildList';
|
import GetGuildList from './group/GetGuildList';
|
||||||
import Debug from './llonebot/Debug';
|
import Debug from '@/onebot11/action/extends/Debug';
|
||||||
import SetFriendAddRequest from './user/SetFriendAddRequest';
|
import SetFriendAddRequest from './user/SetFriendAddRequest';
|
||||||
import SetGroupWholeBan from './group/SetGroupWholeBan';
|
import SetGroupWholeBan from './group/SetGroupWholeBan';
|
||||||
import SetGroupName from './group/SetGroupName';
|
import SetGroupName from './group/SetGroupName';
|
||||||
@@ -37,9 +37,9 @@ import GetRecord from './file/GetRecord';
|
|||||||
import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead';
|
import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead';
|
||||||
import CleanCache from './system/CleanCache';
|
import CleanCache from './system/CleanCache';
|
||||||
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
|
||||||
import { GetConfigAction, SetConfigAction } from './llonebot/Config';
|
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
|
||||||
import GetGroupAddRequest from './llonebot/GetGroupAddRequest';
|
import GetGroupAddRequest from '@/onebot11/action/extends/GetGroupAddRequest';
|
||||||
import SetQQAvatar from './llonebot/SetQQAvatar';
|
import SetQQAvatar from '@/onebot11/action/extends/SetQQAvatar';
|
||||||
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile';
|
||||||
import GoCQHTTPGetGroupMsgHistory from './go-cqhttp/GetGroupMsgHistory';
|
import GoCQHTTPGetGroupMsgHistory from './go-cqhttp/GetGroupMsgHistory';
|
||||||
import GetFile from './file/GetFile';
|
import GetFile from './file/GetFile';
|
||||||
|
@@ -21,15 +21,16 @@ checkVersion().then((remoteVersion: string) => {
|
|||||||
const localVersion = require('./package.json').version;
|
const localVersion = require('./package.json').version;
|
||||||
const localVersionList = localVersion.split('.');
|
const localVersionList = localVersion.split('.');
|
||||||
const remoteVersionList = remoteVersion.split('.');
|
const remoteVersionList = remoteVersion.split('.');
|
||||||
|
console.log('[NapCat] [Upate] 当前版本:', localVersion);
|
||||||
for (const k of [0, 1, 2]) {
|
for (const k of [0, 1, 2]) {
|
||||||
if (parseInt(remoteVersionList[k]) > parseInt(localVersionList[k])) {
|
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;
|
return;
|
||||||
} else if (parseInt(remoteVersionList[k]) < parseInt(localVersionList[k])) {
|
} else if (parseInt(remoteVersionList[k]) < parseInt(localVersionList[k])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('当前已是最新版本,版本:', localVersion);
|
console.log('[NapCat] [Upate] 当前已是最新版本');
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
new NapCatOnebot11();
|
new NapCatOnebot11();
|
||||||
|
@@ -298,38 +298,38 @@ export class NapCatOnebot11 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async postGroupMemberChange(groupList: Group[]) {
|
// async postGroupMemberChange(groupList: Group[]) {
|
||||||
// todo: 有无更好的方法判断群成员变动
|
// // todo: 有无更好的方法判断群成员变动
|
||||||
const newGroupList = groupList;
|
// const newGroupList = groupList;
|
||||||
for (const group of newGroupList) {
|
// for (const group of newGroupList) {
|
||||||
const existGroup = await getGroup(group.groupCode);
|
// const existGroup = await getGroup(group.groupCode);
|
||||||
if (existGroup) {
|
// if (existGroup) {
|
||||||
if (existGroup.memberCount > group.memberCount) {
|
// if (existGroup.memberCount > group.memberCount) {
|
||||||
log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
// log(`群(${group.groupCode})成员数量减少${existGroup.memberCount} -> ${group.memberCount}`);
|
||||||
const oldMembers = existGroup.members;
|
// const oldMembers = existGroup.members;
|
||||||
const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode);
|
// const newMembers = await NTQQGroupApi.getGroupMembers(group.groupCode);
|
||||||
group.members = newMembers;
|
// group.members = newMembers;
|
||||||
const newMembersSet = new Set<string>(); // 建立索引降低时间复杂度
|
// const newMembersSet = new Set<string>(); // 建立索引降低时间复杂度
|
||||||
|
//
|
||||||
for (const member of newMembers) {
|
// for (const member of newMembers) {
|
||||||
newMembersSet.add(member.uin);
|
// newMembersSet.add(member.uin);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
// // 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||||
const bot = await getGroupMember(group.groupCode, selfInfo.uin);
|
// const bot = await getGroupMember(group.groupCode, selfInfo.uin);
|
||||||
if (bot!.role == GroupMemberRole.admin || bot!.role == GroupMemberRole.owner) {
|
// if (bot!.role == GroupMemberRole.admin || bot!.role == GroupMemberRole.owner) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
for (const member of oldMembers) {
|
// for (const member of oldMembers) {
|
||||||
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
// if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), 'leave'));
|
// postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), 'leave'));
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const napCatOneBot11 = new NapCatOnebot11();
|
// export const napCatOneBot11 = new NapCatOnebot11();
|
||||||
|
Reference in New Issue
Block a user