mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8d94f24c71 | ||
![]() |
6ac74c39d9 | ||
![]() |
836eb7b708 | ||
![]() |
698624b4dc | ||
![]() |
5c1df82076 | ||
![]() |
5d649b3687 | ||
![]() |
a6a3d71155 | ||
![]() |
1cc9d501ab | ||
![]() |
7a98025df8 | ||
![]() |
44d6ed5e80 | ||
![]() |
b5f2226bef | ||
![]() |
ddbffe55d2 | ||
![]() |
9676b1d0e9 | ||
![]() |
8142d3bfeb | ||
![]() |
755ad27a0a | ||
![]() |
5afa2dcdf1 | ||
![]() |
7eb80646ba | ||
![]() |
6fd24e57d3 | ||
![]() |
22c90adb47 | ||
![]() |
df0c6fafbe | ||
![]() |
dc30321b04 | ||
![]() |
63dd98d2df | ||
![]() |
caaa6ed506 | ||
![]() |
caf23792cb | ||
![]() |
e430db20aa | ||
![]() |
6fc5da9b67 | ||
![]() |
f428e57724 | ||
![]() |
14ab21fe9a | ||
![]() |
85626e19da | ||
![]() |
8712160fd7 | ||
![]() |
75b33f5cb1 | ||
![]() |
f5e8ede847 | ||
![]() |
3b3f684a8c | ||
![]() |
a78b60d40e | ||
![]() |
9ff06a3c44 | ||
![]() |
8532dc486c | ||
![]() |
861340f4bf | ||
![]() |
cdcb51ebe4 | ||
![]() |
0b11786d7d | ||
![]() |
1742247a9a | ||
![]() |
42bad123b2 | ||
![]() |
2d1e87defc | ||
![]() |
1c6f783a07 | ||
![]() |
6aafc097d5 | ||
![]() |
4010f233dd |
6
LICENSE
6
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC Without Social media promotion LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
@@ -111,6 +111,10 @@ above, provided that you also meet all of these conditions:
|
|||||||
does not normally print such an announcement, your work based on
|
does not normally print such an announcement, your work based on
|
||||||
the Program is not required to print an announcement.)
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
d)You may use this software in accordance with the above terms,
|
||||||
|
but you are not allowed to promote this project or your projects
|
||||||
|
based on this project on any public social media.
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
These requirements apply to the modified work as a whole. If
|
||||||
identifiable sections of that work are not derived from the Program,
|
identifiable sections of that work are not derived from the Program,
|
||||||
and can be reasonably considered independent and separate works in
|
and can be reasonably considered independent and separate works in
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
## To Be Continued
|
||||||
|
当前版本请使用低于27187 (不包含) 高于26702 (包含) 的QQ版本运行
|
||||||
|
|
||||||
## 项目介绍
|
## 项目介绍
|
||||||
NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "2.0.23",
|
"version": "2.0.33",
|
||||||
"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.23",
|
"version": "2.0.33",
|
||||||
"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.23';
|
export const napcat_version = '2.0.33';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import fsPromise, { stat } from 'fs/promises';
|
import { stat } from 'fs/promises';
|
||||||
import crypto, { randomUUID } from 'crypto';
|
import crypto, { randomUUID } from 'crypto';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import * as fileType from 'file-type';
|
import * as fileType from 'file-type';
|
||||||
import { LogWrapper } from './log';
|
|
||||||
|
|
||||||
export function isGIF(path: string) {
|
export function isGIF(path: string) {
|
||||||
const buffer = Buffer.alloc(4);
|
const buffer = Buffer.alloc(4);
|
||||||
@@ -13,7 +12,6 @@ export function isGIF(path: string) {
|
|||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
return buffer.toString() === 'GIF8';
|
return buffer.toString() === 'GIF8';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义一个异步函数来检查文件是否存在
|
// 定义一个异步函数来检查文件是否存在
|
||||||
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
|
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -94,7 +92,6 @@ export async function file2base64(path: string) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function calculateFileMD5(filePath: string): Promise<string> {
|
export function calculateFileMD5(filePath: string): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 创建一个流式读取器
|
// 创建一个流式读取器
|
||||||
@@ -165,6 +162,7 @@ type Uri2LocalRes = {
|
|||||||
path: string,
|
path: string,
|
||||||
isLocal: boolean
|
isLocal: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkFileV2(filePath: string) {
|
export async function checkFileV2(filePath: string) {
|
||||||
try {
|
try {
|
||||||
const ext: string | undefined = (await fileType.fileTypeFromFile(filePath))?.ext;
|
const ext: string | undefined = (await fileType.fileTypeFromFile(filePath))?.ext;
|
||||||
@@ -178,12 +176,14 @@ export async function checkFileV2(filePath: string) {
|
|||||||
}
|
}
|
||||||
return { success: false, ext: '', path: filePath };
|
return { success: false, ext: '', path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum FileUriType {
|
export enum FileUriType {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
Local = 1,
|
Local = 1,
|
||||||
Remote = 2,
|
Remote = 2,
|
||||||
Base64 = 3
|
Base64 = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkUriType(Uri: string) {
|
export async function checkUriType(Uri: string) {
|
||||||
//先判断是否是本地文件
|
//先判断是否是本地文件
|
||||||
try {
|
try {
|
||||||
@@ -215,8 +215,9 @@ export async function checkUriType(Uri: string) {
|
|||||||
}
|
}
|
||||||
return { Uri: Uri, Type: FileUriType.Unknown };
|
return { Uri: Uri, Type: FileUriType.Unknown };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uri2local(dir: string, uri: string, filename: string | undefined = undefined): Promise<Uri2LocalRes> {
|
export async function uri2local(dir: string, uri: string, filename: string | undefined = undefined): Promise<Uri2LocalRes> {
|
||||||
let { Uri: HandledUri, Type: UriType } = await checkUriType(uri);
|
const { Uri: HandledUri, Type: UriType } = await checkUriType(uri);
|
||||||
//解析失败
|
//解析失败
|
||||||
|
|
||||||
if (UriType == FileUriType.Unknown) {
|
if (UriType == FileUriType.Unknown) {
|
||||||
@@ -231,14 +232,21 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
|||||||
//接下来都要有文件名
|
//接下来都要有文件名
|
||||||
if (!filename) filename = randomUUID();
|
if (!filename) filename = randomUUID();
|
||||||
//解析Http和Https协议
|
//解析Http和Https协议
|
||||||
|
|
||||||
if (UriType == FileUriType.Remote) {
|
if (UriType == FileUriType.Remote) {
|
||||||
|
const pathInfo = path.parse(decodeURIComponent(new URL(HandledUri).pathname));
|
||||||
|
if (pathInfo.name) {
|
||||||
|
filename = pathInfo.name;
|
||||||
|
if (pathInfo.ext) {
|
||||||
|
filename += pathInfo.ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filename = filename.replace(/[/\\:*?"<>|]/g, '_');
|
||||||
const fileExt = path.extname(HandledUri);
|
const fileExt = path.extname(HandledUri);
|
||||||
|
const filePath = path.join(dir, filename);
|
||||||
const fileName = filename + fileExt;
|
|
||||||
const filePath = path.join(dir, fileName);
|
|
||||||
const buffer = await httpDownload(HandledUri);
|
const buffer = await httpDownload(HandledUri);
|
||||||
fs.writeFileSync(filePath, buffer);
|
fs.writeFileSync(filePath, buffer);
|
||||||
return { success: true, errMsg: '', fileName: fileName, ext: fileExt, path: filePath, isLocal: true };
|
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
||||||
}
|
}
|
||||||
//解析Base64
|
//解析Base64
|
||||||
if (UriType == FileUriType.Base64) {
|
if (UriType == FileUriType.Base64) {
|
||||||
@@ -256,26 +264,4 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
|||||||
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
||||||
}
|
}
|
||||||
return { success: false, errMsg: '未知文件类型', fileName: '', ext: '', path: '', isLocal: false };
|
return { success: false, errMsg: '未知文件类型', fileName: '', ext: '', path: '', isLocal: false };
|
||||||
}
|
}
|
||||||
export async function copyFolder(sourcePath: string, destPath: string, logger: LogWrapper) {
|
|
||||||
try {
|
|
||||||
const entries = await fsPromise.readdir(sourcePath, { withFileTypes: true });
|
|
||||||
await fsPromise.mkdir(destPath, { recursive: true });
|
|
||||||
for (const entry of entries) {
|
|
||||||
const srcPath = path.join(sourcePath, entry.name);
|
|
||||||
const dstPath = path.join(destPath, entry.name);
|
|
||||||
if (entry.isDirectory()) {
|
|
||||||
await copyFolder(srcPath, dstPath, logger);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
await fsPromise.copyFile(srcPath, dstPath);
|
|
||||||
} catch (error) {
|
|
||||||
logger.logError(`无法复制文件 '${srcPath}' 到 '${dstPath}': ${error}`);
|
|
||||||
// 这里可以决定是否要继续复制其他文件
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
logger.logError('复制文件夹时出错:', error);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -53,12 +53,6 @@ export async function runAllWithTimeout<T>(tasks: Promise<T>[], timeout: number)
|
|||||||
.map((result) => (result as { status: 'fulfilled'; value: T }).value);
|
.map((result) => (result as { status: 'fulfilled'; value: T }).value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMd5(s: string) {
|
|
||||||
const h = crypto.createHash('md5');
|
|
||||||
h.update(s);
|
|
||||||
return h.digest('hex');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isNull(value: any) {
|
export function isNull(value: any) {
|
||||||
return value === undefined || value === null;
|
return value === undefined || value === null;
|
||||||
}
|
}
|
||||||
@@ -137,28 +131,6 @@ export function getQQVersionConfigPath(exePath: string = ''): string | undefined
|
|||||||
return configVersionInfoPath;
|
return configVersionInfoPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteOldFiles(directoryPath: string, daysThreshold: number) {
|
|
||||||
try {
|
|
||||||
const files = await fsPromise.readdir(directoryPath);
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
const filePath = path.join(directoryPath, file);
|
|
||||||
const stats = await fsPromise.stat(filePath);
|
|
||||||
const lastModifiedTime = stats.mtimeMs;
|
|
||||||
const currentTime = Date.now();
|
|
||||||
const timeDifference = currentTime - lastModifiedTime;
|
|
||||||
const daysDifference = timeDifference / (1000 * 60 * 60 * 24);
|
|
||||||
|
|
||||||
if (daysDifference > daysThreshold) {
|
|
||||||
await fsPromise.unlink(filePath); // Delete the file
|
|
||||||
//console.log(`Deleted: ${filePath}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
//console.error('Error deleting files:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function calcQQLevel(level: QQLevel) {
|
export function calcQQLevel(level: QQLevel) {
|
||||||
const { crownNum, sunNum, moonNum, starNum } = level;
|
const { crownNum, sunNum, moonNum, starNum } = level;
|
||||||
return crownNum * 64 + sunNum * 16 + moonNum * 4 + starNum;
|
return crownNum * 64 + sunNum * 16 + moonNum * 4 + starNum;
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -253,22 +253,45 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||||
type ListenerType = NodeIKernelGroupListener['onMemberInfoChange'];
|
//type ListenerType = NodeIKernelGroupListener['onMemberInfoChange'];
|
||||||
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
||||||
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
||||||
//return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
//return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
||||||
const [, , , _members] = await this.core.eventWrapper.CallNormalEvent<EventType, ListenerType>
|
const Listener = this.core.eventWrapper.RegisterListen<(params: any) => void>
|
||||||
(
|
(
|
||||||
'NodeIKernelGroupService/getMemberInfo',
|
|
||||||
'NodeIKernelGroupListener/onMemberInfoChange',
|
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
1,
|
1,
|
||||||
5000,
|
forced ? 5000 : 250,
|
||||||
(groupCode: string, changeType: number, members: Map<string, GroupMember>) => {
|
(params) => {
|
||||||
return groupCode == GroupCode && members.has(uid);
|
return params === GroupCode;
|
||||||
},
|
},
|
||||||
GroupCode, [uid], forced,
|
|
||||||
);
|
);
|
||||||
return _members.get(uid);
|
const EventFunc = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelGroupService/getMemberInfo');
|
||||||
|
const retData = await EventFunc!(GroupCode, [uid], forced);
|
||||||
|
if (retData.result !== 0) {
|
||||||
|
throw new Error(`${retData.errMsg}`);
|
||||||
|
}
|
||||||
|
const result = await Listener as unknown;
|
||||||
|
let member: GroupMember | undefined;
|
||||||
|
if (Array.isArray(result) && result?.[2] instanceof Map) {
|
||||||
|
let members = result[2] as Map<string, GroupMember>;
|
||||||
|
member = members.get(uid);
|
||||||
|
};
|
||||||
|
return member;
|
||||||
|
|
||||||
|
// 原本的方法: (no_cache 下效率很高, cache 下效率一致)
|
||||||
|
// const [, , , _members] = await this.core.eventWrapper.CallNormalEvent<EventType, ListenerType>
|
||||||
|
// (
|
||||||
|
// 'NodeIKernelGroupService/getMemberInfo',
|
||||||
|
// 'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
|
// 1,
|
||||||
|
// 5000,
|
||||||
|
// (groupCode: string, changeType: number, members: Map<string, GroupMember>) => {
|
||||||
|
// return groupCode == GroupCode && members.has(uid);
|
||||||
|
// },
|
||||||
|
// GroupCode, [uid], forced,
|
||||||
|
// );
|
||||||
|
// return _members.get(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ChatType, GetFileListParam, Peer, RawMessage, SendMessageElement } from '@/core/entities';
|
import { ChatType, GetFileListParam, Peer, RawMessage, SendMessageElement, SendStatusType } from '@/core/entities';
|
||||||
import { InstanceContext, NapCatCore } from '@/core';
|
import { InstanceContext, NapCatCore } from '@/core';
|
||||||
import { onGroupFileInfoUpdateParamType } from '@/core/listeners';
|
import { onGroupFileInfoUpdateParamType } from '@/core/listeners';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
@@ -16,6 +16,9 @@ export class NTQQMsgApi {
|
|||||||
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendShowInputStatusReq(peer: Peer, eventType: number) {
|
||||||
|
return this.context.session.getMsgService().sendShowInputStatusReq(peer.chatType, eventType, peer.peerUid);
|
||||||
|
}
|
||||||
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
||||||
//console.log(peer, msgSeq, emojiId, emojiType, count);
|
//console.log(peer, msgSeq, emojiId, emojiType, count);
|
||||||
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
||||||
@@ -93,7 +96,22 @@ export class NTQQMsgApi {
|
|||||||
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
||||||
return await this.context.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
return await this.context.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
||||||
}
|
}
|
||||||
|
async getMsgExBySeq(peer: Peer, msgSeq: string) {
|
||||||
|
const DateNow = Math.floor(Date.now() / 1000);
|
||||||
|
const filterMsgFromTime = (DateNow - 300).toString();
|
||||||
|
const filterMsgToTime = DateNow.toString();
|
||||||
|
const ret = await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||||
|
chatInfo: peer,//此处为Peer 为关键查询参数 没有啥也没有 by mlik iowa
|
||||||
|
filterMsgType: [],
|
||||||
|
filterSendersUid: [],
|
||||||
|
filterMsgToTime: filterMsgToTime,
|
||||||
|
filterMsgFromTime: filterMsgFromTime,
|
||||||
|
isReverseOrder: false,
|
||||||
|
isIncludeCurrent: true,
|
||||||
|
pageLimit: 100,
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
async setMsgRead(peer: Peer) {
|
async setMsgRead(peer: Peer) {
|
||||||
return this.context.session.getMsgService().setMsgRead(peer);
|
return this.context.session.getMsgService().setMsgRead(peer);
|
||||||
}
|
}
|
||||||
@@ -102,18 +120,18 @@ export class NTQQMsgApi {
|
|||||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||||
(GroupCode: string, params: GetFileListParam) => Promise<unknown>,
|
(GroupCode: string, params: GetFileListParam) => Promise<unknown>,
|
||||||
(groupFileListResult: onGroupFileInfoUpdateParamType) => void
|
(groupFileListResult: onGroupFileInfoUpdateParamType) => void
|
||||||
>(
|
>(
|
||||||
'NodeIKernelRichMediaService/getGroupFileList',
|
'NodeIKernelRichMediaService/getGroupFileList',
|
||||||
'NodeIKernelMsgListener/onGroupFileInfoUpdate',
|
'NodeIKernelMsgListener/onGroupFileInfoUpdate',
|
||||||
1,
|
1,
|
||||||
5000,
|
5000,
|
||||||
(groupFileListResult: onGroupFileInfoUpdateParamType) => {
|
(groupFileListResult: onGroupFileInfoUpdateParamType) => {
|
||||||
//Developer Mlikiowa Todo: 此处有问题 无法判断是否成功
|
//Developer Mlikiowa Todo: 此处有问题 无法判断是否成功
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
GroupCode,
|
GroupCode,
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
return data[1].item;
|
return data[1].item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,24 +182,24 @@ export class NTQQMsgApi {
|
|||||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
const data = await this.core.eventWrapper.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>,
|
||||||
(msgList: RawMessage[]) => void
|
(msgList: RawMessage[]) => void
|
||||||
>(
|
>(
|
||||||
'NodeIKernelMsgService/sendMsg',
|
'NodeIKernelMsgService/sendMsg',
|
||||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
1,
|
1,
|
||||||
timeout,
|
timeout,
|
||||||
(msgRecords: RawMessage[]) => {
|
(msgRecords: RawMessage[]) => {
|
||||||
for (const msgRecord of msgRecords) {
|
for (const msgRecord of msgRecords) {
|
||||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
if (msgRecord.guildId === msgId && msgRecord.sendStatus === SendStatusType.KSEND_STATUS_SUCCESS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
},
|
return false;
|
||||||
'0',
|
},
|
||||||
peer,
|
'0',
|
||||||
msgElements,
|
peer,
|
||||||
new Map(),
|
msgElements,
|
||||||
);
|
new Map(),
|
||||||
|
);
|
||||||
const retMsg = data[1].find(msgRecord => {
|
const retMsg = data[1].find(msgRecord => {
|
||||||
if (msgRecord.guildId === msgId) {
|
if (msgRecord.guildId === msgId) {
|
||||||
return true;
|
return true;
|
||||||
@@ -209,25 +227,25 @@ export class NTQQMsgApi {
|
|||||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||||
(msgInfo: typeof msgInfos, srcPeer: Peer, destPeer: Peer, comment: Array<any>, attr: Map<any, any>) => Promise<unknown>,
|
(msgInfo: typeof msgInfos, srcPeer: Peer, destPeer: Peer, comment: Array<any>, attr: Map<any, any>) => Promise<unknown>,
|
||||||
(msgList: RawMessage[]) => void
|
(msgList: RawMessage[]) => void
|
||||||
>(
|
>(
|
||||||
'NodeIKernelMsgService/multiForwardMsgWithComment',
|
'NodeIKernelMsgService/multiForwardMsgWithComment',
|
||||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
1,
|
1,
|
||||||
5000,
|
5000,
|
||||||
(msgRecords: RawMessage[]) => {
|
(msgRecords: RawMessage[]) => {
|
||||||
for (const msgRecord of msgRecords) {
|
for (const msgRecord of msgRecords) {
|
||||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == this.core.selfInfo.uid) {
|
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == this.core.selfInfo.uid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
},
|
return false;
|
||||||
msgInfos,
|
},
|
||||||
srcPeer,
|
msgInfos,
|
||||||
destPeer,
|
srcPeer,
|
||||||
[],
|
destPeer,
|
||||||
new Map(),
|
[],
|
||||||
);
|
new Map(),
|
||||||
|
);
|
||||||
for (const msg of data[1]) {
|
for (const msg of data[1]) {
|
||||||
const arkElement = msg.elements.find(ele => ele.arkElement);
|
const arkElement = msg.elements.find(ele => ele.arkElement);
|
||||||
if (!arkElement) {
|
if (!arkElement) {
|
||||||
|
@@ -100,7 +100,7 @@ export class NTQQUserApi {
|
|||||||
return retData;
|
return retData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchUserDetailInfo(uid: string) {
|
async fetchUserDetailInfo(uid: string, mode: UserDetailSource = UserDetailSource.KDB) {
|
||||||
type EventService = NodeIKernelProfileService['fetchUserDetailInfo'];
|
type EventService = NodeIKernelProfileService['fetchUserDetailInfo'];
|
||||||
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged'];
|
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged'];
|
||||||
const [_retData, profile] = await this.core.eventWrapper.CallNormalEvent<EventService, EventListener>(
|
const [_retData, profile] = await this.core.eventWrapper.CallNormalEvent<EventService, EventListener>(
|
||||||
@@ -111,7 +111,7 @@ export class NTQQUserApi {
|
|||||||
(profile) => profile.uid === uid,
|
(profile) => profile.uid === uid,
|
||||||
'BuddyProfileStore',
|
'BuddyProfileStore',
|
||||||
[uid],
|
[uid],
|
||||||
UserDetailSource.KSERVER,
|
mode,
|
||||||
[ProfileBizType.KALL],
|
[ProfileBizType.KALL],
|
||||||
);
|
);
|
||||||
const RetUser: User = {
|
const RetUser: User = {
|
||||||
@@ -120,14 +120,20 @@ export class NTQQUserApi {
|
|||||||
...profile.simpleInfo.vasInfo,
|
...profile.simpleInfo.vasInfo,
|
||||||
...profile.commonExt,
|
...profile.commonExt,
|
||||||
...profile.simpleInfo.baseInfo,
|
...profile.simpleInfo.baseInfo,
|
||||||
qqLevel: profile.commonExt.qqLevel,
|
qqLevel: profile.commonExt?.qqLevel,
|
||||||
|
age: profile.simpleInfo.baseInfo.age,
|
||||||
pendantId: '',
|
pendantId: '',
|
||||||
};
|
};
|
||||||
return RetUser;
|
return RetUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfo(uid: string) {
|
async getUserDetailInfo(uid: string) {
|
||||||
return this.fetchUserDetailInfo(uid);
|
const ret = await this.fetchUserDetailInfo(uid, UserDetailSource.KDB);
|
||||||
|
if (ret.uin === '0') {
|
||||||
|
this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.')
|
||||||
|
return await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
async modifySelfProfile(param: ModifyProfileParams) {
|
async modifySelfProfile(param: ModifyProfileParams) {
|
||||||
@@ -187,9 +193,9 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
//后期改成流水线处理
|
//后期改成流水线处理
|
||||||
async getUidByUinV2(Uin: string) {
|
async getUidByUinV2(Uin: string) {
|
||||||
let uid = (await this.context.session.getProfileService().getUidByUin('FriendsServiceImpl', [Uin])).get(Uin);
|
let uid = (await this.context.session.getGroupService().getUidByUins([Uin])).uids.get(Uin);
|
||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
uid = (await this.context.session.getGroupService().getUidByUins([Uin])).uids.get(Uin);
|
uid = (await this.context.session.getProfileService().getUidByUin('FriendsServiceImpl', [Uin])).get(Uin);
|
||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
uid = (await this.context.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
uid = (await this.context.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
@@ -201,9 +207,9 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
//后期改成流水线处理
|
//后期改成流水线处理
|
||||||
async getUinByUidV2(Uid: string) {
|
async getUinByUidV2(Uid: string) {
|
||||||
let uin = (await this.context.session.getProfileService().getUinByUid('FriendsServiceImpl', [Uid])).get(Uid);
|
let uin = (await this.context.session.getGroupService().getUinByUids([Uid])).uins.get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
uin = (await this.context.session.getGroupService().getUinByUids([Uid])).uins.get(Uid);
|
uin = (await this.context.session.getProfileService().getUinByUid('FriendsServiceImpl', [Uid])).get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
uin = (await this.context.session.getUixConvertService().getUin([Uid])).uinInfo.get(Uid);
|
uin = (await this.context.session.getUixConvertService().getUin([Uid])).uinInfo.get(Uid);
|
||||||
if (uin) return uin;
|
if (uin) return uin;
|
||||||
@@ -234,11 +240,6 @@ export class NTQQUserApi {
|
|||||||
('NodeIKernelProfileService/getUserDetailInfoByUin', 5000, Uin);
|
('NodeIKernelProfileService/getUserDetailInfoByUin', 5000, Uin);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfoByUin(Uin: string) {
|
|
||||||
return this.core.eventWrapper.callNoListenerEvent<(Uin: string) => Promise<UserDetailInfoByUin>>
|
|
||||||
('NodeIKernelProfileService/getUserDetailInfoByUin', 5000, Uin);
|
|
||||||
}
|
|
||||||
|
|
||||||
async forceFetchClientKey() {
|
async forceFetchClientKey() {
|
||||||
return await this.context.session.getTicketService().forceFetchClientKey('');
|
return await this.context.session.getTicketService().forceFetchClientKey('');
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { QQLevel, Sex } from './user';
|
import { QQLevel, Sex, User } from './user';
|
||||||
|
|
||||||
export enum GroupListUpdateType {
|
export enum GroupListUpdateType {
|
||||||
REFRESHALL,
|
REFRESHALL,
|
||||||
@@ -65,6 +65,7 @@ export interface GroupMember {
|
|||||||
uin: string; // QQ号
|
uin: string; // QQ号
|
||||||
isRobot: boolean;
|
isRobot: boolean;
|
||||||
sex?: Sex;
|
sex?: Sex;
|
||||||
|
age?: number;
|
||||||
qqLevel?: QQLevel;
|
qqLevel?: QQLevel;
|
||||||
isChangeRole: boolean;
|
isChangeRole: boolean;
|
||||||
joinTime: string;
|
joinTime: string;
|
||||||
|
@@ -614,13 +614,28 @@ export interface PicElement {
|
|||||||
originImageUrl?: string; // http url, 没有host,host是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
|
originImageUrl?: string; // http url, 没有host,host是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum GrayTipElementSubType {
|
export enum NTGrayTipElementSubTypeV2 {
|
||||||
INVITE_NEW_MEMBER = 12,
|
GRAYTIP_ELEMENT_SUBTYPE_AIOOP = 15,
|
||||||
MEMBER_NEW_TITLE = 17
|
GRAYTIP_ELEMENT_SUBTYPE_BLOCK = 14,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_BUDDY = 5,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_BUDDYNOTIFY = 9,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_EMOJIREPLY = 3,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_ESSENCE = 7,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_FEED = 6,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_FEEDCHANNELMSG = 11,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_FILE = 10,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_GROUP = 4,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_GROUPNOTIFY = 8,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_JSON = 17,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_LOCALMSG = 13,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_PROCLAMATION = 2,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_REVOKE = 1,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_UNKNOWN = 0,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_WALLET = 16,
|
||||||
|
GRAYTIP_ELEMENT_SUBTYPE_XMLMSG = 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GrayTipElement {
|
export interface GrayTipElement {
|
||||||
subElementType: GrayTipElementSubType;
|
subElementType: NTGrayTipElementSubTypeV2;
|
||||||
revokeElement: {
|
revokeElement: {
|
||||||
operatorRole: string;
|
operatorRole: string;
|
||||||
operatorUid: string;
|
operatorUid: string;
|
||||||
@@ -876,6 +891,12 @@ export enum NTSubMsgType {
|
|||||||
KMSGSUBTYPEMIXTEXT = 0,
|
KMSGSUBTYPEMIXTEXT = 0,
|
||||||
KMSGSUBTYPETENCENTDOC = 6
|
KMSGSUBTYPETENCENTDOC = 6
|
||||||
}
|
}
|
||||||
|
export enum SendStatusType {
|
||||||
|
KSEND_STATUS_FAILED = 0,
|
||||||
|
KSEND_STATUS_SENDING = 1,
|
||||||
|
KSEND_STATUS_SUCCESS = 2,
|
||||||
|
KSEND_STATUS_SUCCESS_NOSEQ = 3
|
||||||
|
}
|
||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
parentMsgPeer: Peer;
|
parentMsgPeer: Peer;
|
||||||
|
|
||||||
@@ -935,7 +956,7 @@ export interface RawMessage {
|
|||||||
/**
|
/**
|
||||||
* 消息状态,别人发的 2 是已撤回,自己发的 2 是已发送
|
* 消息状态,别人发的 2 是已撤回,自己发的 2 是已发送
|
||||||
*/
|
*/
|
||||||
sendStatus?: number;
|
sendStatus?: SendStatusType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 撤回时间,"0" 是没有撤回
|
* 撤回时间,"0" 是没有撤回
|
||||||
|
@@ -231,6 +231,7 @@ export interface User {
|
|||||||
longNick?: string; // 签名
|
longNick?: string; // 签名
|
||||||
remark?: string;
|
remark?: string;
|
||||||
sex?: Sex;
|
sex?: Sex;
|
||||||
|
age?: number;
|
||||||
qqLevel?: QQLevel;
|
qqLevel?: QQLevel;
|
||||||
qid?: string;
|
qid?: string;
|
||||||
birthday_year?: number;
|
birthday_year?: number;
|
||||||
|
44
src/onebot/action/extends/SetInputStatus.ts
Normal file
44
src/onebot/action/extends/SetInputStatus.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { ChatType, Peer } from '@/core';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
eventType: { type: 'string' },
|
||||||
|
group_id: { type: 'string' },
|
||||||
|
user_id: { type: 'string' }
|
||||||
|
},
|
||||||
|
required: ['eventType'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class SetInputStatus extends BaseAction<Payload, any> {
|
||||||
|
actionName = ActionName.SetInputStatus;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
|
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||||
|
let peer: Peer;
|
||||||
|
if (payload.group_id) {
|
||||||
|
peer = {
|
||||||
|
chatType: ChatType.group,
|
||||||
|
peerUid: payload.group_id
|
||||||
|
}
|
||||||
|
} else if (payload.user_id) {
|
||||||
|
let uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
||||||
|
if (!uid) throw new Error('uid is empty');
|
||||||
|
peer = {
|
||||||
|
chatType: ChatType.friend,
|
||||||
|
peerUid: uid
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error('请指定 group_id 或 user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
const ret = await NTQQMsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
@@ -21,20 +21,23 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
async _handle(payload: Payload): Promise<OB11User> {
|
async _handle(payload: Payload): Promise<OB11User> {
|
||||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
|
||||||
const uid = (await NTQQUserApi.getUidByUinV2(user_id))!;
|
const uid = (await NTQQUserApi.getUidByUinV2(user_id))!;
|
||||||
if (!uid || uid.indexOf('*') != -1) {
|
if (!uid || uid.indexOf('*') != -1) {
|
||||||
const ret = {
|
const ret = {
|
||||||
...extendData,
|
...extendData.detail.simpleInfo.coreInfo,
|
||||||
user_id: parseInt(extendData.info.uin) || 0,
|
...extendData.detail.commonExt,
|
||||||
nickname: extendData.info.nick,
|
...extendData.detail.simpleInfo.baseInfo,
|
||||||
|
...extendData.detail.simpleInfo.relationFlags,
|
||||||
|
user_id: parseInt(extendData.detail.uin) || 0,
|
||||||
|
nickname: extendData.detail.simpleInfo.coreInfo.nick,
|
||||||
sex: OB11UserSex.unknown,
|
sex: OB11UserSex.unknown,
|
||||||
age: (extendData.info.birthday_year == 0) ? 0 : new Date().getFullYear() - extendData.info.birthday_year,
|
age: extendData.detail.simpleInfo.baseInfo.age || 0,
|
||||||
qid: extendData.info.qid,
|
qid: extendData.detail.simpleInfo.baseInfo.qid,
|
||||||
level: extendData.info.qqLevel && calcQQLevel(extendData.info.qqLevel) || 0,
|
level: calcQQLevel(extendData.detail.commonExt?.qqLevel ?? 0) || 0,
|
||||||
login_days: 0,
|
login_days: 0,
|
||||||
uid: '',
|
uid: ''
|
||||||
};
|
};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||||
|
@@ -3,6 +3,7 @@ import { OB11Constructor } from '../../helper/data';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { GroupMember } from '@/core';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -23,39 +24,25 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||||
const NTQQWebApi = this.CoreContext.apis.WebApi;
|
|
||||||
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
if (!uid) throw (`Uin2Uid Error ${payload.user_id}不存在`);
|
if (!uid) throw (`Uin2Uid Error ${payload.user_id}不存在`);
|
||||||
const member = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache);
|
const [member, info] = await Promise.allSettled([
|
||||||
if (!member) throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache),
|
||||||
try {
|
NTQQUserApi.getUserDetailInfo(uid),
|
||||||
const info = (await NTQQUserApi.getUserDetailInfo(member.uid));
|
]);
|
||||||
this.CoreContext.context.logger.logDebug('群成员详细信息结果', info);
|
if (member.status !== 'fulfilled') throw (`群(${payload.group_id})成员${payload.user_id}不存在 ${member.reason}`);
|
||||||
Object.assign(member, info);
|
if (info.status === 'fulfilled') {
|
||||||
} catch (e) {
|
this.CoreContext.context.logger.logDebug("群成员详细信息结果", info.value);
|
||||||
this.CoreContext.context.logger.logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
Object.assign(member, info.value);
|
||||||
|
} else {
|
||||||
|
this.CoreContext.context.logger.logDebug(`获取群成员详细信息失败, 只能返回基础信息 ${info.reason}`);
|
||||||
}
|
}
|
||||||
const date = Math.round(Date.now() / 1000);
|
const date = Math.round(Date.now() / 1000);
|
||||||
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member.value as GroupMember);
|
||||||
const SelfInfoInGroup = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), this.CoreContext.selfInfo.uid, isNocache);
|
const Member = await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id);
|
||||||
let isPrivilege = false;
|
retMember.last_sent_time = parseInt(Member?.lastSpeakTime || date.toString());
|
||||||
if (SelfInfoInGroup) {
|
retMember.join_time = parseInt(Member?.joinTime || date.toString());
|
||||||
isPrivilege = SelfInfoInGroup.role === 3 || SelfInfoInGroup.role === 4;
|
|
||||||
}
|
|
||||||
if (isPrivilege) {
|
|
||||||
const webGroupMembers = await NTQQWebApi.getGroupMembers(payload.group_id.toString());
|
|
||||||
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
|
||||||
if (webGroupMembers[i]?.uin && webGroupMembers[i].uin === retMember.user_id) {
|
|
||||||
retMember.join_time = webGroupMembers[i]?.join_time;
|
|
||||||
retMember.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
|
||||||
retMember.qage = webGroupMembers[i]?.qage;
|
|
||||||
retMember.level = webGroupMembers[i]?.lv.level.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
retMember.last_sent_time = parseInt((await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
|
|
||||||
retMember.join_time = parseInt((await this.CoreContext.apis.GroupApi.getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
|
||||||
return retMember;
|
return retMember;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,6 +78,7 @@ import { NapCatCore } from '@/core';
|
|||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||||
import GetGuildProfile from './guild/GetGuildProfile';
|
import GetGuildProfile from './guild/GetGuildProfile';
|
||||||
import SetModelShow from './go-cqhttp/SetModelShow';
|
import SetModelShow from './go-cqhttp/SetModelShow';
|
||||||
|
import { SetInputStatus } from './extends/SetInputStatus';
|
||||||
|
|
||||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||||
|
|
||||||
@@ -165,6 +166,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
|||||||
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
||||||
new GetGuildProfile(onebotContext, coreContext),
|
new GetGuildProfile(onebotContext, coreContext),
|
||||||
new SetModelShow(onebotContext, coreContext),
|
new SetModelShow(onebotContext, coreContext),
|
||||||
|
new SetInputStatus(onebotContext, coreContext),
|
||||||
];
|
];
|
||||||
const actionMap = new Map();
|
const actionMap = new Map();
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -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.23 Refactor Todo
|
// Mlikiowa V2.0.33 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.23 Refactor Todo
|
// Mlikiowa V2.0.33 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') {
|
||||||
|
@@ -88,11 +88,9 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
|||||||
// This function determines the type of message by the existence of user_id / group_id,
|
// This function determines the type of message by the existence of user_id / group_id,
|
||||||
// not message_type.
|
// not message_type.
|
||||||
// This redundant design of Ob11 here should be blamed.
|
// This redundant design of Ob11 here should be blamed.
|
||||||
const NTQQGroupApi = coreContext.apis.GroupApi;
|
|
||||||
const NTQQFriendApi = coreContext.apis.FriendApi;
|
const NTQQFriendApi = coreContext.apis.FriendApi;
|
||||||
const NTQQUserApi = coreContext.apis.UserApi;
|
const NTQQUserApi = coreContext.apis.UserApi;
|
||||||
if ((contextMode === ContextMode.Group || contextMode === ContextMode.Normal) && payload.group_id) {
|
if ((contextMode === ContextMode.Group || contextMode === ContextMode.Normal) && payload.group_id) {
|
||||||
const group = (await NTQQGroupApi.getGroups()).find(e => e.groupCode == payload.group_id?.toString());
|
|
||||||
return {
|
return {
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
peerUid: payload.group_id.toString(),
|
peerUid: payload.group_id.toString(),
|
||||||
@@ -134,21 +132,17 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// if (payload.message_type !== 'private' && payload.group_id && !(await getGroup(payload.group_id))) {
|
|
||||||
// return { valid: false, message: `群${payload.group_id}不存在` };
|
|
||||||
// }
|
|
||||||
if (payload.user_id && payload.message_type !== 'group') {
|
if (payload.user_id && payload.message_type !== 'group') {
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(uid!);
|
const isBuddy = await NTQQFriendApi.isBuddy(uid!);
|
||||||
// 此处有问题
|
if (!isBuddy) {}
|
||||||
if (!isBuddy) {
|
|
||||||
//return { valid: false, message: '异常消息' };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return { valid: true };
|
return { valid: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: OB11PostSendMsg): Promise<{ message_id: number }> {
|
async _handle(payload: OB11PostSendMsg): Promise<{ message_id: number }> {
|
||||||
|
if (payload.message_type === 'group') this.contextMode = ContextMode.Group;
|
||||||
|
if (payload.message_type === 'private') this.contextMode = ContextMode.Private;
|
||||||
const peer = await createContext(this.CoreContext, payload, this.contextMode);
|
const peer = await createContext(this.CoreContext, payload, this.contextMode);
|
||||||
|
|
||||||
const messages = normalize(
|
const messages = normalize(
|
||||||
|
@@ -106,5 +106,6 @@ export enum ActionName {
|
|||||||
TestApi01 = 'test_api_01',
|
TestApi01 = 'test_api_01',
|
||||||
FetchEmojiLike = 'fetch_emoji_like',
|
FetchEmojiLike = 'fetch_emoji_like',
|
||||||
GetGuildProfile = "get_guild_service_profile",
|
GetGuildProfile = "get_guild_service_profile",
|
||||||
SetModelShow = "_set_model_show"
|
SetModelShow = "_set_model_show",
|
||||||
|
SetInputStatus = "set_input_status"
|
||||||
}
|
}
|
||||||
|
@@ -15,9 +15,9 @@ import {
|
|||||||
FaceIndex,
|
FaceIndex,
|
||||||
Friend,
|
Friend,
|
||||||
FriendV2,
|
FriendV2,
|
||||||
GrayTipElementSubType,
|
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
|
NTGrayTipElementSubTypeV2,
|
||||||
Peer,
|
Peer,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SelfInfo,
|
SelfInfo,
|
||||||
@@ -149,6 +149,7 @@ export class OB11Constructor {
|
|||||||
message_data['type'] = OB11MessageDataType.reply;
|
message_data['type'] = OB11MessageDataType.reply;
|
||||||
//log("收到回复消息", element.replyElement);
|
//log("收到回复消息", element.replyElement);
|
||||||
try {
|
try {
|
||||||
|
let oldMsgFlag = false;
|
||||||
const records = msg.records.find(msgRecord => msgRecord.msgId === element?.replyElement?.sourceMsgIdInRecords);
|
const records = msg.records.find(msgRecord => msgRecord.msgId === element?.replyElement?.sourceMsgIdInRecords);
|
||||||
const peer = {
|
const peer = {
|
||||||
chatType: msg.chatType,
|
chatType: msg.chatType,
|
||||||
@@ -161,14 +162,15 @@ export class OB11Constructor {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
chatType: msg.chatType,
|
chatType: msg.chatType,
|
||||||
}, element.replyElement.replayMsgSeq, 1, true, true)).msgList[0];
|
}, element.replyElement.replayMsgSeq, 1, true, true)).msgList.find(msg => msg.msgRandom === records.msgRandom);
|
||||||
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
||||||
|
if (!replyMsg && records.msgRandom === '0') oldMsgFlag = true;
|
||||||
replyMsg = (await NTQQMsgApi.getSingleMsg(peer, element.replyElement.replayMsgSeq)).msgList[0];
|
replyMsg = (await NTQQMsgApi.getSingleMsg(peer, element.replyElement.replayMsgSeq)).msgList[0];
|
||||||
}
|
}
|
||||||
if (msg.peerUin == '284840486') {
|
if (msg.peerUin == '284840486') {
|
||||||
//合并消息内侧 消息具体定位不到
|
//合并消息内侧 消息具体定位不到
|
||||||
}
|
}
|
||||||
if ((!replyMsg || records.msgRandom !== replyMsg.msgRandom) && msg.peerUin !== '284840486') {
|
if ((!replyMsg || (records.msgRandom !== replyMsg.msgRandom && !oldMsgFlag || (oldMsgFlag && records.msgSeq !== replyMsg.msgSeq))) && msg.peerUin !== '284840486') {
|
||||||
throw new Error('回复消息消息验证失败');
|
throw new Error('回复消息消息验证失败');
|
||||||
}
|
}
|
||||||
message_data['data']['id'] = MessageUnique.createMsg({
|
message_data['data']['id'] = MessageUnique.createMsg({
|
||||||
@@ -286,13 +288,13 @@ export class OB11Constructor {
|
|||||||
chatType: msg.chatType,
|
chatType: msg.chatType,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
},
|
},
|
||||||
msg.msgId,
|
msg.msgId,
|
||||||
msg.msgSeq,
|
msg.msgSeq,
|
||||||
msg.senderUid,
|
msg.senderUid,
|
||||||
element.elementId,
|
element.elementId,
|
||||||
element.elementType.toString(),
|
element.elementType.toString(),
|
||||||
element.pttElement.fileSize || '0',
|
element.pttElement.fileSize || '0',
|
||||||
element.pttElement.fileUuid || '',
|
element.pttElement.fileUuid || '',
|
||||||
);
|
);
|
||||||
//以uuid作为文件名
|
//以uuid作为文件名
|
||||||
} else if (element.arkElement) {
|
} else if (element.arkElement) {
|
||||||
@@ -377,7 +379,7 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
for (const element of msg.elements) {
|
for (const element of msg.elements) {
|
||||||
if (element.grayTipElement) {
|
if (element.grayTipElement) {
|
||||||
if (element.grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
|
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr);
|
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
|
|
||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
@@ -398,7 +400,7 @@ 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.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
||||||
//好友添加成功事件
|
//好友添加成功事件
|
||||||
if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') {
|
if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') {
|
||||||
return new OB11FriendAddNoticeEvent(core, parseInt(msg.peerUin));
|
return new OB11FriendAddNoticeEvent(core, parseInt(msg.peerUin));
|
||||||
@@ -417,7 +419,7 @@ export class OB11Constructor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//log("group msg", msg);
|
//log("group msg", msg);
|
||||||
// Mlikiowa V2.0.23 Refactor Todo
|
// Mlikiowa V2.0.33 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) {
|
||||||
@@ -530,18 +532,18 @@ export class OB11Constructor {
|
|||||||
const senderUin = emojiLikeData.gtip.qq.jp;
|
const senderUin = emojiLikeData.gtip.qq.jp;
|
||||||
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
||||||
const emojiId = emojiLikeData.gtip.face.id;
|
const emojiId = emojiLikeData.gtip.face.id;
|
||||||
|
const peer = {
|
||||||
const replyMsgList = (await NTQQMsgApi.getMsgsBySeqAndCount({
|
|
||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid
|
||||||
}, msgSeq, 1, true, true)).msgList;
|
}
|
||||||
|
const replyMsgList = (await NTQQMsgApi.getMsgExBySeq(peer, msgSeq)).msgList;
|
||||||
if (replyMsgList.length < 1) {
|
if (replyMsgList.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const replyMsg = replyMsgList.filter(e => e.msgSeq == msgSeq).sort((a, b) => parseInt(a.msgTime) - parseInt(b.msgTime))[0];
|
||||||
const replyMsg = replyMsgList[0];
|
//console.log("表情回应消息长度检测", msgSeq, replyMsg.elements);
|
||||||
console.log('表情回应消息', msgSeq, ' 结算ID', replyMsg.msgId);
|
if (!replyMsg) throw new Error('找不到回应消息');
|
||||||
return new OB11GroupMsgEmojiLikeEvent(
|
return new OB11GroupMsgEmojiLikeEvent(
|
||||||
core,
|
core,
|
||||||
parseInt(msg.peerUid),
|
parseInt(msg.peerUid),
|
||||||
@@ -556,7 +558,7 @@ export class OB11Constructor {
|
|||||||
logger.logError('解析表情回应消息失败', e.stack);
|
logger.logError('解析表情回应消息失败', e.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) {
|
if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) {
|
||||||
logger.logDebug('收到新人被邀请进群消息', grayTipElement);
|
logger.logDebug('收到新人被邀请进群消息', grayTipElement);
|
||||||
const xmlElement = grayTipElement.xmlElement;
|
const xmlElement = grayTipElement.xmlElement;
|
||||||
if (xmlElement?.content) {
|
if (xmlElement?.content) {
|
||||||
@@ -582,7 +584,7 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//代码歧义 GrayTipElementSubType.MEMBER_NEW_TITLE
|
//代码歧义 GrayTipElementSubType.MEMBER_NEW_TITLE
|
||||||
else if (grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
|
else if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
|
||||||
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr);
|
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
//判断业务类型
|
//判断业务类型
|
||||||
@@ -709,7 +711,7 @@ export class OB11Constructor {
|
|||||||
nickname: member.nick,
|
nickname: member.nick,
|
||||||
card: member.cardName,
|
card: member.cardName,
|
||||||
sex: OB11Constructor.sex(member.sex!),
|
sex: OB11Constructor.sex(member.sex!),
|
||||||
age: 0,
|
age: member.age ?? 0,
|
||||||
area: '',
|
area: '',
|
||||||
level: '0',
|
level: '0',
|
||||||
qq_level: member.qqLevel && calcQQLevel(member.qqLevel) || 0,
|
qq_level: member.qqLevel && calcQQLevel(member.qqLevel) || 0,
|
||||||
|
@@ -18,10 +18,11 @@ import {
|
|||||||
SendVideoElement,
|
SendVideoElement,
|
||||||
viedo_type,
|
viedo_type,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
|
import * as fsnormal from 'node:fs';
|
||||||
import { promises as fs } from 'node:fs';
|
import { promises as fs } from 'node:fs';
|
||||||
import ffmpeg from 'fluent-ffmpeg';
|
import ffmpeg from 'fluent-ffmpeg';
|
||||||
import { calculateFileMD5, isGIF } from '@/common/utils/file';
|
import { calculateFileMD5, isGIF } from '@/common/utils/file';
|
||||||
import { getVideoInfo } from '@/common/utils/video';
|
import { defaultVideoThumbB64, getVideoInfo } from '@/common/utils/video';
|
||||||
import { encodeSilk } from '@/common/utils/audio';
|
import { encodeSilk } from '@/common/utils/audio';
|
||||||
import faceConfig from '@/core/external/face_config.json';
|
import faceConfig from '@/core/external/face_config.json';
|
||||||
import * as pathLib from 'node:path';
|
import * as pathLib from 'node:path';
|
||||||
@@ -140,11 +141,7 @@ export class SendMsgElementConstructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async video(coreContext: NapCatCore, filePath: string, fileName: string = '', diyThumbPath: string = '', videotype: viedo_type = viedo_type.VIDEO_FORMAT_MP4): Promise<SendVideoElement> {
|
static async video(coreContext: NapCatCore, filePath: string, fileName: string = '', diyThumbPath: string = '', videotype: viedo_type = viedo_type.VIDEO_FORMAT_MP4): Promise<SendVideoElement> {
|
||||||
const NTQQGroupApi = coreContext.apis.GroupApi;
|
|
||||||
const NTQQUserApi = coreContext.apis.UserApi;
|
|
||||||
const NTQQFileApi = coreContext.apis.FileApi;
|
const NTQQFileApi = coreContext.apis.FileApi;
|
||||||
const NTQQMsgApi = coreContext.apis.MsgApi;
|
|
||||||
const NTQQFriendApi = coreContext.apis.FriendApi;
|
|
||||||
const logger = coreContext.context.logger;
|
const logger = coreContext.context.logger;
|
||||||
const { fileName: _fileName, path, fileSize, md5 } = await NTQQFileApi.uploadFile(filePath, ElementType.VIDEO);
|
const { fileName: _fileName, path, fileSize, md5 } = await NTQQFileApi.uploadFile(filePath, ElementType.VIDEO);
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
@@ -179,7 +176,8 @@ export class SendMsgElementConstructor {
|
|||||||
resolve(thumbPath);
|
resolve(thumbPath);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
} else {
|
} else {
|
||||||
resolve(undefined);
|
fsnormal.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64'));
|
||||||
|
resolve(thumbPath);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.screenshots({
|
.screenshots({
|
||||||
@@ -224,6 +222,21 @@ export class SendMsgElementConstructor {
|
|||||||
// sourceVideoCodecFormat: 2
|
// sourceVideoCodecFormat: 2
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// "fileElement": {
|
||||||
|
// "fileMd5": "",
|
||||||
|
// "fileName": "1.mp4",
|
||||||
|
// "filePath": "C:\\Users\\nanae\\OneDrive\\Desktop\\1.mp4",
|
||||||
|
// "fileSize": "1847007",
|
||||||
|
// "picHeight": 1280,
|
||||||
|
// "picWidth": 720,
|
||||||
|
// "picThumbPath": {},
|
||||||
|
// "file10MMd5": "",
|
||||||
|
// "fileSha": "",
|
||||||
|
// "fileSha3": "",
|
||||||
|
// "fileUuid": "",
|
||||||
|
// "fileSubId": "",
|
||||||
|
// "thumbFileSize": 750
|
||||||
|
// }
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ import {
|
|||||||
MsgListener,
|
MsgListener,
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
|
SendStatusType,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config';
|
import { OB11Config, OB11ConfigLoader } from '@/onebot/helper/config';
|
||||||
import { OneBotApiContextType } from '@/onebot/types';
|
import { OneBotApiContextType } from '@/onebot/types';
|
||||||
@@ -250,7 +251,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
.catch(e => this.context.logger.logError('处理消息失败', e));
|
.catch(e => this.context.logger.logError('处理消息失败', e));
|
||||||
|
|
||||||
for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
|
for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) {
|
||||||
if (msg.sendStatus == 2 && !msgIdSend.get(msg.msgId)) {
|
if (msg.sendStatus == SendStatusType.KSEND_STATUS_SUCCESS && !msgIdSend.get(msg.msgId)) {
|
||||||
msgIdSend.put(msg.msgId, true);
|
msgIdSend.put(msg.msgId, true);
|
||||||
// 完成后再post
|
// 完成后再post
|
||||||
OB11Constructor.message(this.core, this, msg)
|
OB11Constructor.message(this.core, this, msg)
|
||||||
@@ -290,8 +291,8 @@ export class NapCatOneBot11Adapter {
|
|||||||
await this.networkManager.emitEvent(new OB11FriendRequestEvent(
|
await this.networkManager.emitEvent(new OB11FriendRequestEvent(
|
||||||
this.core,
|
this.core,
|
||||||
parseInt(requesterUin!),
|
parseInt(requesterUin!),
|
||||||
req.friendUid + '|' + req.reqTime,
|
|
||||||
req.extWords,
|
req.extWords,
|
||||||
|
req.friendUid + '|' + req.reqTime,
|
||||||
));
|
));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.context.logger.logDebug('获取加好友者QQ号失败', e);
|
this.context.logger.logDebug('获取加好友者QQ号失败', e);
|
||||||
@@ -325,11 +326,6 @@ export class NapCatOneBot11Adapter {
|
|||||||
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type;
|
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type;
|
||||||
this.context.logger.logDebug('收到群通知', notify);
|
this.context.logger.logDebug('收到群通知', notify);
|
||||||
|
|
||||||
// let member2: GroupMember;
|
|
||||||
// if (notify.user2.uid) {
|
|
||||||
// member2 = await getGroupMember(notify.group.groupCode, null, notify.user2.uid);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ([
|
if ([
|
||||||
GroupNotifyTypes.ADMIN_SET,
|
GroupNotifyTypes.ADMIN_SET,
|
||||||
GroupNotifyTypes.ADMIN_UNSET,
|
GroupNotifyTypes.ADMIN_UNSET,
|
||||||
@@ -400,12 +396,12 @@ export class NapCatOneBot11Adapter {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.context.logger.logError('获取加群人QQ号失败 Uid:', notify.user1.uid, e);
|
this.context.logger.logError('获取加群人QQ号失败 Uid:', notify.user1.uid, e);
|
||||||
}
|
}
|
||||||
} else if (notify.type == GroupNotifyTypes.INVITE_ME) {
|
} else if (notify.type == GroupNotifyTypes.INVITE_ME && notify.status == 1) {
|
||||||
this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
|
this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
|
||||||
const groupInviteEvent = new OB11GroupRequestEvent(
|
const groupInviteEvent = new OB11GroupRequestEvent(
|
||||||
this.core,
|
this.core,
|
||||||
parseInt(notify.group.groupCode),
|
parseInt(notify.group.groupCode),
|
||||||
parseInt(notify.user1.uid),
|
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid)),
|
||||||
'invite',
|
'invite',
|
||||||
notify.postscript,
|
notify.postscript,
|
||||||
flag,
|
flag,
|
||||||
|
@@ -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.23', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.0.33', '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.23", "napcat-update-button", "secondary")
|
SettingButton("V2.0.33", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user