mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # src/core.lib/src/adapters/NodeIDependsAdapter.js # src/core.lib/src/adapters/NodeIDispatcherAdapter.js # src/core.lib/src/adapters/NodeIGlobalAdapter.js # src/core.lib/src/adapters/index.js # src/core.lib/src/apis/file.js # src/core.lib/src/apis/friend.js # src/core.lib/src/apis/group.js # src/core.lib/src/apis/index.js # src/core.lib/src/apis/msg.js # src/core.lib/src/apis/sign.js # src/core.lib/src/apis/user.js # src/core.lib/src/apis/webapi.js # src/core.lib/src/core.js # src/core.lib/src/data.js # src/core.lib/src/entities/cache.js # src/core.lib/src/entities/constructor.js # src/core.lib/src/entities/group.js # src/core.lib/src/entities/index.js # src/core.lib/src/entities/msg.js # src/core.lib/src/entities/notify.js # src/core.lib/src/entities/user.js # src/core.lib/src/external/hook.js # src/core.lib/src/index.js # src/core.lib/src/listeners/NodeIKernelBuddyListener.js # src/core.lib/src/listeners/NodeIKernelFileAssistantListener.js # src/core.lib/src/listeners/NodeIKernelGroupListener.js # src/core.lib/src/listeners/NodeIKernelLoginListener.js # src/core.lib/src/listeners/NodeIKernelMsgListener.js # src/core.lib/src/listeners/NodeIKernelProfileListener.js # src/core.lib/src/listeners/NodeIKernelRobotListener.js # src/core.lib/src/listeners/NodeIKernelSessionListener.js # src/core.lib/src/listeners/NodeIKernelStorageCleanListener.js # src/core.lib/src/listeners/index.js # src/core.lib/src/services/common.js # src/core.lib/src/services/index.js # src/core.lib/src/sessionConfig.js # src/core.lib/src/utils/config.js # src/core.lib/src/utils/db.js # src/core.lib/src/utils/rkey.js # src/core.lib/src/wrapper.js
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
# v1.3.2
|
||||
# v1.3.5
|
||||
|
||||
QQ Version: Windows 9.9.9-23424 / Linux 3.2.7-23361
|
||||
|
||||
## 修复与优化
|
||||
* 重置Rkey获取机制,使用接口分发Rkey
|
||||
* 尝试修复多开崩溃问题
|
||||
* 修复群列表更新问题
|
||||
|
||||
## 新增与调整
|
||||
* 新增扩展获取好友分类列表 Api /get_friend_with_category
|
||||
* 新增设置群公告 Api
|
||||
|
||||
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.2",
|
||||
"scripts": {
|
||||
"watch:dev": "vite --mode development",
|
||||
"watch:prod": "vite --mode production",
|
||||
|
@@ -61,12 +61,12 @@ export abstract class HttpServerBase {
|
||||
this.listen(port, host);
|
||||
} catch (e: any) {
|
||||
logError('HTTP服务启动失败', e.toString());
|
||||
// llonebotError.httpServerError = "HTTP服务启动失败, " + e.toString()
|
||||
// httpServerError = "HTTP服务启动失败, " + e.toString()
|
||||
}
|
||||
}
|
||||
|
||||
stop() {
|
||||
// llonebotError.httpServerError = ""
|
||||
// httpServerError = ""
|
||||
if (this.server) {
|
||||
this.server.close();
|
||||
this.server = null;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// QQ等级换算
|
||||
import { QQLevel } from '../../core/src/entities';
|
||||
import { QQLevel } from '@/core/entities';
|
||||
|
||||
export function calcQQLevel(level: QQLevel) {
|
||||
const { crownNum, sunNum, moonNum, starNum } = level;
|
||||
|
@@ -1,15 +1,28 @@
|
||||
import { exit } from "process";
|
||||
import { resolve } from "path";
|
||||
async function reboot() {
|
||||
import { writeFile, writeFileSync } from "fs";
|
||||
async function rebootWithQuickLogin(uin: string) {
|
||||
let batScript = resolve(__dirname, './napcat.bat');
|
||||
let batUtf8Script = resolve(__dirname, './napcat-utf8.bat');
|
||||
let bashScript = resolve(__dirname, './napcat.sh');
|
||||
//如果是win系统写出 5s延迟启动 默认batUtf8Script启动
|
||||
// 如果是linux系统写出 5s延迟启动 默认bashScript启动
|
||||
if (process.platform === 'win32') {
|
||||
// console.log('正在重启...');
|
||||
writeFileSync(resolve(__dirname, './reboot-utf8.bat'), `
|
||||
@echo off
|
||||
timeout /t 5 /nobreak
|
||||
start /b /wait %~dp0\\napcat-utf8.bat -q ${uin}
|
||||
`);
|
||||
// 启动cmd执行脚本
|
||||
|
||||
} else if (process.platform === 'linux') {
|
||||
//console.log('正在重启...');
|
||||
writeFileSync(resolve(__dirname, './reboot.sh'), `
|
||||
#!/bin/bash
|
||||
timeout 5
|
||||
./napcat-utf8.sh -q ${uin}
|
||||
`);
|
||||
// 启动bash执行脚本
|
||||
|
||||
|
||||
|
||||
}
|
||||
exit(0);
|
||||
}
|
@@ -1,10 +1,18 @@
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
// 缓解Win7设备兼容性问题
|
||||
let osName: string;
|
||||
try {
|
||||
osName = os.hostname();
|
||||
} catch (e) {
|
||||
osName = "NapCat"
|
||||
|
||||
}
|
||||
export const systemPlatform = os.platform();
|
||||
export const cpuArch = os.arch();
|
||||
export const systemVersion = os.release();
|
||||
export const hostname = os.hostname();
|
||||
export const hostname = osName;
|
||||
const homeDir = os.homedir();
|
||||
export const downloadsPath = path.join(homeDir, 'Downloads');
|
||||
export const systemName = os.type();
|
||||
|
@@ -34,7 +34,7 @@ export function postLoginStatus() {
|
||||
'screen': '1920x1080',
|
||||
'language': 'zh-CN',
|
||||
'title': 'OneBot.Login',
|
||||
'url': '/login/onebot11/1.3.0',
|
||||
'url': '/login/onebot11/1.3.2',
|
||||
'referrer': 'https://napcat.demo.cn/login?type=onebot11'
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
58
src/onebot11/action/go-cqhttp/SendGroupNotice.ts
Normal file
58
src/onebot11/action/go-cqhttp/SendGroupNotice.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi, WebApi } from '@/core/apis';
|
||||
import { unlink } from 'node:fs';
|
||||
interface Payload {
|
||||
group_id: string;
|
||||
content: string;
|
||||
image?: string;
|
||||
pinned?: number;
|
||||
confirmRequired?: number;
|
||||
|
||||
}
|
||||
export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||
protected async _handle(payload: Payload) {
|
||||
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
||||
if (payload.image) {
|
||||
//公告图逻辑
|
||||
let Image_path, Image_errMsg, Image_IsLocal = false;
|
||||
let Uri2LocalRet = (await uri2local(payload.image));
|
||||
Image_errMsg = Uri2LocalRet.errMsg;
|
||||
Image_path = Uri2LocalRet.path;
|
||||
Image_IsLocal = Uri2LocalRet.isLocal;
|
||||
if (Image_errMsg) {
|
||||
throw `群公告${payload.image}设置失败,image字段可能格式不正确`;
|
||||
}
|
||||
if (!Image_path) {
|
||||
throw `群公告${payload.image}设置失败,获取资源失败`;
|
||||
}
|
||||
await checkFileReceived(Image_path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||
let ImageUploadResult = await NTQQGroupApi.uploadGroupBulletinPic(payload.group_id, Image_path);
|
||||
if (ImageUploadResult.errCode != 0) {
|
||||
throw `群公告${payload.image}设置失败,图片上传失败`;
|
||||
}
|
||||
if (!Image_IsLocal) {
|
||||
unlink(Image_path, () => { });
|
||||
}
|
||||
UploadImage = ImageUploadResult.picInfo;
|
||||
}
|
||||
let Notice_Pinned = 0;
|
||||
let Notice_confirmRequired = 0;
|
||||
if (!payload.pinned) {
|
||||
Notice_Pinned = 0;
|
||||
}
|
||||
if (!payload.confirmRequired) {
|
||||
Notice_confirmRequired = 0;
|
||||
}
|
||||
let PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id, payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
||||
|
||||
if (PublishGroupBulletinResult.result! = 0) {
|
||||
throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`;
|
||||
}
|
||||
// 下面实现扬了
|
||||
//await WebApi.setGroupNotice(payload.group_id, payload.content) ;
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -53,6 +53,7 @@ import { GetGroupNotice } from './group/GetGroupNotice';
|
||||
import { GetGroupEssence } from './group/GetGroupEssence';
|
||||
import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from '@/onebot11/action/msg/ForwardSingleMsg';
|
||||
import { GetFriendWithCategory } from './extends/GetFriendWithCategory';
|
||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice';
|
||||
|
||||
export const actionHandlers = [
|
||||
new GetFile(),
|
||||
@@ -97,6 +98,7 @@ export const actionHandlers = [
|
||||
new GetRobotUinRange(),
|
||||
new GetFriendWithCategory(),
|
||||
//以下为go-cqhttp api
|
||||
new SendGroupNotice(),
|
||||
new GetGroupNotice(),
|
||||
new GetGroupEssence(),
|
||||
new GoCQHTTPSendForwardMsg(),
|
||||
|
@@ -14,7 +14,10 @@ export interface InvalidCheckResult {
|
||||
}
|
||||
|
||||
export enum ActionName {
|
||||
// llonebot
|
||||
// 以下为扩展napcat扩展
|
||||
GetRobotUinRange = 'get_robot_uin_range',
|
||||
SetOnlineStatus = 'set_online_status',
|
||||
GetFriendsWithCategory = 'get_friends_with_category',
|
||||
GetGroupIgnoreAddRequest = 'get_group_ignore_add_request',
|
||||
SetQQAvatar = 'set_qq_avatar',
|
||||
GetConfig = 'get_config',
|
||||
@@ -54,11 +57,8 @@ export enum ActionName {
|
||||
GetRecord = 'get_record',
|
||||
CleanCache = 'clean_cache',
|
||||
GetCookies = 'get_cookies',
|
||||
// 以下为扩展napcat扩展
|
||||
GetRobotUinRange = 'get_robot_uin_range',
|
||||
SetOnlineStatus = 'set_online_status',
|
||||
GetFriendsWithCategory = 'get_friends_with_category',
|
||||
// 以下为go-cqhttp api
|
||||
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
||||
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
|
||||
GoCQHTTP_SetGroupNotice = '_send_group_notice',
|
||||
GoCQHTTP_GetGroupNotice = '_get_group_notice',
|
||||
|
@@ -23,7 +23,7 @@ import {
|
||||
Sex,
|
||||
TipGroupElementType,
|
||||
User
|
||||
} from '../core/src/entities';
|
||||
} from '@/core/entities';
|
||||
import { EventType } from './event/OB11BaseEvent';
|
||||
import { encodeCQCode } from './cqcode';
|
||||
import { dbUtil } from '@/core/utils/db';
|
||||
@@ -41,7 +41,7 @@ import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent';
|
||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '../core/src/apis';
|
||||
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '@/core/apis';
|
||||
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ export class OB11Constructor {
|
||||
resMsg.group_id = parseInt(tempGroupCode);
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of msg.elements) {
|
||||
const message_data: OB11MessageData | any = {
|
||||
data: {},
|
||||
@@ -152,10 +151,11 @@ export class OB11Constructor {
|
||||
// let currentRKey = "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
||||
|
||||
try {
|
||||
message_data['data']['url'] = await NTQQFileApi.getImageUrl(msg);
|
||||
message_data['data']['url'] = await NTQQFileApi.getImageUrl(element.picElement, msg.chatType !== ChatType.group);
|
||||
} catch (e: any) {
|
||||
logError('获取图片url失败', e.stack);
|
||||
}
|
||||
//console.log(message_data['data']['url'])
|
||||
// message_data["data"]["file_id"] = element.picElement.fileUuid
|
||||
message_data['data']['file_size'] = element.picElement.fileSize;
|
||||
dbUtil.addFileCache({
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { napCatCore } from '@/core';
|
||||
import { MsgListener } from '../core/src/listeners';
|
||||
import { MsgListener } from '@/core/listeners';
|
||||
import { OB11Constructor } from '@/onebot11/constructor';
|
||||
import { postOB11Event } from '@/onebot11/server/postOB11Event';
|
||||
import {
|
||||
@@ -10,16 +10,16 @@ import {
|
||||
GroupNotify,
|
||||
GroupNotifyTypes,
|
||||
RawMessage
|
||||
} from '../core/src/entities';
|
||||
} from '@/core/entities';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { httpHeart, ob11HTTPServer } from '@/onebot11/server/http';
|
||||
import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer';
|
||||
import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
||||
import { friendRequests, getFriend, getGroup, getGroupMember, groupNotifies, selfInfo, uid2UinMap } from '@/core/data';
|
||||
import { dbUtil } from '@/core/utils/db';
|
||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '../core/src/listeners';
|
||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||
import { NTQQGroupApi, NTQQUserApi } from '../core/src/apis';
|
||||
import { NTQQGroupApi, NTQQUserApi } from '@/core/apis';
|
||||
import { log, logDebug, logError, setLogSelfInfo } from '@/common/utils/log';
|
||||
import { OB11GroupRequestEvent } from '@/onebot11/event/request/OB11GroupRequest';
|
||||
import { OB11GroupAdminNoticeEvent } from '@/onebot11/event/notice/OB11GroupAdminNoticeEvent';
|
||||
@@ -205,7 +205,7 @@ export class NapCatOnebot11 {
|
||||
try {
|
||||
notify.time = Date.now();
|
||||
const notifyTime = parseInt(notify.seq) / 1000 / 1000;
|
||||
// log(`群通知时间${notifyTime}`, `LLOneBot启动时间${this.bootTime}`);
|
||||
// log(`群通知时间${notifyTime}`, `启动时间${this.bootTime}`);
|
||||
if (notifyTime < this.bootTime) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -6,14 +6,14 @@ import { wsReply } from './ws/reply';
|
||||
import { log, logDebug, logError } from '@/common/utils/log';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import crypto from 'crypto';
|
||||
import { ChatType, Group, GroupRequestOperateTypes, Peer } from '../../core/src/entities';
|
||||
import { ChatType, Group, GroupRequestOperateTypes, Peer } from '@/core/entities';
|
||||
import { convertMessage2List, createSendElements, sendMsg } from '../action/msg/SendMsg';
|
||||
import { OB11FriendRequestEvent } from '../event/request/OB11FriendRequest';
|
||||
import { OB11GroupRequestEvent } from '../event/request/OB11GroupRequest';
|
||||
import { isNull } from '@/common/utils/helper';
|
||||
import { dbUtil } from '@/core/utils/db';
|
||||
import { friendRequests, getGroup, groupNotifies, selfInfo } from '@/core/data';
|
||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi } from '../../core/src/apis';
|
||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi } from '@/core/apis';
|
||||
|
||||
export type PostEventType = OB11Message | OB11BaseMetaEvent | OB11BaseNoticeEvent
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
export const version = '1.3.0';
|
||||
export const version = '1.3.2';
|
||||
|
@@ -27,7 +27,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
undefined,
|
||||
SettingButton('V1.3.0', 'napcat-update-button', 'secondary'),
|
||||
SettingButton('V1.3.2', 'napcat-update-button', 'secondary'),
|
||||
),
|
||||
]),
|
||||
SettingList([
|
||||
|
@@ -168,7 +168,7 @@ async function onSettingWindowCreated(view) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
void 0,
|
||||
SettingButton("V1.3.0", "napcat-update-button", "secondary")
|
||||
SettingButton("V1.3.2", "napcat-update-button", "secondary")
|
||||
)
|
||||
]),
|
||||
SettingList([
|
||||
|
@@ -7,7 +7,6 @@ import { PluginOption, Plugin } from 'vite';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import { builtinModules } from 'module';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
|
||||
const external = ['silk-wasm', 'ws', 'express', 'uuid', 'fluent-ffmpeg', 'sqlite3', 'log4js',
|
||||
|
Reference in New Issue
Block a user