mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d9fb4d6c4d | ||
![]() |
fcf2f4c5f2 | ||
![]() |
4e97501690 | ||
![]() |
b0402391fb | ||
![]() |
f05a862cf9 | ||
![]() |
3ea92d57c2 |
@@ -19,6 +19,7 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
|||||||
**首次使用**请务必前往[官方文档](https://napneko.github.io/)查看使用教程。
|
**首次使用**请务必前往[官方文档](https://napneko.github.io/)查看使用教程。
|
||||||
|
|
||||||
## 相关链接
|
## 相关链接
|
||||||
|
[QQ Group](https://qm.qq.com/q/VfjAq5HIMS)
|
||||||
|
|
||||||
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCat",
|
"name": "NapCat",
|
||||||
"slug": "NapCat",
|
"slug": "NapCat",
|
||||||
"description": "现代化的 OneBot 11 协议实现",
|
"description": "现代化的 OneBot 11 协议实现",
|
||||||
"version": "2.0.14",
|
"version": "2.0.15",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.0.14",
|
"version": "2.0.15",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "vite build --mode framework",
|
"build:framework": "vite build --mode framework",
|
||||||
"build:shell": "vite build --mode shell",
|
"build:shell": "vite build --mode shell",
|
||||||
|
@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
export const napcat_version = '2.0.14';
|
export const napcat_version = '2.0.15';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
|
@@ -28,19 +28,6 @@ const GetFileBase_PayloadSchema = {
|
|||||||
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||||
PayloadSchema: any = GetFileBase_PayloadSchema;
|
PayloadSchema: any = GetFileBase_PayloadSchema;
|
||||||
|
|
||||||
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
|
|
||||||
let element = msg.elements.find(e => e.fileElement);
|
|
||||||
if (!element) {
|
|
||||||
element = msg.elements.find(e => e.videoElement);
|
|
||||||
if (element) {
|
|
||||||
return { id: element.elementId, element: element.videoElement };
|
|
||||||
} else {
|
|
||||||
throw new Error('找不到文件');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { id: element.elementId, element: element.fileElement };
|
|
||||||
}
|
|
||||||
|
|
||||||
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||||
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
|
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
|
||||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
@@ -92,7 +79,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
file_size: fileSize,
|
file_size: fileSize,
|
||||||
file_name: fileName,
|
file_name: fileName,
|
||||||
};
|
};
|
||||||
if (true/*enableLocalFile2Url*/) {
|
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||||
try {
|
try {
|
||||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -132,7 +119,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
file_size: NTSearchNameResult[0].fileSize.toString(),
|
file_size: NTSearchNameResult[0].fileSize.toString(),
|
||||||
file_name: NTSearchNameResult[0].fileName,
|
file_name: NTSearchNameResult[0].fileName,
|
||||||
};
|
};
|
||||||
if (true/*enableLocalFile2Url*/) {
|
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||||
try {
|
try {
|
||||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@@ -69,7 +69,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Mlikiowa V2.0.14 Refactor Todo
|
// Mlikiowa V2.0.15 Refactor Todo
|
||||||
// retMember.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
|
// retMember.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
|
||||||
// retMember.join_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
// retMember.join_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Mlikiowa V2.0.14 Refactor Todo
|
// Mlikiowa V2.0.15 Refactor Todo
|
||||||
// _groupMembers.forEach(async item => {
|
// _groupMembers.forEach(async item => {
|
||||||
// item.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.lastSpeakTime || date.toString());
|
// item.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.lastSpeakTime || date.toString());
|
||||||
// item.join_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.joinTime || date.toString());
|
// item.join_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.joinTime || date.toString());
|
||||||
|
@@ -56,7 +56,7 @@ const _handlers: {
|
|||||||
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
||||||
|
|
||||||
// then the qq is a group member
|
// then the qq is a group member
|
||||||
// Mlikiowa V2.0.14 Refactor Todo
|
// Mlikiowa V2.0.15 Refactor Todo
|
||||||
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
|
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
|
||||||
if (!uid) throw new Error('Get Uid Error');
|
if (!uid) throw new Error('Get Uid Error');
|
||||||
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
||||||
@@ -161,7 +161,7 @@ const _handlers: {
|
|||||||
} else {
|
} else {
|
||||||
postData = data;
|
postData = data;
|
||||||
}
|
}
|
||||||
// Mlikiowa V2.0.14 Refactor Todo
|
// Mlikiowa V2.0.15 Refactor Todo
|
||||||
const signUrl = obContext.configLoader.configData.musicSignUrl;
|
const signUrl = obContext.configLoader.configData.musicSignUrl;
|
||||||
if (!signUrl) {
|
if (!signUrl) {
|
||||||
if (data.type === 'qq') {
|
if (data.type === 'qq') {
|
||||||
|
@@ -67,7 +67,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
|||||||
const cookiesObject = await NTQQUserApi.getCookies(payload.domain);
|
const cookiesObject = await NTQQUserApi.getCookies(payload.domain);
|
||||||
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
||||||
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
||||||
const bkn = NTQQWebApi.getBknFromCookie(cookiesObject.p_skey);
|
const bkn = NTQQWebApi.getBknFromCookie(cookiesObject);
|
||||||
return { cookies, bkn };
|
return { cookies, bkn };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,8 @@ export class OB11Constructor {
|
|||||||
msg: RawMessage,
|
msg: RawMessage,
|
||||||
messagePostFormat: string = obcore.configLoader.configData.messagePostFormat
|
messagePostFormat: string = obcore.configLoader.configData.messagePostFormat
|
||||||
): Promise<OB11Message | undefined> {
|
): Promise<OB11Message | undefined> {
|
||||||
if (msg.senderUin == "0") return;
|
if (msg.senderUin == "0" || msg.senderUin == "") return;
|
||||||
if (msg.peerUin == "0") return;
|
if (msg.peerUin == "0" || msg.peerUin) return;
|
||||||
//跳过空消息
|
//跳过空消息
|
||||||
const NTQQGroupApi = core.apis.GroupApi;
|
const NTQQGroupApi = core.apis.GroupApi;
|
||||||
const NTQQUserApi = core.apis.UserApi;
|
const NTQQUserApi = core.apis.UserApi;
|
||||||
@@ -417,7 +417,7 @@ export class OB11Constructor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//log("group msg", msg);
|
//log("group msg", msg);
|
||||||
// Mlikiowa V2.0.14 Refactor Todo
|
// Mlikiowa V2.0.15 Refactor Todo
|
||||||
// if (msg.senderUin && msg.senderUin !== '0') {
|
// if (msg.senderUin && msg.senderUin !== '0') {
|
||||||
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
|
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
|
||||||
// if (member && member.cardName !== msg.sendMemberName) {
|
// if (member && member.cardName !== msg.sendMemberName) {
|
||||||
|
@@ -168,20 +168,24 @@ export async function NCoreInitShell() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (quickLoginUin && historyLoginList.some(u => u.uin === quickLoginUin)) {
|
if (quickLoginUin) {
|
||||||
logger.log('正在快速登录 ', quickLoginUin);
|
if (historyLoginList.some(u => u.uin === quickLoginUin)) {
|
||||||
setTimeout(() => {
|
logger.log('正在快速登录 ', quickLoginUin);
|
||||||
loginService.quickLoginWithUin(quickLoginUin)
|
setTimeout(() => {
|
||||||
.then(result => {
|
loginService.quickLoginWithUin(quickLoginUin)
|
||||||
if (result.loginErrorInfo.errMsg) {
|
.then(result => {
|
||||||
logger.logError('快速登录错误:', result.loginErrorInfo.errMsg);
|
if (result.loginErrorInfo.errMsg) {
|
||||||
loginService.getQRCodePicture();
|
logger.logError('快速登录错误:', result.loginErrorInfo.errMsg);
|
||||||
}
|
loginService.getQRCodePicture();
|
||||||
})
|
}
|
||||||
.catch();
|
})
|
||||||
}, 1000);
|
.catch();
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
logger.logError('快速登录失败,未找到该 QQ 历史登录记录,将使用二维码登录方式');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log('没有 -q 指令指定快速登录,或未曾登录过这个 QQ,将使用二维码登录方式');
|
logger.log('没有 -q 指令指定快速登录,将使用二维码登录方式');
|
||||||
if (historyLoginList.length > 0) {
|
if (historyLoginList.length > 0) {
|
||||||
logger.log(`可用于快速登录的 QQ:\n${
|
logger.log(`可用于快速登录的 QQ:\n${
|
||||||
historyLoginList
|
historyLoginList
|
||||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V2.0.14', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.0.15', 'napcat-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V2.0.14", "napcat-update-button", "secondary")
|
SettingButton("V2.0.15", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user