mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8645a412b7 | ||
![]() |
acad07a588 | ||
![]() |
51bbb480bb | ||
![]() |
f0306cd10a | ||
![]() |
25253ad9e7 | ||
![]() |
51f2fb8e8b | ||
![]() |
9e8d650cbd | ||
![]() |
d222ccfa58 | ||
![]() |
9a05aaa906 | ||
![]() |
00fdce8876 | ||
![]() |
29b51adf7d | ||
![]() |
8e14b39969 | ||
![]() |
d9fb4d6c4d | ||
![]() |
fcf2f4c5f2 | ||
![]() |
4e97501690 | ||
![]() |
b0402391fb | ||
![]() |
f05a862cf9 | ||
![]() |
3ea92d57c2 | ||
![]() |
254b85fbd8 | ||
![]() |
16371c0cc4 |
@@ -19,6 +19,7 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
||||
**首次使用**请务必前往[官方文档](https://napneko.github.io/)查看使用教程。
|
||||
|
||||
## 相关链接
|
||||
[QQ Group](https://qm.qq.com/q/VfjAq5HIMS)
|
||||
|
||||
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"name": "NapCat",
|
||||
"slug": "NapCat",
|
||||
"description": "现代化的 OneBot 11 协议实现",
|
||||
"version": "2.0.12",
|
||||
"version": "2.0.18",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "2.0.12",
|
||||
"version": "2.0.18",
|
||||
"scripts": {
|
||||
"build:framework": "vite build --mode framework",
|
||||
"build:shell": "vite build --mode shell",
|
||||
|
@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import fs from 'fs';
|
||||
|
||||
export const napcat_version = '2.0.12';
|
||||
export const napcat_version = '2.0.18';
|
||||
|
||||
export class NapCatPathWrapper {
|
||||
binaryPath: string;
|
||||
|
@@ -117,31 +117,31 @@ export class NTQQFileApi {
|
||||
filePath: string
|
||||
}) => Promise<unknown>,
|
||||
(fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/downloadRichMedia',
|
||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||
1,
|
||||
timeout,
|
||||
(arg: OnRichMediaDownloadCompleteParams) => {
|
||||
if (arg.msgId === msgId) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
{
|
||||
fileModelId: '0',
|
||||
downloadSourceType: 0,
|
||||
triggerType: 1,
|
||||
msgId: msgId,
|
||||
chatType: chatType,
|
||||
peerUid: peerUid,
|
||||
elementId: elementId,
|
||||
thumbSize: 0,
|
||||
downloadType: 1,
|
||||
filePath: thumbPath,
|
||||
},
|
||||
);
|
||||
let msg = await this.core.apis.MsgApi.getMsgsByMsgId({
|
||||
>(
|
||||
'NodeIKernelMsgService/downloadRichMedia',
|
||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||
1,
|
||||
timeout,
|
||||
(arg: OnRichMediaDownloadCompleteParams) => {
|
||||
if (arg.msgId === msgId) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
{
|
||||
fileModelId: '0',
|
||||
downloadSourceType: 0,
|
||||
triggerType: 1,
|
||||
msgId: msgId,
|
||||
chatType: chatType,
|
||||
peerUid: peerUid,
|
||||
elementId: elementId,
|
||||
thumbSize: 0,
|
||||
downloadType: 1,
|
||||
filePath: thumbPath,
|
||||
},
|
||||
);
|
||||
const msg = await this.core.apis.MsgApi.getMsgsByMsgId({
|
||||
guildId: '',
|
||||
chatType: chatType,
|
||||
peerUid: peerUid,
|
||||
@@ -150,13 +150,13 @@ export class NTQQFileApi {
|
||||
return data[1].filePath;
|
||||
}
|
||||
//获取原始消息
|
||||
let FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
|
||||
const FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
|
||||
if (!FileElements) {
|
||||
//失败则就乱来 Todo
|
||||
return data[1].filePath;
|
||||
}
|
||||
//从原始消息获取文件路径
|
||||
let filePath =
|
||||
const filePath =
|
||||
FileElements?.fileElement?.filePath ||
|
||||
FileElements?.pttElement?.filePath ||
|
||||
FileElements?.videoElement?.filePath ||
|
||||
@@ -280,10 +280,10 @@ export class NTQQFileApi {
|
||||
let id = '';
|
||||
const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void>
|
||||
(
|
||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
);
|
||||
id = await Event!(keys, 12);
|
||||
const [ret] = (await Listener);
|
||||
|
@@ -83,12 +83,12 @@ export class NTQQFriendApi {
|
||||
async getFriends(forced = false): Promise<User[]> {
|
||||
const [_retData, _BuddyArg] = await this.core.eventWrapper.CallNormalEvent<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
||||
(
|
||||
'NodeIKernelBuddyService/getBuddyList',
|
||||
'NodeIKernelBuddyListener/onBuddyListChange',
|
||||
1,
|
||||
5000,
|
||||
() => true,
|
||||
forced,
|
||||
'NodeIKernelBuddyService/getBuddyList',
|
||||
'NodeIKernelBuddyListener/onBuddyListChange',
|
||||
1,
|
||||
5000,
|
||||
() => true,
|
||||
forced,
|
||||
);
|
||||
const friends: User[] = [];
|
||||
for (const categoryItem of _BuddyArg) {
|
||||
|
@@ -103,18 +103,18 @@ export class NTQQMsgApi {
|
||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||
(GroupCode: string, params: GetFileListParam) => Promise<unknown>,
|
||||
(groupFileListResult: onGroupFileInfoUpdateParamType) => void
|
||||
>(
|
||||
'NodeIKernelRichMediaService/getGroupFileList',
|
||||
'NodeIKernelMsgListener/onGroupFileInfoUpdate',
|
||||
1,
|
||||
5000,
|
||||
(groupFileListResult: onGroupFileInfoUpdateParamType) => {
|
||||
>(
|
||||
'NodeIKernelRichMediaService/getGroupFileList',
|
||||
'NodeIKernelMsgListener/onGroupFileInfoUpdate',
|
||||
1,
|
||||
5000,
|
||||
(groupFileListResult: onGroupFileInfoUpdateParamType) => {
|
||||
//Developer Mlikiowa Todo: 此处有问题 无法判断是否成功
|
||||
return true;
|
||||
},
|
||||
GroupCode,
|
||||
params,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
GroupCode,
|
||||
params,
|
||||
);
|
||||
return data[1].item;
|
||||
}
|
||||
|
||||
@@ -155,24 +155,24 @@ export class NTQQMsgApi {
|
||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||
(msgList: RawMessage[]) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/sendMsg',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
timeout,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.msgId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true;
|
||||
>(
|
||||
'NodeIKernelMsgService/sendMsg',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
timeout,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.msgId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
msgId,
|
||||
peer,
|
||||
msgElements,
|
||||
new Map(),
|
||||
);
|
||||
return false;
|
||||
},
|
||||
msgId,
|
||||
peer,
|
||||
msgElements,
|
||||
new Map(),
|
||||
);
|
||||
const retMsg = data[1].find(msgRecord => {
|
||||
if (msgRecord.msgId === msgId) {
|
||||
return true;
|
||||
@@ -186,7 +186,7 @@ export class NTQQMsgApi {
|
||||
}
|
||||
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
||||
//By Jadx/Ida Mlikiowa
|
||||
let TempGameSession = {
|
||||
const TempGameSession = {
|
||||
nickname: "",
|
||||
gameAppId: "",
|
||||
selfTinyId: "",
|
||||
@@ -210,7 +210,7 @@ export class NTQQMsgApi {
|
||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||
//唉? !我有个想法
|
||||
if (peer.chatType === ChatType.temp && peer.guildId && peer.guildId !== '') {
|
||||
let member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
||||
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
||||
if (member) {
|
||||
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
|
||||
}
|
||||
@@ -220,24 +220,24 @@ export class NTQQMsgApi {
|
||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||
(msgList: RawMessage[]) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/sendMsg',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
timeout,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true;
|
||||
>(
|
||||
'NodeIKernelMsgService/sendMsg',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
timeout,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
'0',
|
||||
peer,
|
||||
msgElements,
|
||||
new Map(),
|
||||
);
|
||||
return false;
|
||||
},
|
||||
'0',
|
||||
peer,
|
||||
msgElements,
|
||||
new Map(),
|
||||
);
|
||||
const retMsg = data[1].find(msgRecord => {
|
||||
if (msgRecord.guildId === msgId) {
|
||||
return true;
|
||||
@@ -272,25 +272,25 @@ export class NTQQMsgApi {
|
||||
const data = await this.core.eventWrapper.CallNormalEvent<
|
||||
(msgInfo: typeof msgInfos, srcPeer: Peer, destPeer: Peer, comment: Array<any>, attr: Map<any, any>) => Promise<unknown>,
|
||||
(msgList: RawMessage[]) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/multiForwardMsgWithComment',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
5000,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == this.core.selfInfo.uid) {
|
||||
return true;
|
||||
>(
|
||||
'NodeIKernelMsgService/multiForwardMsgWithComment',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
5000,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == this.core.selfInfo.uid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
msgInfos,
|
||||
srcPeer,
|
||||
destPeer,
|
||||
[],
|
||||
new Map(),
|
||||
);
|
||||
return false;
|
||||
},
|
||||
msgInfos,
|
||||
srcPeer,
|
||||
destPeer,
|
||||
[],
|
||||
new Map(),
|
||||
);
|
||||
for (const msg of data[1]) {
|
||||
const arkElement = msg.elements.find(ele => ele.arkElement);
|
||||
if (!arkElement) {
|
||||
|
@@ -155,16 +155,10 @@ export class NTQQUserApi {
|
||||
//需要异常处理
|
||||
async getCookies(domain: string) {
|
||||
const ClientKeyData = await this.forceFetchClientKey();
|
||||
const requestUrl = `https://ssl.ptlogin2.qq.com/jump?${
|
||||
new URLSearchParams({
|
||||
ptlang: '1033',
|
||||
clientuin: this.core.selfInfo.uin,
|
||||
clientkey: ClientKeyData.clientKey,
|
||||
u1: `https://user.qzone.qq.com/${this.core.selfInfo.uin}/infocenter`,
|
||||
keyindex: '19',
|
||||
})
|
||||
}`;
|
||||
return await RequestUtil.HttpsGetCookies(requestUrl);
|
||||
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + this.core.selfInfo.uin +
|
||||
'&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2F' + domain + '%2F' + this.core.selfInfo.uin + '%2Finfocenter&keyindex=19%27';
|
||||
const cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||
return cookies;
|
||||
}
|
||||
|
||||
async getPSkey(domainList: string[]) {
|
||||
|
@@ -13,7 +13,7 @@ import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
|
||||
//Framework ES入口文件
|
||||
export async function getWebUiUrl() {
|
||||
let WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
|
||||
const WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
|
||||
return "http://127.0.0.1:" + WebUiConfigData.port + '/webui/?token=' + WebUiConfigData.token;
|
||||
}
|
||||
export async function NCoreInitFramework(
|
||||
|
@@ -1,14 +1,38 @@
|
||||
|
||||
export const onSettingWindowCreated = async (view) => {
|
||||
view.style.width = "100%";
|
||||
view.style.height = "100%";
|
||||
//添加iframe
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.src = await window.napcat.getWebUiUrl();
|
||||
iframe.width = "100%";
|
||||
iframe.height = "100%";
|
||||
iframe.style.border = "none";
|
||||
//去掉iframe滚动条
|
||||
//iframe.scrolling = "no";
|
||||
//有滚动条何尝不是一种美
|
||||
view.appendChild(iframe);
|
||||
|
||||
// view.style.width = "100%";
|
||||
// view.style.height = "100%";
|
||||
// //添加iframe
|
||||
// const iframe = document.createElement("iframe");
|
||||
// iframe.src = await window.napcat.getWebUiUrl();
|
||||
// iframe.width = "100%";
|
||||
// iframe.height = "100%";
|
||||
// iframe.style.border = "none";
|
||||
// //去掉iframe滚动条
|
||||
// //iframe.scrolling = "no";
|
||||
// //有滚动条何尝不是一种美
|
||||
// view.appendChild(iframe);
|
||||
let webui = await window.napcat.getWebUiUrl();
|
||||
let panel = `
|
||||
<setting-section data-title="">
|
||||
<setting-panel>
|
||||
<setting-list data-direction="column">
|
||||
<setting-item>
|
||||
<setting-button data-type="primary" class="nc_openwebui">打开配置页面</setting-button>
|
||||
</setting-item>
|
||||
<setting-item>
|
||||
<div>
|
||||
<setting-text class="nc_webui">WebUi</setting-text>
|
||||
</div>
|
||||
</setting-item>
|
||||
</setting-list>
|
||||
</setting-panel>
|
||||
</setting-section>
|
||||
`;
|
||||
view.innerHTML = panel;
|
||||
view.querySelector(".nc_openwebui").addEventListener("click", () => {
|
||||
window.open(webui, "_blank");
|
||||
});
|
||||
view.querySelector(".nc_webui").innerText = webui;
|
||||
};
|
@@ -6,14 +6,9 @@ export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetFriendsWithCategory;
|
||||
|
||||
async _handle(payload: void) {
|
||||
if (this.CoreContext.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
|
||||
//全新逻辑
|
||||
return (await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
|
||||
...category,
|
||||
buddyList: OB11Constructor.friendsV2(category.buddyList),
|
||||
}));
|
||||
} else {
|
||||
throw new Error('this ntqq version not support, must be 26702 or later');
|
||||
}
|
||||
return (await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
|
||||
...category,
|
||||
buddyList: OB11Constructor.friendsV2(category.buddyList),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ export class GetRobotUinRange extends BaseAction<void, Array<any>> {
|
||||
actionName = ActionName.GetRobotUinRange;
|
||||
|
||||
async _handle(payload: void) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange());
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
return await NTQQUserApi.getRobotUinRange();
|
||||
}
|
||||
|
@@ -28,19 +28,6 @@ const GetFileBase_PayloadSchema = {
|
||||
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
PayloadSchema: any = GetFileBase_PayloadSchema;
|
||||
|
||||
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
|
||||
let element = msg.elements.find(e => e.fileElement);
|
||||
if (!element) {
|
||||
element = msg.elements.find(e => e.videoElement);
|
||||
if (element) {
|
||||
return { id: element.elementId, element: element.videoElement };
|
||||
} else {
|
||||
throw new Error('找不到文件');
|
||||
}
|
||||
}
|
||||
return { id: element.elementId, element: element.fileElement };
|
||||
}
|
||||
|
||||
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
@@ -92,7 +79,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
file_size: fileSize,
|
||||
file_name: fileName,
|
||||
};
|
||||
if (true/*enableLocalFile2Url*/) {
|
||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
@@ -132,7 +119,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
file_size: NTSearchNameResult[0].fileSize.toString(),
|
||||
file_name: NTSearchNameResult[0].fileName,
|
||||
};
|
||||
if (true/*enableLocalFile2Url*/) {
|
||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
|
@@ -40,7 +40,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
}
|
||||
const msgList = data.msgList;
|
||||
const messages = (await Promise.all(msgList.map(async msg => {
|
||||
const resMsg = await OB11Constructor.message(this.CoreContext, msg, 'array');
|
||||
const resMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext, msg);
|
||||
if (!resMsg) return;
|
||||
resMsg.message_id = MessageUnique.createMsg({
|
||||
guildId: '',
|
||||
|
@@ -53,7 +53,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
}));
|
||||
//转换消息
|
||||
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, 'array')))).filter(msg => !!msg);
|
||||
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, this.OneBotContext, msg)))).filter(msg => !!msg);
|
||||
return { 'messages': ob11MsgList };
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
||||
}));
|
||||
|
||||
//转换消息
|
||||
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, 'array')))).filter(msg => !!msg);
|
||||
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, this.OneBotContext, msg)))).filter(msg => !!msg);
|
||||
return { 'messages': ob11MsgList };
|
||||
}
|
||||
}
|
||||
|
10
src/onebot/action/go-cqhttp/SetModelShow.ts
Normal file
10
src/onebot/action/go-cqhttp/SetModelShow.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
export default class SetModelShow extends BaseAction<null, null> {
|
||||
actionName = ActionName.SetModelShow;
|
||||
|
||||
async _handle(payload: null): Promise<null> {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -20,9 +20,7 @@ export default class DelEssenceMsg extends BaseAction<Payload, any> {
|
||||
async _handle(payload: Payload): Promise<any> {
|
||||
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
||||
if (!msg) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
if (!msg) throw new Error('msg not found');
|
||||
return await NTQQGroupApi.removeGroupEssence(
|
||||
msg.Peer.peerUid,
|
||||
msg.MsgId,
|
||||
|
@@ -9,7 +9,7 @@ const SchemaData = {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
pages: { type: 'number' },
|
||||
},
|
||||
required: ['group_id', 'pages'],
|
||||
required: ['group_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
@@ -20,7 +20,7 @@ export class GetGroupEssence extends BaseAction<Payload, GroupEssenceMsgRet> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQWebApi = this.CoreContext.apis.WebApi;
|
||||
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), payload.pages.toString());
|
||||
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), (payload.pages || "0").toString());
|
||||
if (!ret) {
|
||||
throw new Error('获取失败');
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Mlikiowa V2.0.12 Refactor Todo
|
||||
// Mlikiowa V2.0.18 Refactor Todo
|
||||
// retMember.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
|
||||
// retMember.join_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Mlikiowa V2.0.12 Refactor Todo
|
||||
// Mlikiowa V2.0.18 Refactor Todo
|
||||
// _groupMembers.forEach(async item => {
|
||||
// item.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.lastSpeakTime || date.toString());
|
||||
// item.join_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.joinTime || date.toString());
|
||||
|
10
src/onebot/action/guild/GetGuildProfile.ts
Normal file
10
src/onebot/action/guild/GetGuildProfile.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
export default class GetGuildProfile extends BaseAction<null, null> {
|
||||
actionName = ActionName.GetGuildProfile;
|
||||
|
||||
async _handle(payload: null): Promise<null> {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -23,7 +23,7 @@ import GoCQHTTPGetStrangerInfo from './go-cqhttp/GetStrangerInfo';
|
||||
import SendLike from './user/SendLike';
|
||||
import SetGroupAddRequest from './group/SetGroupAddRequest';
|
||||
import SetGroupLeave from './group/SetGroupLeave';
|
||||
import GetGuildList from './group/GetGuildList';
|
||||
import GetGuildList from './guild/GetGuildList';
|
||||
import SetFriendAddRequest from './user/SetFriendAddRequest';
|
||||
import SetGroupWholeBan from './group/SetGroupWholeBan';
|
||||
import SetGroupName from './group/SetGroupName';
|
||||
@@ -76,6 +76,8 @@ import { FetchEmojiLike } from './extends/FetchEmojiLike';
|
||||
import { NapCatCore } from '@/core';
|
||||
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
import GetGuildProfile from './guild/GetGuildProfile';
|
||||
import SetModelShow from './go-cqhttp/SetModelShow';
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
|
||||
@@ -161,6 +163,8 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
||||
new SetGroupHeader(onebotContext, coreContext),
|
||||
new FetchCustomFace(onebotContext, coreContext),
|
||||
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
||||
new GetGuildProfile(onebotContext, coreContext),
|
||||
new SetModelShow(onebotContext, coreContext),
|
||||
];
|
||||
const actionMap = new Map();
|
||||
for (const action of actionHandlers) {
|
||||
|
@@ -28,8 +28,8 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
if (!payload.message_id) {
|
||||
throw Error('参数message_id不能为空');
|
||||
}
|
||||
const MsgShortId = await MessageUnique.getShortIdByMsgId(payload.message_id.toString());
|
||||
const msgIdWithPeer = await MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString()));
|
||||
const MsgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString());
|
||||
const msgIdWithPeer = MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString()));
|
||||
if (!msgIdWithPeer) {
|
||||
throw ('消息不存在');
|
||||
}
|
||||
@@ -37,8 +37,8 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
const msg = await NTQQMsgApi.getMsgsByMsgId(
|
||||
peer,
|
||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||
const retMsg = await OB11Constructor.message(this.CoreContext, msg.msgList[0], 'array');
|
||||
if(!retMsg) throw Error('消息为空');
|
||||
const retMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext, msg.msgList[0], 'array');
|
||||
if (!retMsg) throw Error('消息为空');
|
||||
try {
|
||||
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;
|
||||
retMsg.message_seq = retMsg.message_id;
|
||||
|
@@ -56,7 +56,7 @@ const _handlers: {
|
||||
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
||||
|
||||
// then the qq is a group member
|
||||
// Mlikiowa V2.0.12 Refactor Todo
|
||||
// Mlikiowa V2.0.18 Refactor Todo
|
||||
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
|
||||
if (!uid) throw new Error('Get Uid Error');
|
||||
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
||||
@@ -161,7 +161,7 @@ const _handlers: {
|
||||
} else {
|
||||
postData = data;
|
||||
}
|
||||
// Mlikiowa V2.0.12 Refactor Todo
|
||||
// Mlikiowa V2.0.18 Refactor Todo
|
||||
const signUrl = obContext.configLoader.configData.musicSignUrl;
|
||||
if (!signUrl) {
|
||||
if (data.type === 'qq') {
|
||||
|
@@ -104,5 +104,7 @@ export enum ActionName {
|
||||
FetchCustomFace = 'fetch_custom_face',
|
||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||
TestApi01 = 'test_api_01',
|
||||
FetchEmojiLike = 'fetch_emoji_like'
|
||||
FetchEmojiLike = 'fetch_emoji_like',
|
||||
GetGuildProfile = "get_guild_service_profile",
|
||||
SetModelShow = "_set_model_show"
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
|
||||
const cookiesObject = await NTQQUserApi.getCookies(payload.domain);
|
||||
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
|
||||
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
||||
const bkn = NTQQWebApi.getBknFromCookie(cookiesObject.p_skey);
|
||||
const bkn = cookiesObject?.skey ? NTQQWebApi.getBknFromCookie(cookiesObject) : '';
|
||||
return { cookies, bkn };
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ export default class GetRecentContact extends BaseAction<Payload, any> {
|
||||
const FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
||||
if (FastMsg.msgList.length > 0) {
|
||||
//扩展ret.info.changedList
|
||||
const lastestMsg = await OB11Constructor.message(this.CoreContext, FastMsg.msgList[0], 'array');
|
||||
const lastestMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext,FastMsg.msgList[0], 'array');
|
||||
return {
|
||||
lastestMsg: lastestMsg,
|
||||
peerUin: t.peerUin,
|
||||
|
@@ -42,11 +42,17 @@ import { OB11BaseNoticeEvent } from '../event/notice/OB11BaseNoticeEvent';
|
||||
import { OB11GroupEssenceEvent } from '../event/notice/OB11GroupEssenceEvent';
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
import { NapCatCore } from '@/core';
|
||||
import { NapCatOneBot11Adapter } from '..';
|
||||
|
||||
export class OB11Constructor {
|
||||
static async message(core: NapCatCore, msg: RawMessage, messagePostFormat: any): Promise<OB11Message | undefined> {
|
||||
if (msg.senderUin == "0") return;
|
||||
if (msg.peerUin == "0") return;
|
||||
static async message(
|
||||
core: NapCatCore,
|
||||
obcore: NapCatOneBot11Adapter,
|
||||
msg: RawMessage,
|
||||
messagePostFormat: string = obcore.configLoader.configData.messagePostFormat
|
||||
): Promise<OB11Message | undefined> {
|
||||
if (msg.senderUin == "0" || msg.senderUin == "") return;
|
||||
if (msg.peerUin == "0" || msg.peerUin == "") return;
|
||||
//跳过空消息
|
||||
const NTQQGroupApi = core.apis.GroupApi;
|
||||
const NTQQUserApi = core.apis.UserApi;
|
||||
@@ -280,13 +286,13 @@ export class OB11Constructor {
|
||||
chatType: msg.chatType,
|
||||
guildId: '',
|
||||
},
|
||||
msg.msgId,
|
||||
msg.msgSeq,
|
||||
msg.senderUid,
|
||||
element.elementId,
|
||||
element.elementType.toString(),
|
||||
element.pttElement.fileSize || '0',
|
||||
element.pttElement.fileUuid || '',
|
||||
msg.msgId,
|
||||
msg.msgSeq,
|
||||
msg.senderUid,
|
||||
element.elementId,
|
||||
element.elementType.toString(),
|
||||
element.pttElement.fileSize || '0',
|
||||
element.pttElement.fileUuid || '',
|
||||
);
|
||||
//以uuid作为文件名
|
||||
} else if (element.arkElement) {
|
||||
@@ -344,7 +350,7 @@ export class OB11Constructor {
|
||||
MultiMsg.parentMsgPeer = ParentMsgPeer;
|
||||
MultiMsg.parentMsgIdList = msg.parentMsgIdList;
|
||||
MultiMsg.id = MessageUnique.createMsg(ParentMsgPeer, MultiMsg.msgId);//该ID仅用查看 无法调用
|
||||
const msgList = await OB11Constructor.message(core, MultiMsg, 'array');
|
||||
const msgList = await OB11Constructor.message(core, obcore, MultiMsg, messagePostFormat);
|
||||
if (!msgList) continue;
|
||||
message_data['data']['content'].push(msgList);
|
||||
//console.log("合并消息", msgList);
|
||||
@@ -411,7 +417,7 @@ export class OB11Constructor {
|
||||
return;
|
||||
}
|
||||
//log("group msg", msg);
|
||||
// Mlikiowa V2.0.12 Refactor Todo
|
||||
// Mlikiowa V2.0.18 Refactor Todo
|
||||
// if (msg.senderUin && msg.senderUin !== '0') {
|
||||
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
|
||||
// if (member && member.cardName !== msg.sendMemberName) {
|
||||
|
@@ -253,9 +253,9 @@ export class NapCatOneBot11Adapter {
|
||||
if (msg.sendStatus == 2 && !msgIdSend.get(msg.msgId)) {
|
||||
msgIdSend.put(msg.msgId, true);
|
||||
// 完成后再post
|
||||
OB11Constructor.message(this.core, msg, this.configLoader.configData.messagePostFormat)
|
||||
OB11Constructor.message(this.core, this, msg)
|
||||
.then((ob11Msg) => {
|
||||
if(!ob11Msg) return;
|
||||
if (!ob11Msg) return;
|
||||
ob11Msg.target_id = parseInt(msg.peerUin);
|
||||
if (this.configLoader.configData.reportSelfMessage) {
|
||||
msg.id = MessageUnique.createMsg({
|
||||
@@ -425,8 +425,8 @@ export class NapCatOneBot11Adapter {
|
||||
private async emitMsg(message: RawMessage) {
|
||||
const { debug, reportSelfMessage, messagePostFormat } = this.configLoader.configData;
|
||||
this.context.logger.logDebug('收到新消息 RawMessage', message);
|
||||
OB11Constructor.message(this.core, message, messagePostFormat).then((ob11Msg) => {
|
||||
if(!ob11Msg) return;
|
||||
OB11Constructor.message(this.core, this, message, messagePostFormat).then((ob11Msg) => {
|
||||
if (!ob11Msg) return;
|
||||
this.context.logger.logDebug('转化为 OB11Message', ob11Msg);
|
||||
if (debug) {
|
||||
ob11Msg.raw = message;
|
||||
@@ -483,7 +483,7 @@ export class NapCatOneBot11Adapter {
|
||||
let operatorId = message.senderUin;
|
||||
for (const element of message.elements) {
|
||||
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
|
||||
if(!operatorUid) return;
|
||||
if (!operatorUid) return;
|
||||
const operator = await this.core.apis.GroupApi.getGroupMember(message.peerUin, operatorUid);
|
||||
operatorId = operator?.uin || message.senderUin;
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
let isClosedByError = false;
|
||||
|
||||
this.connection = new WebSocket(this.url, {
|
||||
maxPayload: 1024 * 1024 * 1024,
|
||||
headers: {
|
||||
'X-Self-ID': this.coreContext.selfInfo.uin,
|
||||
'Authorization': `Bearer ${this.token}`,
|
||||
@@ -79,12 +80,12 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
|
||||
});
|
||||
this.connection.on('open', () => {
|
||||
try{
|
||||
try {
|
||||
this.connectEvent(this.coreContext);
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
this.logger.logError('[OneBot] [WebSocket Client] 发送连接生命周期失败', e);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
this.connection.on('message', (data) => {
|
||||
this.handleMessage(data);
|
||||
|
@@ -36,8 +36,8 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
this.logger = coreContext.context.logger;
|
||||
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
this.wsServer = new WebSocketServer({ port: port, host: ip });
|
||||
let core = coreContext;
|
||||
this.wsServer = new WebSocketServer({ port: port, host: ip, maxPayload: 1024 * 1024 * 1024, });
|
||||
const core = coreContext;
|
||||
this.wsServer.on('connection', async (wsClient, wsReq) => {
|
||||
if (!this.isOpen) {
|
||||
wsClient.close();
|
||||
@@ -63,7 +63,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
});
|
||||
}).on('error', (err) => this.logger.log('[OneBot] [WebSocket Server] Server Error:', err.message));
|
||||
}
|
||||
|
||||
|
||||
connectEvent(core: NapCatCore, wsClient: WebSocket) {
|
||||
try {
|
||||
this.checkStateAndReply<any>(new OB11LifeCycleEvent(core, LifeCycleSubType.CONNECT), wsClient);
|
||||
|
@@ -168,20 +168,24 @@ export async function NCoreInitShell() {
|
||||
});
|
||||
});
|
||||
|
||||
if (quickLoginUin && historyLoginList.some(u => u.uin === quickLoginUin)) {
|
||||
logger.log('正在快速登录 ', quickLoginUin);
|
||||
setTimeout(() => {
|
||||
loginService.quickLoginWithUin(quickLoginUin)
|
||||
.then(result => {
|
||||
if (result.loginErrorInfo.errMsg) {
|
||||
logger.logError('快速登录错误:', result.loginErrorInfo.errMsg);
|
||||
loginService.getQRCodePicture();
|
||||
}
|
||||
})
|
||||
.catch();
|
||||
}, 1000);
|
||||
if (quickLoginUin) {
|
||||
if (historyLoginList.some(u => u.uin === quickLoginUin)) {
|
||||
logger.log('正在快速登录 ', quickLoginUin);
|
||||
setTimeout(() => {
|
||||
loginService.quickLoginWithUin(quickLoginUin)
|
||||
.then(result => {
|
||||
if (result.loginErrorInfo.errMsg) {
|
||||
logger.logError('快速登录错误:', result.loginErrorInfo.errMsg);
|
||||
loginService.getQRCodePicture();
|
||||
}
|
||||
})
|
||||
.catch();
|
||||
}, 1000);
|
||||
} else {
|
||||
logger.logError('快速登录失败,未找到该 QQ 历史登录记录,将使用二维码登录方式');
|
||||
}
|
||||
} else {
|
||||
logger.log('没有 -q 指令指定快速登录,或未曾登录过这个 QQ,将使用二维码登录方式');
|
||||
logger.log('没有 -q 指令指定快速登录,将使用二维码登录方式');
|
||||
if (historyLoginList.length > 0) {
|
||||
logger.log(`可用于快速登录的 QQ:\n${
|
||||
historyLoginList
|
||||
|
@@ -19,7 +19,7 @@ export let webUiPathWrapper: NapCatPathWrapper;
|
||||
export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapper) {
|
||||
webUiPathWrapper = pathWrapper;
|
||||
WebUiConfig = new WebUiConfigWrapper();
|
||||
let log = logger.log.bind(logger);
|
||||
const log = logger.log.bind(logger);
|
||||
const config = await WebUiConfig.GetWebUIConfig();
|
||||
if (config.port == 0) {
|
||||
log('[NapCat] [WebUi] Current WebUi is not run.');
|
||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
undefined,
|
||||
SettingButton('V2.0.12', 'napcat-update-button', 'secondary'),
|
||||
SettingButton('V2.0.18', 'napcat-update-button', 'secondary'),
|
||||
),
|
||||
]),
|
||||
SettingList([
|
||||
@@ -180,12 +180,12 @@ async function onSettingWindowCreated(view: Element) {
|
||||
'Telegram 群',
|
||||
'https://t.me/+nLZEnpne-pQ1OWFl',
|
||||
SettingButton('进去逛逛', 'open-telegram')
|
||||
),
|
||||
SettingItem(
|
||||
),
|
||||
SettingItem(
|
||||
'QQ 群',
|
||||
'518662028',
|
||||
SettingButton('我要进去', 'open-qq-group')
|
||||
),
|
||||
),
|
||||
'</div>',
|
||||
].join(''),
|
||||
'text/html',
|
||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
||||
SettingItem(
|
||||
'<span id="napcat-update-title">Napcat</span>',
|
||||
void 0,
|
||||
SettingButton("V2.0.12", "napcat-update-button", "secondary")
|
||||
SettingButton("V2.0.18", "napcat-update-button", "secondary")
|
||||
)
|
||||
]),
|
||||
SettingList([
|
||||
|
Reference in New Issue
Block a user