mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3a7a47f82d | ||
![]() |
cc211706d5 | ||
![]() |
22f74be4cd | ||
![]() |
5a00d14f94 | ||
![]() |
ecb4e7bf9f | ||
![]() |
56e5b546e1 | ||
![]() |
272f5a2f4f |
@@ -12,6 +12,8 @@ NapCatQQ(瞌睡猫QQ,不准叫我NCQQ!),像睡着了一样在后台低
|
||||
|
||||
具体占用会因人而异,QQ 群、好友越多占用越高
|
||||
|
||||
目前只支持 onebot11 协议
|
||||
|
||||
## 下载
|
||||
|
||||
前往 Release 页面下载最新版本
|
||||
@@ -74,6 +76,8 @@ json 配置内容参数解释:
|
||||
|
||||
运行`napcat.sh`
|
||||
|
||||
或使用[NapCatDocker](https://github.com/NapNeko/NapCat-Docker)
|
||||
|
||||
## 使用无需扫码快速登录
|
||||
|
||||
前提是你已经成功登录过QQ,可以加参数` -q <你的QQ>` 进行登录,如`napcat.sh -q 1234567`
|
||||
|
@@ -41,4 +41,4 @@ export async function checkVersion(): Promise<string> {
|
||||
}
|
||||
reject('get verison error!');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -148,18 +148,15 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
||||
let file = sendMsg.data?.file;
|
||||
const payloadFileName = sendMsg.data?.name;
|
||||
if (file) {
|
||||
// todo: 使用缓存文件发送
|
||||
const cache = await dbUtil.getFileCacheByName(file);
|
||||
if (cache) {
|
||||
if (fs.existsSync(cache.path)) {
|
||||
file = 'file://' + cache.path;
|
||||
}
|
||||
else if (cache.url) {
|
||||
} else if (cache.url) {
|
||||
file = cache.url;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
const fileMsg = await dbUtil.getMsgByLongId(cache.msgId);
|
||||
if (fileMsg){
|
||||
if (fileMsg) {
|
||||
const downloadPath = await NTQQFileApi.downloadMedia(fileMsg.msgId, fileMsg.chatType, fileMsg.peerUid,
|
||||
cache.elementId, '', '');
|
||||
cache.path = downloadPath!;
|
||||
@@ -210,14 +207,20 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
||||
sendElements.push(SendMsgElementConstructor.ark(sendMsg.data.data));
|
||||
}
|
||||
break;
|
||||
case OB11MessageDataType.dice:{
|
||||
case OB11MessageDataType.dice: {
|
||||
const resultId = sendMsg.data?.result;
|
||||
sendElements.push(SendMsgElementConstructor.dice(resultId));
|
||||
}break;
|
||||
case OB11MessageDataType.RPS:{
|
||||
}
|
||||
break;
|
||||
case OB11MessageDataType.RPS: {
|
||||
const resultId = sendMsg.data?.result;
|
||||
sendElements.push(SendMsgElementConstructor.rps(resultId));
|
||||
}break;
|
||||
}
|
||||
break;
|
||||
case OB11MessageDataType.markdown: {
|
||||
const content = sendMsg.data?.content;
|
||||
sendElements.push(SendMsgElementConstructor.markdown(content));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -333,11 +336,10 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (this.getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
try {
|
||||
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group);
|
||||
if (returnMsg){
|
||||
const msgShortId =await dbUtil.addMsg(returnMsg!, false);
|
||||
if (returnMsg) {
|
||||
const msgShortId = await dbUtil.addMsg(returnMsg!, false);
|
||||
return { message_id: msgShortId };
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw Error('发送转发消息失败');
|
||||
}
|
||||
} catch (e: any) {
|
||||
@@ -512,7 +514,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
// nodeIds.push(nodeMsg.msgId)
|
||||
// await sleep(500);
|
||||
// 开发转发
|
||||
if (nodeMsgIds.length === 0){
|
||||
if (nodeMsgIds.length === 0) {
|
||||
throw Error('转发消息失败,生成节点为空');
|
||||
}
|
||||
try {
|
||||
|
@@ -16,7 +16,7 @@ import {
|
||||
GrayTipElementSubType,
|
||||
Group,
|
||||
GroupMember,
|
||||
IMAGE_HTTP_HOST,
|
||||
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NT,
|
||||
RawMessage,
|
||||
SelfInfo,
|
||||
Sex,
|
||||
@@ -160,7 +160,11 @@ export class OB11Constructor {
|
||||
message_data['data']['url'] = IMAGE_HTTP_HOST + url;
|
||||
} else {
|
||||
// 有可能会碰到appid为1406的,这个不能使用新的NT域名,并且需要把appid改为1407才可访问
|
||||
message_data['data']['url'] = `${IMAGE_HTTP_HOST}/download?appid=1407&fileid=${fileUuid}&rkey=${currentRKey}&spec=0`;
|
||||
let host = IMAGE_HTTP_HOST_NT;
|
||||
if (url.includes('appid=1406')) {
|
||||
host = IMAGE_HTTP_HOST;
|
||||
}
|
||||
message_data['data']['url'] = `${host}/download?appid=1407&fileid=${fileUuid}&rkey=${currentRKey}&spec=0`;
|
||||
}
|
||||
} else {
|
||||
message_data['data']['url'] = IMAGE_HTTP_HOST + url;
|
||||
|
@@ -21,17 +21,19 @@ checkVersion().then((remoteVersion: string) => {
|
||||
const localVersion = require('./package.json').version;
|
||||
const localVersionList = localVersion.split('.');
|
||||
const remoteVersionList = remoteVersion.split('.');
|
||||
console.log('[NapCat] [Upate] 当前版本:', localVersion);
|
||||
console.log('[NapCat] 当前版本:', localVersion);
|
||||
for (const k of [0, 1, 2]) {
|
||||
if (parseInt(remoteVersionList[k]) > parseInt(localVersionList[k])) {
|
||||
console.log('[NapCat] [Upate] 检测到更新,请前往 https://github.com/NapNeko/NapCatQQ 下载 NapCatQQ V', remoteVersion);
|
||||
console.log('[NapCat] 检测到更新,请前往 https://github.com/NapNeko/NapCatQQ 下载 NapCatQQ V', remoteVersion);
|
||||
return;
|
||||
} else if (parseInt(remoteVersionList[k]) < parseInt(localVersionList[k])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log('[NapCat] [Upate] 当前已是最新版本');
|
||||
console.log('[NapCat] 当前已是最新版本');
|
||||
return;
|
||||
}).catch((e) => {
|
||||
console.error('[NapCat] 检测更新失败');
|
||||
});
|
||||
new NapCatOnebot11();
|
||||
napCatCore.addLoginSuccessCallback(() => {
|
||||
|
@@ -17,6 +17,12 @@ import { selfInfo } from '@/common/data';
|
||||
const heartbeatRunning = false;
|
||||
|
||||
class OB11WebsocketServer extends WebsocketServerBase {
|
||||
|
||||
public start(port: number) {
|
||||
this.token = ob11Config.token;
|
||||
super.start(port);
|
||||
}
|
||||
|
||||
authorizeFailed(wsClient: WebSocket) {
|
||||
wsClient.send(JSON.stringify(OB11Response.res(null, 'failed', 1403, 'token验证失败')));
|
||||
}
|
||||
|
@@ -229,13 +229,20 @@ export interface OB11MessageRPS{
|
||||
}
|
||||
}
|
||||
|
||||
export interface OB11MessageMarkdown {
|
||||
type: OB11MessageDataType.markdown
|
||||
data: {
|
||||
content: string
|
||||
}
|
||||
}
|
||||
|
||||
export type OB11MessageData =
|
||||
OB11MessageText |
|
||||
OB11MessageFace | OB11MessageMFace |
|
||||
OB11MessageAt | OB11MessageReply |
|
||||
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
|
||||
OB11MessageNode | OB11MessageCustomMusic | OB11MessageJson |
|
||||
OB11MessageDice | OB11MessageRPS
|
||||
OB11MessageDice | OB11MessageRPS | OB11MessageMarkdown
|
||||
|
||||
export interface OB11PostSendMsg {
|
||||
message_type?: 'private' | 'group'
|
||||
|
Reference in New Issue
Block a user