mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 |
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.24",
|
"version": "2.0.31",
|
||||||
"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.24",
|
"version": "2.0.31",
|
||||||
"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.24';
|
export const napcat_version = '2.0.31';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
|
@@ -232,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) {
|
|
||||||
const fileExt = path.extname(HandledUri);
|
|
||||||
|
|
||||||
const fileName = filename + fileExt;
|
if (UriType == FileUriType.Remote) {
|
||||||
const filePath = path.join(dir, fileName);
|
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 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) {
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -187,9 +187,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;
|
||||||
@@ -234,11 +234,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('');
|
||||||
}
|
}
|
||||||
|
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,19 +21,22 @@ 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;
|
||||||
}
|
}
|
||||||
|
@@ -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.24 Refactor Todo
|
// Mlikiowa V2.0.31 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.24 Refactor Todo
|
// Mlikiowa V2.0.31 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"
|
||||||
}
|
}
|
||||||
|
@@ -417,7 +417,7 @@ export class OB11Constructor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//log("group msg", msg);
|
//log("group msg", msg);
|
||||||
// Mlikiowa V2.0.24 Refactor Todo
|
// Mlikiowa V2.0.31 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,19 +530,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;
|
}
|
||||||
console.log("表情回应消息长度检测", replyMsgList.length)
|
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.reverse()[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),
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -291,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);
|
||||||
@@ -396,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(await this.core.apis.UserApi.getUinByUidV2(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.24', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.0.31', '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.24", "napcat-update-button", "secondary")
|
SettingButton("V2.0.31", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user