mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
440b63f662 | ||
![]() |
7d2cc3b56b | ||
![]() |
5fe3422469 | ||
![]() |
6c02cedb1e | ||
![]() |
3cc2f1dcad | ||
![]() |
773cdc5877 | ||
![]() |
361a7329d7 | ||
![]() |
29910f1236 | ||
![]() |
4a164016f5 | ||
![]() |
cebd3e62a4 | ||
![]() |
2562a38fa1 | ||
![]() |
d46c922bbf | ||
![]() |
66b59982f7 | ||
![]() |
ad397ccf7f | ||
![]() |
bdef80ede7 |
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.7.3",
|
"version": "1.7.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch:dev": "vite --mode development",
|
"watch:dev": "vite --mode development",
|
||||||
"watch:prod": "vite --mode production",
|
"watch:prod": "vite --mode production",
|
||||||
|
@@ -7,9 +7,6 @@ import { NodeIKernelMsgListener, onGroupFileInfoUpdateParamType } from '@/core/l
|
|||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
import { MessageUnique } from '../../../common/utils/MessageUnique';
|
import { MessageUnique } from '../../../common/utils/MessageUnique';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
import { logNotice } from '@/onebot11/log';
|
|
||||||
import { c } from 'vite/dist/node/types.d-aGj9QkWt';
|
|
||||||
//let MsgSendMode = 2;
|
|
||||||
|
|
||||||
async function LoadMessageIdList(Peer: Peer, msgId: string) {
|
async function LoadMessageIdList(Peer: Peer, msgId: string) {
|
||||||
let msgList = await NTQQMsgApi.getMsgHistory(Peer, msgId, 50);
|
let msgList = await NTQQMsgApi.getMsgHistory(Peer, msgId, 50);
|
||||||
@@ -45,6 +42,8 @@ setTimeout(() => {
|
|||||||
await sleep(100);
|
await sleep(100);
|
||||||
// NTQQMsgApi.CheckSendMode().then().catch();
|
// NTQQMsgApi.CheckSendMode().then().catch();
|
||||||
loadMessageUnique().then().catch();
|
loadMessageUnique().then().catch();
|
||||||
|
//let data = await napCatCore.session.getMsgService().sendSsoCmdReqByContend("LightAppSvc.mini_app_growguard.ReportExecute","1124343");
|
||||||
|
//console.log(data);
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
//歇菜LocalMsg压根不写Db
|
//歇菜LocalMsg压根不写Db
|
||||||
@@ -65,6 +64,9 @@ setTimeout(() => {
|
|||||||
// ));
|
// ));
|
||||||
// console.log(await NTQQMsgApi.multiForwardMsg(peer, peer, [MsgId]));
|
// console.log(await NTQQMsgApi.multiForwardMsg(peer, peer, [MsgId]));
|
||||||
// }, 25000)
|
// }, 25000)
|
||||||
|
|
||||||
|
let SendMsgSeq = new Map<Peer, Array<number>>();
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
// static async CheckSendMode() {
|
// static async CheckSendMode() {
|
||||||
// try {
|
// try {
|
||||||
@@ -142,9 +144,6 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
||||||
return await napCatCore.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
return await napCatCore.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
||||||
}
|
|
||||||
static async testMode() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
static async setMsgRead(peer: Peer) {
|
static async setMsgRead(peer: Peer) {
|
||||||
return napCatCore.session.getMsgService().setMsgRead(peer);
|
return napCatCore.session.getMsgService().setMsgRead(peer);
|
||||||
@@ -176,7 +175,13 @@ export class NTQQMsgApi {
|
|||||||
peerUid: peer.peerUid
|
peerUid: peer.peerUid
|
||||||
}, msgIds);
|
}, msgIds);
|
||||||
}
|
}
|
||||||
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
//并发Seq
|
||||||
|
static async sendMsgV3(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
|
let msgList = await NTQQMsgApi.getLastestMsgByUids(peer);
|
||||||
|
let data = await napCatCore.session.getMsgService().sendMsg("0", peer, msgElements, new Map());
|
||||||
|
SendMsgSeq.get(peer)?.push()
|
||||||
|
}
|
||||||
|
static async sendMsgV2(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
// function generateMsgId() {
|
// function generateMsgId() {
|
||||||
// const timestamp = Math.floor(Date.now() / 1000);
|
// const timestamp = Math.floor(Date.now() / 1000);
|
||||||
// const random = Math.floor(Math.random() * Math.pow(2, 32));
|
// const random = Math.floor(Math.random() * Math.pow(2, 32));
|
||||||
@@ -186,7 +191,7 @@ export class NTQQMsgApi {
|
|||||||
// const msgId = BigInt("0x" + buffer.toString('hex')).toString();
|
// const msgId = BigInt("0x" + buffer.toString('hex')).toString();
|
||||||
// return msgId;
|
// return msgId;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
||||||
let data = await NTEventDispatch.CallNormalEvent<
|
let data = await NTEventDispatch.CallNormalEvent<
|
||||||
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||||
@@ -219,45 +224,37 @@ export class NTQQMsgApi {
|
|||||||
static sendMsgEx(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static sendMsgEx(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
//return NTQQMsgApi.sendMsgV1(peer, msgElements, waitComplete, timeout);
|
//return NTQQMsgApi.sendMsgV1(peer, msgElements, waitComplete, timeout);
|
||||||
}
|
}
|
||||||
static async sendMsgV1(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
let msgList = await NTQQMsgApi.getLastestMsgByUids(peer);
|
//唉? !我有个想法
|
||||||
let msgCurrentSeq = 0n;
|
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
||||||
if (msgList.msgList.length > 0) {
|
peer.guildId = msgId;
|
||||||
msgCurrentSeq = BigInt(msgList.msgList[0].msgSeq);
|
let data = await NTEventDispatch.CallNormalEvent<
|
||||||
}
|
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||||
let rawMsg: RawMessage | undefined;
|
(msgList: RawMessage[]) => void
|
||||||
let onAddSendMsgListener = NTEventDispatch.RegisterListen<NodeIKernelMsgListener['onAddSendMsg']>('NodeIKernelMsgListener/onAddSendMsg', 1, timeout, (msg: RawMessage) => {
|
>(
|
||||||
//console.log("msgSeq:", msgCurrentSeq.toString(), JSON.stringify(msgList.msgList[0], null, 4));
|
'NodeIKernelMsgService/sendMsg',
|
||||||
if (msg.peerUid == peer.peerUid && (msgCurrentSeq == 0n || msgList.msgList[0].msgSeq == msgCurrentSeq.toString())) {
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
rawMsg = msg;
|
1,
|
||||||
return true;
|
timeout,
|
||||||
}
|
(msgRecords: RawMessage[]) => {
|
||||||
return false;
|
for (let msgRecord of msgRecords) {
|
||||||
}).catch(logError);
|
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||||
let MsgInfoListUpdateListener = NTEventDispatch.RegisterListen<NodeIKernelMsgListener['onMsgInfoListUpdate']>('NodeIKernelMsgListener/onMsgInfoListUpdate', 1, timeout,
|
|
||||||
(msgList: RawMessage[]) => {
|
|
||||||
for (let msg of msgList) {
|
|
||||||
if (msg.peerUid == peer.peerUid && rawMsg && rawMsg.msgId == msg.msgId && msg.sendStatus == 2) {
|
|
||||||
rawMsg = msg;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}).catch(logError);
|
},
|
||||||
let data = await napCatCore.session.getMsgService().sendMsg("0", peer, msgElements, new Map());
|
"0",
|
||||||
//await NTEventDispatch.CallNoListenerEvent<NodeIKernelMsgService['sendMsg']>('NodeIKernelMsgService/sendMsg', timeout, "0", peer, msgElements, new Map());
|
peer,
|
||||||
await onAddSendMsgListener;
|
msgElements,
|
||||||
if (data.result !== 0 && rawMsg) {
|
new Map()
|
||||||
//发送失败msgid
|
);
|
||||||
await napCatCore.session.getMsgService().deleteMsg(peer, [rawMsg.msgId]);
|
let retMsg = data[1].find(msgRecord => {
|
||||||
throw new Error('发送消息失败');
|
if (msgRecord.guildId === msgId) {
|
||||||
}
|
return true;
|
||||||
await MsgInfoListUpdateListener;
|
}
|
||||||
// console.log("rawMsg", JSON.stringify(rawMsg, null, 4));
|
});
|
||||||
if (rawMsg) {
|
return retMsg;
|
||||||
return rawMsg;
|
|
||||||
}
|
|
||||||
throw new Error('发送消息超时');
|
|
||||||
}
|
}
|
||||||
static async getMsgUniqueEx() {
|
static async getMsgUniqueEx() {
|
||||||
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
||||||
|
@@ -731,6 +731,7 @@ export interface MultiForwardMsgElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
|
guildId: string;
|
||||||
msgRandom: string;
|
msgRandom: string;
|
||||||
// int32, 自己维护的消息id
|
// int32, 自己维护的消息id
|
||||||
id?: number;
|
id?: number;
|
||||||
|
@@ -178,14 +178,14 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getSingleMsg(Peer: Peer, msgSeq: string): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
getSingleMsg(Peer: Peer, msgSeq: string): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
||||||
|
|
||||||
getSourceOfReplyMsg(...args: unknown[]): unknown;
|
getSourceOfReplyMsg(peer: Peer, MsgId: string, SourceSeq: string): unknown;
|
||||||
|
|
||||||
getSourceOfReplyMsgV2(...args: unknown[]): unknown;
|
getSourceOfReplyMsgV2(peer: Peer, RootMsgId: string, ReplyMsgId: string): unknown;
|
||||||
|
|
||||||
getMsgByClientSeqAndTime(...args: unknown[]): unknown;
|
getMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
||||||
|
|
||||||
getSourceOfReplyMsgByClientSeqAndTime(...args: unknown[]): unknown;
|
|
||||||
|
|
||||||
|
getSourceOfReplyMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
||||||
|
//cnt clientSeq?并不是吧
|
||||||
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: { type: number, subtype: Array<number> }): unknown;
|
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: { type: number, subtype: Array<number> }): unknown;
|
||||||
|
|
||||||
getMsgsByTypeFilters(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilters: Array<{ type: number, subtype: Array<number> }>): unknown;
|
getMsgsByTypeFilters(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilters: Array<{ type: number, subtype: Array<number> }>): unknown;
|
||||||
@@ -534,7 +534,7 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
queryCalendar(...args: unknown[]): unknown;
|
queryCalendar(...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryFirstMsgSeq(...args: unknown[]): unknown;
|
queryFirstMsgSeq(peer: Peer, ...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryRoamCalendar(...args: unknown[]): unknown;
|
queryRoamCalendar(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -628,6 +628,8 @@ export interface NodeIKernelMsgService {
|
|||||||
// this.gameSession = tempChatGameSession;
|
// this.gameSession = tempChatGameSession;
|
||||||
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
|
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
|
||||||
|
|
||||||
|
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>;
|
||||||
|
|
||||||
//chattype,uid->Promise<any>
|
//chattype,uid->Promise<any>
|
||||||
getTempChatInfo(ChatType: number, Uid: string): unknown;
|
getTempChatInfo(ChatType: number, Uid: string): unknown;
|
||||||
|
|
||||||
|
32
src/onebot11/action/extends/TestApi01.ts
Normal file
32
src/onebot11/action/extends/TestApi01.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName, BaseCheckResult } from '../types';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
|
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||||
|
import { napCatCore, NTQQGroupApi } from '@/core';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
// import { log } from "../../../common/utils";
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
cmd: { type: 'string' },
|
||||||
|
param: { type: 'string' }
|
||||||
|
},
|
||||||
|
required: ['cmd', 'param'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export default class TestApi01 extends BaseAction<Payload, any> {
|
||||||
|
actionName = ActionName.TestApi01;
|
||||||
|
// 用不着复杂检测
|
||||||
|
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
return await napCatCore.session.getMsgService().sendSsoCmdReqByContend(payload.cmd, payload.param);
|
||||||
|
}
|
||||||
|
}
|
@@ -77,6 +77,7 @@ import { GetProfileLike } from './extends/GetProfileLike';
|
|||||||
import SetGroupHeader from './extends/SetGroupHeader';
|
import SetGroupHeader from './extends/SetGroupHeader';
|
||||||
import { FetchCustomFace } from './extends/FetchCustomFace';
|
import { FetchCustomFace } from './extends/FetchCustomFace';
|
||||||
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
||||||
|
import TestApi01 from './extends/TestApi01';
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new RebootNormal(),
|
new RebootNormal(),
|
||||||
@@ -160,9 +161,9 @@ export const actionHandlers = [
|
|||||||
new GetProfileLike(),
|
new GetProfileLike(),
|
||||||
new SetGroupHeader(),
|
new SetGroupHeader(),
|
||||||
new FetchCustomFace(),
|
new FetchCustomFace(),
|
||||||
new GoCQHTTPUploadPrivateFile()
|
new GoCQHTTPUploadPrivateFile(),
|
||||||
|
new TestApi01()
|
||||||
];
|
];
|
||||||
|
|
||||||
function initActionMap() {
|
function initActionMap() {
|
||||||
const actionMap = new Map<string, BaseAction<any, any>>();
|
const actionMap = new Map<string, BaseAction<any, any>>();
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -12,25 +12,22 @@ import {
|
|||||||
SignMusicWrapper
|
SignMusicWrapper
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { getGroupMember } from '@/core/data';
|
import { getGroupMember } from '@/core/data';
|
||||||
import { logDebug, logError, logWarn } from '@/common/utils/log';
|
import { logError, logWarn } from '@/common/utils/log';
|
||||||
import { uri2local } from '@/common/utils/file';
|
import { uri2local } from '@/common/utils/file';
|
||||||
import { ob11Config } from '@/onebot11/config';
|
import { ob11Config } from '@/onebot11/config';
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/utils/request';
|
||||||
import fs from 'node:fs';
|
|
||||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||||
|
|
||||||
export type MessageContext = {
|
export type MessageContext = {
|
||||||
group?: Group,
|
group?: Group,
|
||||||
deleteAfterSentFiles: string[],
|
deleteAfterSentFiles: string[],
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleOb11FileLikeMessage(
|
async function handleOb11FileLikeMessage(
|
||||||
{ data: { file, name: payloadFileName } }: OB11MessageFileBase,
|
{ data: inputdata }: OB11MessageFileBase,
|
||||||
{ deleteAfterSentFiles }: MessageContext
|
{ deleteAfterSentFiles }: MessageContext
|
||||||
) {
|
) {
|
||||||
const uri = file;
|
//有的奇怪的框架将url作为参数 而不是file 此时优先url
|
||||||
|
let { path, isLocal, fileName, errMsg } = (await uri2local(inputdata?.url || inputdata.file));
|
||||||
const { path, isLocal, fileName, errMsg } = (await uri2local(uri));
|
|
||||||
|
|
||||||
if (errMsg) {
|
if (errMsg) {
|
||||||
logError('文件下载失败', errMsg);
|
logError('文件下载失败', errMsg);
|
||||||
@@ -41,7 +38,7 @@ async function handleOb11FileLikeMessage(
|
|||||||
deleteAfterSentFiles.push(path);
|
deleteAfterSentFiles.push(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { path, fileName: payloadFileName || fileName };
|
return { path, fileName: inputdata.name || fileName };
|
||||||
}
|
}
|
||||||
|
|
||||||
const _handlers: {
|
const _handlers: {
|
||||||
|
@@ -101,5 +101,6 @@ export enum ActionName {
|
|||||||
GetProfileLike = 'get_profile_like',
|
GetProfileLike = 'get_profile_like',
|
||||||
SetGroupHeader = 'set_group_head',
|
SetGroupHeader = 'set_group_head',
|
||||||
FetchCustomFace = 'fetch_custom_face',
|
FetchCustomFace = 'fetch_custom_face',
|
||||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file'
|
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||||
|
TestApi01 = "test_api_01"
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ import { deleteGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap }
|
|||||||
import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||||
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||||
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
||||||
|
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent';
|
||||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
|
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
|
||||||
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent';
|
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent';
|
||||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||||
@@ -173,6 +174,7 @@ export class OB11Constructor {
|
|||||||
// message_data["data"]["file"] = element.picElement.sourcePath
|
// message_data["data"]["file"] = element.picElement.sourcePath
|
||||||
message_data['data']['file'] = element.picElement.fileName;
|
message_data['data']['file'] = element.picElement.fileName;
|
||||||
message_data['data']['subType'] = element.picElement.picSubType;
|
message_data['data']['subType'] = element.picElement.picSubType;
|
||||||
|
message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId);
|
||||||
// message_data["data"]["path"] = element.picElement.sourcePath
|
// message_data["data"]["path"] = element.picElement.sourcePath
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -190,7 +192,7 @@ export class OB11Constructor {
|
|||||||
message_data['data']['file'] = FileElement.fileName;
|
message_data['data']['file'] = FileElement.fileName;
|
||||||
message_data['data']['path'] = FileElement.filePath;
|
message_data['data']['path'] = FileElement.filePath;
|
||||||
message_data['data']['url'] = FileElement.filePath;
|
message_data['data']['url'] = FileElement.filePath;
|
||||||
message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId);
|
message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId);
|
||||||
message_data['data']['file_size'] = FileElement.fileSize;
|
message_data['data']['file_size'] = FileElement.fileSize;
|
||||||
await NTQQFileApi.addFileCache({
|
await NTQQFileApi.addFileCache({
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
@@ -353,6 +355,12 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
||||||
}
|
}
|
||||||
|
if (element.grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) {
|
||||||
|
//好友添加成功事件
|
||||||
|
if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') {
|
||||||
|
return new OB11FriendAddNoticeEvent(parseInt(msg.peerUin));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts
Normal file
11
src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||||
|
|
||||||
|
export class OB11FriendAddNoticeEvent extends OB11BaseNoticeEvent {
|
||||||
|
notice_type = 'friend_add';
|
||||||
|
user_id: number;
|
||||||
|
|
||||||
|
public constructor(user_Id: number) {
|
||||||
|
super();
|
||||||
|
this.user_id = user_Id;
|
||||||
|
}
|
||||||
|
}
|
@@ -242,19 +242,19 @@ export class NapCatOnebot11 {
|
|||||||
this.postRecallMsg(msgList).then().catch(logError);
|
this.postRecallMsg(msgList).then().catch(logError);
|
||||||
for (const msg of msgList.filter(e => e.senderUin == selfInfo.uin)) {
|
for (const msg of msgList.filter(e => e.senderUin == selfInfo.uin)) {
|
||||||
// console.log(msg);
|
// console.log(msg);
|
||||||
if (msg.sendStatus !== 2) {
|
if (msg.sendStatus == 2) {
|
||||||
//完成后再post
|
//完成后再post
|
||||||
return;
|
OB11Constructor.message(msg).then((_msg) => {
|
||||||
|
_msg.target_id = parseInt(msg.peerUin);
|
||||||
|
if (ob11Config.reportSelfMessage) {
|
||||||
|
msg.id = MessageUnique.createMsg({ chatType: msg.chatType, peerUid: msg.peerUid, guildId: '' }, msg.msgId);
|
||||||
|
this.postReceiveMsg([msg]).then().catch(logError);
|
||||||
|
} else {
|
||||||
|
logMessage(_msg as OB11Message).then().catch(logError);
|
||||||
|
}
|
||||||
|
}).catch(logError);
|
||||||
}
|
}
|
||||||
OB11Constructor.message(msg).then((_msg) => {
|
|
||||||
_msg.target_id = parseInt(msg.peerUin);
|
|
||||||
if (ob11Config.reportSelfMessage) {
|
|
||||||
msg.id = MessageUnique.createMsg({ chatType: msg.chatType, peerUid: msg.peerUid, guildId: '' }, msg.msgId);
|
|
||||||
this.postReceiveMsg([msg]).then().catch(logError);
|
|
||||||
} else {
|
|
||||||
logMessage(_msg as OB11Message).then().catch(logError);
|
|
||||||
}
|
|
||||||
}).catch(logError);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
msgListener.onAddSendMsg = (msg) => {
|
msgListener.onAddSendMsg = (msg) => {
|
||||||
@@ -285,7 +285,7 @@ export class NapCatOnebot11 {
|
|||||||
// }
|
// }
|
||||||
groupListener.onGroupNotifiesUpdated = async (doubt, notifies) => {
|
groupListener.onGroupNotifiesUpdated = async (doubt, notifies) => {
|
||||||
//console.log('ob11 onGroupNotifiesUpdated', notifies[0]);
|
//console.log('ob11 onGroupNotifiesUpdated', notifies[0]);
|
||||||
if (![GroupNotifyTypes.INVITE_ME, GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(notifies[0].type)) {
|
if (![GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(notifies[0].type)) {
|
||||||
this.postGroupNotifies(notifies).then().catch(e => logError('postGroupNotifies error: ', e));
|
this.postGroupNotifies(notifies).then().catch(e => logError('postGroupNotifies error: ', e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = '1.7.3';
|
export const version = '1.7.4';
|
||||||
|
@@ -29,7 +29,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('V1.7.3', 'napcat-update-button', 'secondary')
|
SettingButton('V1.7.4', 'napcat-update-button', 'secondary')
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -163,7 +163,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("V1.7.3", "napcat-update-button", "secondary")
|
SettingButton("V1.7.4", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user