mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: remove some log
This commit is contained in:
parent
0bb7288ad2
commit
75ad495b98
@ -37,14 +37,14 @@ export abstract class HttpServerBase {
|
|||||||
const authHeader = req.get('authorization');
|
const authHeader = req.get('authorization');
|
||||||
if (authHeader) {
|
if (authHeader) {
|
||||||
clientToken = authHeader.split('Bearer ').pop() || '';
|
clientToken = authHeader.split('Bearer ').pop() || '';
|
||||||
logDebug('receive http header token', clientToken);
|
//logDebug('receive http header token', clientToken);
|
||||||
} else if (req.query.access_token) {
|
} else if (req.query.access_token) {
|
||||||
if (Array.isArray(req.query.access_token)) {
|
if (Array.isArray(req.query.access_token)) {
|
||||||
clientToken = req.query.access_token[0].toString();
|
clientToken = req.query.access_token[0].toString();
|
||||||
} else {
|
} else {
|
||||||
clientToken = req.query.access_token.toString();
|
clientToken = req.query.access_token.toString();
|
||||||
}
|
}
|
||||||
logDebug('receive http url token', clientToken);
|
//logDebug('receive http url token', clientToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverToken && clientToken != serverToken) {
|
if (serverToken && clientToken != serverToken) {
|
||||||
|
@ -14,7 +14,7 @@ export async function checkVersion(): Promise<string> {
|
|||||||
try {
|
try {
|
||||||
version = (await RequestUtil.HttpGetJson<{ version: string }>(url)).version;
|
version = (await RequestUtil.HttpGetJson<{ version: string }>(url)).version;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logDebug(e);
|
logDebug("检测更新异常",e);
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
resolve(version);
|
resolve(version);
|
||||||
|
2
src/core
2
src/core
@ -1 +1 @@
|
|||||||
Subproject commit d7677362d108fe4d942a0da8a87dce1e6f9ed5ee
|
Subproject commit 50cb003ab85f62a4b9830e426039d8208b66c5f3
|
@ -20,7 +20,7 @@ export default class Debug extends BaseAction<Payload, any> {
|
|||||||
actionName = ActionName.Debug;
|
actionName = ActionName.Debug;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
logDebug('debug call ntqq api', payload);
|
//logDebug('debug call ntqq api', payload);
|
||||||
const ntqqApi = [NTQQMsgApi, NTQQFriendApi, NTQQGroupApi, NTQQUserApi, NTQQFileApi,
|
const ntqqApi = [NTQQMsgApi, NTQQFriendApi, NTQQGroupApi, NTQQUserApi, NTQQFileApi,
|
||||||
// NTQQFileCacheApi,
|
// NTQQFileCacheApi,
|
||||||
];
|
];
|
||||||
|
@ -39,7 +39,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
|||||||
chatType: friend ? ChatType.friend : ChatType.temp,
|
chatType: friend ? ChatType.friend : ChatType.temp,
|
||||||
peerUid: uid
|
peerUid: uid
|
||||||
}, startMsgId, parseInt(payload.count?.toString()) || 20));
|
}, startMsgId, parseInt(payload.count?.toString()) || 20));
|
||||||
logDebug(historyResult);
|
//logDebug(historyResult);
|
||||||
const msgList = historyResult.msgList;
|
const msgList = historyResult.msgList;
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = await dbUtil.addMsg(msg);
|
msg.id = await dbUtil.addMsg(msg);
|
||||||
|
@ -38,7 +38,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
|||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
peerUid: group.groupCode
|
peerUid: group.groupCode
|
||||||
}, startMsgId, parseInt(payload.count?.toString()) || 20));
|
}, startMsgId, parseInt(payload.count?.toString()) || 20));
|
||||||
logDebug(historyResult);
|
//logDebug(historyResult);
|
||||||
const msgList = historyResult.msgList;
|
const msgList = historyResult.msgList;
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = await dbUtil.addMsg(msg);
|
msg.id = await dbUtil.addMsg(msg);
|
||||||
|
@ -22,7 +22,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<OB11User> {
|
protected async _handle(payload: Payload): Promise<OB11User> {
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
logDebug('uidMaps', uid2UinMap);
|
//logDebug('uidMaps', uidMaps);
|
||||||
const uid = getUidByUin(user_id);
|
const uid = getUidByUin(user_id);
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
throw new Error('查无此人');
|
throw new Error('查无此人');
|
||||||
|
@ -62,7 +62,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
// 无管理员权限通过本地记录获取发言时间
|
// 无管理员权限通过本地记录获取发言时间
|
||||||
const haveAdmin = RetGroupMember[0].last_sent_time !== 0;
|
const haveAdmin = RetGroupMember[0].last_sent_time !== 0;
|
||||||
if (!haveAdmin) {
|
if (!haveAdmin) {
|
||||||
logDebug('没有管理员权限,使用本地记录');
|
//logDebug('没有管理员权限,使用本地记录');
|
||||||
const _sendAndJoinRember = await getLastSentTimeAndJoinTime(parseInt(group.groupCode));
|
const _sendAndJoinRember = await getLastSentTimeAndJoinTime(parseInt(group.groupCode));
|
||||||
_sendAndJoinRember.forEach((rember) => {
|
_sendAndJoinRember.forEach((rember) => {
|
||||||
const member = RetGroupMember.find(member=>member.user_id == rember.user_id);
|
const member = RetGroupMember.find(member=>member.user_id == rember.user_id);
|
||||||
|
@ -117,14 +117,14 @@ const _handlers: {
|
|||||||
|
|
||||||
[OB11MessageDataType.file]: async (sendMsg, context) => {
|
[OB11MessageDataType.file]: async (sendMsg, context) => {
|
||||||
const { path, fileName } = await handleOb11FileLikeMessage(sendMsg, context);
|
const { path, fileName } = await handleOb11FileLikeMessage(sendMsg, context);
|
||||||
logDebug('发送文件', path, fileName);
|
//logDebug('发送文件', path, fileName);
|
||||||
return SendMsgElementConstructor.file(path, fileName);
|
return SendMsgElementConstructor.file(path, fileName);
|
||||||
},
|
},
|
||||||
|
|
||||||
[OB11MessageDataType.video]: async (sendMsg, context) => {
|
[OB11MessageDataType.video]: async (sendMsg, context) => {
|
||||||
const { path, fileName } = await handleOb11FileLikeMessage(sendMsg, context);
|
const { path, fileName } = await handleOb11FileLikeMessage(sendMsg, context);
|
||||||
|
|
||||||
logDebug('发送视频', path, fileName);
|
//logDebug('发送视频', path, fileName);
|
||||||
let thumb = sendMsg.data.thumb;
|
let thumb = sendMsg.data.thumb;
|
||||||
if (thumb) {
|
if (thumb) {
|
||||||
const uri2LocalRes = await uri2local(thumb);
|
const uri2LocalRes = await uri2local(thumb);
|
||||||
|
@ -14,7 +14,7 @@ async function cloneMsg(msg: RawMessage): Promise<RawMessage | undefined> {
|
|||||||
peerUid: selfInfo.uid
|
peerUid: selfInfo.uid
|
||||||
};
|
};
|
||||||
|
|
||||||
logDebug('克隆的目标消息', msg);
|
// logDebug('克隆的目标消息', msg);
|
||||||
|
|
||||||
const sendElements: SendMessageElement[] = [];
|
const sendElements: SendMessageElement[] = [];
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ async function cloneMsg(msg: RawMessage): Promise<RawMessage | undefined> {
|
|||||||
logDebug('需要clone的消息无法解析,将会忽略掉', msg);
|
logDebug('需要clone的消息无法解析,将会忽略掉', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
logDebug('克隆消息', sendElements);
|
//logDebug('克隆消息', sendElements);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nodeMsg = await NTQQMsgApi.sendMsg(selfPeer, sendElements, true);
|
const nodeMsg = await NTQQMsgApi.sendMsg(selfPeer, sendElements, true);
|
||||||
@ -71,7 +71,7 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag
|
|||||||
// 提取消息段,发给自己生成消息id
|
// 提取消息段,发给自己生成消息id
|
||||||
try {
|
try {
|
||||||
const { sendElements } = await createSendElements(normalize(messageNode.data.content), group);
|
const { sendElements } = await createSendElements(normalize(messageNode.data.content), group);
|
||||||
logDebug('开始生成转发节点', sendElements);
|
//logDebug('开始生成转发节点', sendElements);
|
||||||
const sendElementsSplit: SendMessageElement[][] = [];
|
const sendElementsSplit: SendMessageElement[][] = [];
|
||||||
let splitIndex = 0;
|
let splitIndex = 0;
|
||||||
for (const sendElement of sendElements) {
|
for (const sendElement of sendElements) {
|
||||||
@ -88,7 +88,7 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag
|
|||||||
} else {
|
} else {
|
||||||
sendElementsSplit[splitIndex].push(sendElement);
|
sendElementsSplit[splitIndex].push(sendElement);
|
||||||
}
|
}
|
||||||
logDebug(sendElementsSplit);
|
//logDebug(sendElementsSplit);
|
||||||
}
|
}
|
||||||
// log("分割后的转发节点", sendElementsSplit)
|
// log("分割后的转发节点", sendElementsSplit)
|
||||||
const MsgNodeList: Promise<RawMessage>[] = [];
|
const MsgNodeList: Promise<RawMessage>[] = [];
|
||||||
@ -100,7 +100,7 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag
|
|||||||
for (const msgNode of MsgNodeList) {
|
for (const msgNode of MsgNodeList) {
|
||||||
const result = await msgNode;
|
const result = await msgNode;
|
||||||
nodeMsgIds.push(result.msgId);
|
nodeMsgIds.push(result.msgId);
|
||||||
logDebug('转发节点生成成功', result.msgId);
|
//logDebug('转发节点生成成功', result.msgId);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logDebug('生成转发消息节点失败', e);
|
logDebug('生成转发消息节点失败', e);
|
||||||
@ -124,10 +124,10 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logDebug('nodeMsgArray', nodeMsgArray);
|
//logDebug('nodeMsgArray', nodeMsgArray);
|
||||||
nodeMsgIds = nodeMsgArray.map(msg => msg.msgId);
|
nodeMsgIds = nodeMsgArray.map(msg => msg.msgId);
|
||||||
if (needSendSelf) {
|
if (needSendSelf) {
|
||||||
logDebug('需要克隆转发消息');
|
//logDebug('需要克隆转发消息');
|
||||||
for (const [index, msg] of nodeMsgArray.entries()) {
|
for (const [index, msg] of nodeMsgArray.entries()) {
|
||||||
if (msg.peerUid !== selfInfo.uid) {
|
if (msg.peerUid !== selfInfo.uid) {
|
||||||
const clonedMsg = await cloneMsg(msg);
|
const clonedMsg = await cloneMsg(msg);
|
||||||
|
@ -20,7 +20,7 @@ export default class SendLike extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SendLike;
|
actionName = ActionName.SendLike;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
logDebug('点赞参数', payload);
|
//logDebug('点赞参数', payload);
|
||||||
try {
|
try {
|
||||||
const qq = payload.user_id.toString();
|
const qq = payload.user_id.toString();
|
||||||
const friend = await getFriend(qq);
|
const friend = await getFriend(qq);
|
||||||
@ -31,7 +31,7 @@ export default class SendLike extends BaseAction<Payload, null> {
|
|||||||
uid = friend.uid;
|
uid = friend.uid;
|
||||||
}
|
}
|
||||||
const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1);
|
const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1);
|
||||||
logDebug('点赞结果', result);
|
//logDebug('点赞结果', result);
|
||||||
if (result.result !== 0) {
|
if (result.result !== 0) {
|
||||||
throw Error(result.errMsg);
|
throw Error(result.errMsg);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi } from '@/core/apis';
|
|||||||
import createSendElements from '../action/msg/SendMsg/create-send-elements';
|
import createSendElements from '../action/msg/SendMsg/create-send-elements';
|
||||||
|
|
||||||
export type QuickActionEvent = OB11Message | OB11BaseMetaEvent | OB11BaseNoticeEvent
|
export type QuickActionEvent = OB11Message | OB11BaseMetaEvent | OB11BaseNoticeEvent
|
||||||
|
export type PostEventType = OB11Message | OB11BaseMetaEvent | OB11BaseNoticeEvent
|
||||||
|
|
||||||
interface QuickActionPrivateMessage {
|
interface QuickActionPrivateMessage {
|
||||||
reply?: string;
|
reply?: string;
|
||||||
@ -97,12 +98,12 @@ export function postOB11Event(msg: QuickActionEvent, reportSelf = false, postWs
|
|||||||
headers,
|
headers,
|
||||||
body: msgStr
|
body: msgStr
|
||||||
}).then(async (res) => {
|
}).then(async (res) => {
|
||||||
logDebug(`新消息事件HTTP上报成功: ${host} `, msgStr);
|
//logDebug(`新消息事件HTTP上报成功: ${host} `, msgStr);
|
||||||
// todo: 处理不够优雅,应该使用高级泛型进行QuickAction类型识别
|
// todo: 处理不够优雅,应该使用高级泛型进行QuickAction类型识别
|
||||||
let resJson: QuickAction;
|
let resJson: QuickAction;
|
||||||
try {
|
try {
|
||||||
resJson = await res.json();
|
resJson = await res.json();
|
||||||
logDebug('新消息事件HTTP上报返回快速操作: ', JSON.stringify(resJson));
|
//logDebug('新消息事件HTTP上报返回快速操作: ', JSON.stringify(resJson));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logDebug('新消息事件HTTP上报没有返回快速操作,不需要处理');
|
logDebug('新消息事件HTTP上报没有返回快速操作,不需要处理');
|
||||||
return;
|
return;
|
||||||
|
@ -40,7 +40,7 @@ export class ReverseWebsocket {
|
|||||||
try {
|
try {
|
||||||
receiveData = JSON.parse(msg.toString());
|
receiveData = JSON.parse(msg.toString());
|
||||||
echo = receiveData.echo;
|
echo = receiveData.echo;
|
||||||
logDebug('收到反向Websocket消息', receiveData);
|
//logDebug('收到反向Websocket消息', receiveData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return wsReply(this.websocket!, OB11Response.error('json解析失败,请检查数据格式', 1400, echo));
|
return wsReply(this.websocket!, OB11Response.error('json解析失败,请检查数据格式', 1400, echo));
|
||||||
}
|
}
|
||||||
|
3
src/vite-env.d.ts
vendored
3
src/vite-env.d.ts
vendored
@ -1,8 +1,7 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_APP_TITLE: string
|
VITE_BUILD_TYPE: string
|
||||||
// 更多环境变量...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user