mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
35 Commits
forward-fi
...
ai-qun
Author | SHA1 | Date | |
---|---|---|---|
![]() |
63902d440f | ||
![]() |
956b6cd172 | ||
![]() |
bbaca3f044 | ||
![]() |
bb8a44b918 | ||
![]() |
b5574d5999 | ||
![]() |
06dde072da | ||
![]() |
8e92a81bb9 | ||
![]() |
2c7345ae88 | ||
![]() |
33d4696155 | ||
![]() |
7d2dcc10e5 | ||
![]() |
e82687454c | ||
![]() |
84382caebc | ||
![]() |
662530e507 | ||
![]() |
edf81d0a2e | ||
![]() |
7cbae86941 | ||
![]() |
8ff7420a5e | ||
![]() |
7ae59b1419 | ||
![]() |
41036f8ee8 | ||
![]() |
380777ca04 | ||
![]() |
c658cd1096 | ||
![]() |
c7b9946d2f | ||
![]() |
0caca473d6 | ||
![]() |
3e5d35957d | ||
![]() |
6b8b14aba2 | ||
![]() |
5db7a90a24 | ||
![]() |
88b86611a3 | ||
![]() |
886fe2052e | ||
![]() |
e4dd194d4a | ||
![]() |
faf390bb18 | ||
![]() |
cea900ca2a | ||
![]() |
941b30847b | ||
![]() |
4c5a26698e | ||
![]() |
d14a1dd948 | ||
![]() |
1c0b434f47 | ||
![]() |
573451bade |
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "4.7.33",
|
"version": "4.7.43",
|
||||||
"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": "4.7.33",
|
"version": "4.7.43",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
"ajv": "^8.13.0",
|
"ajv": "^8.13.0",
|
||||||
"async-mutex": "^0.5.0",
|
"async-mutex": "^0.5.0",
|
||||||
"commander": "^13.0.0",
|
"commander": "^13.0.0",
|
||||||
"cors": "^2.8.5",
|
|
||||||
"esbuild": "0.25.0",
|
"esbuild": "0.25.0",
|
||||||
"eslint": "^9.14.0",
|
"eslint": "^9.14.0",
|
||||||
"eslint-import-resolver-typescript": "^4.0.0",
|
"eslint-import-resolver-typescript": "^4.0.0",
|
||||||
@@ -63,7 +62,12 @@
|
|||||||
"compressing": "^1.10.1"
|
"compressing": "^1.10.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ffmpeg.wasm/core-mt": "^0.13.2",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"compressing": "^1.10.1",
|
||||||
"express": "^5.0.0",
|
"express": "^5.0.0",
|
||||||
|
"openai": "^4.85.1",
|
||||||
|
"piscina": "^4.7.0",
|
||||||
"silk-wasm": "^3.6.1",
|
"silk-wasm": "^3.6.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
}
|
}
|
||||||
|
@@ -115,7 +115,7 @@ async function tryDownload(options: string | HttpDownloadOptions, useReferer: bo
|
|||||||
if (useReferer && !headers['Referer']) {
|
if (useReferer && !headers['Referer']) {
|
||||||
headers['Referer'] = url;
|
headers['Referer'] = url;
|
||||||
}
|
}
|
||||||
const fetchRes = await fetch(url, { headers }).catch((err) => {
|
const fetchRes = await fetch(url, { headers, redirect: 'follow' }).catch((err) => {
|
||||||
if (err.cause) {
|
if (err.cause) {
|
||||||
throw err.cause;
|
throw err.cause;
|
||||||
}
|
}
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '4.7.33';
|
export const napCatVersion = '4.7.43';
|
||||||
|
@@ -345,6 +345,7 @@ export class NTQQFileApi {
|
|||||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||||
[{
|
[{
|
||||||
fileModelId: '0',
|
fileModelId: '0',
|
||||||
|
downSourceType: 0,
|
||||||
downloadSourceType: 0,
|
downloadSourceType: 0,
|
||||||
triggerType: 1,
|
triggerType: 1,
|
||||||
msgId: msgId,
|
msgId: msgId,
|
||||||
|
@@ -86,4 +86,31 @@ export class NTQQFriendApi {
|
|||||||
accept,
|
accept,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async handleDoubtFriendRequest(friendUid: string, str1: string = '', str2: string = '') {
|
||||||
|
this.context.session.getBuddyService().approvalDoubtBuddyReq(friendUid, str1, str2);
|
||||||
|
}
|
||||||
|
async getDoubtFriendRequest(count: number) {
|
||||||
|
let date = Date.now().toString();
|
||||||
|
const [, ret] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
|
'NodeIKernelBuddyService/getDoubtBuddyReq',
|
||||||
|
'NodeIKernelBuddyListener/onDoubtBuddyReqChange',
|
||||||
|
[date, count, ''],
|
||||||
|
() => true,
|
||||||
|
(data) => data.reqId === date
|
||||||
|
);
|
||||||
|
let requests = Promise.all(ret.doubtList.map(async (item) => {
|
||||||
|
return {
|
||||||
|
flag: item.uid, //注意强制String 非isNumeric 不遵守则不符合设计
|
||||||
|
uin: await this.core.apis.UserApi.getUinByUidV2(item.uid) ?? 0,// 信息字段
|
||||||
|
nick: item.nick, // 信息字段 这个不是nickname 可能是来源的群内的昵称
|
||||||
|
source: item.source, // 信息字段
|
||||||
|
reason: item.reason, // 信息字段
|
||||||
|
msg: item.msg, // 信息字段
|
||||||
|
group_code: item.groupCode, // 信息字段
|
||||||
|
time: item.reqTime, // 信息字段
|
||||||
|
type: 'doubt' //保留字段
|
||||||
|
};
|
||||||
|
}))
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
16
src/core/external/appid.json
vendored
16
src/core/external/appid.json
vendored
@@ -258,5 +258,21 @@
|
|||||||
"3.2.17-34467": {
|
"3.2.17-34467": {
|
||||||
"appid": 537282292,
|
"appid": 537282292,
|
||||||
"qua": "V1_LNX_NQ_3.2.17_34467_GW_B"
|
"qua": "V1_LNX_NQ_3.2.17_34467_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.19-34566": {
|
||||||
|
"appid": 537282307,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.19_34566_GW_B"
|
||||||
|
},
|
||||||
|
"3.2.17-34566": {
|
||||||
|
"appid": 537282343,
|
||||||
|
"qua": "V1_LNX_NQ_3.2.17_34566_GW_B"
|
||||||
|
},
|
||||||
|
"3.2.17-34606": {
|
||||||
|
"appid": 537282343,
|
||||||
|
"qua": "V1_LNX_NQ_3.2.17_34606_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.19-34606": {
|
||||||
|
"appid": 537282307,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.19_34606_GW_B"
|
||||||
}
|
}
|
||||||
}
|
}
|
18
src/core/external/offset.json
vendored
18
src/core/external/offset.json
vendored
@@ -327,12 +327,28 @@
|
|||||||
"send": "770CDC0",
|
"send": "770CDC0",
|
||||||
"recv": "77106F0"
|
"recv": "77106F0"
|
||||||
},
|
},
|
||||||
"9.9.19-34362-x64":{
|
"9.9.19-34362-x64": {
|
||||||
"send": "3BD80D0",
|
"send": "3BD80D0",
|
||||||
"recv": "3BDC8D0"
|
"recv": "3BDC8D0"
|
||||||
},
|
},
|
||||||
"9.9.19-34467-x64": {
|
"9.9.19-34467-x64": {
|
||||||
"send": "3BD8690",
|
"send": "3BD8690",
|
||||||
"recv": "3BDCE90"
|
"recv": "3BDCE90"
|
||||||
|
},
|
||||||
|
"9.9.19-34566-x64": {
|
||||||
|
"send": "3BDA110",
|
||||||
|
"recv": "3BDE910"
|
||||||
|
},
|
||||||
|
"9.9.19-34606-x64": {
|
||||||
|
"send": "3BDA110",
|
||||||
|
"recv": "3BDE910"
|
||||||
|
},
|
||||||
|
"3.2.17-34606-x64": {
|
||||||
|
"send": "AD7DC60",
|
||||||
|
"recv": "AD81680"
|
||||||
|
},
|
||||||
|
"3.2.17-34606-arm64": {
|
||||||
|
"send": "7711270",
|
||||||
|
"recv": "7714BA0"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -40,12 +40,30 @@ export class NodeIKernelBuddyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDelBatchBuddyInfos(arg: unknown): any {
|
onDelBatchBuddyInfos(arg: unknown): any {
|
||||||
|
console.log('onDelBatchBuddyInfos not implemented', ...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDoubtBuddyReqChange(arg: unknown): any {
|
onDoubtBuddyReqChange(_arg:
|
||||||
|
{
|
||||||
|
reqId: string;
|
||||||
|
cookie: string;
|
||||||
|
doubtList: Array<{
|
||||||
|
uid: string;
|
||||||
|
nick: string;
|
||||||
|
age: number,
|
||||||
|
sex: number;
|
||||||
|
commFriendNum: number;
|
||||||
|
reqTime: string;
|
||||||
|
msg: string;
|
||||||
|
source: string;
|
||||||
|
reason: string;
|
||||||
|
groupCode: string;
|
||||||
|
nameMore?: null;
|
||||||
|
}>;
|
||||||
|
}): void | Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDoubtBuddyReqUnreadNumChange(arg: unknown): any {
|
onDoubtBuddyReqUnreadNumChange(_num: number): void | Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onNickUpdated(arg: unknown): any {
|
onNickUpdated(arg: unknown): any {
|
||||||
|
@@ -21,7 +21,8 @@ export interface OnRichMediaDownloadCompleteParams {
|
|||||||
clientMsg: string,
|
clientMsg: string,
|
||||||
businessId: number,
|
businessId: number,
|
||||||
userTotalSpacePerDay: unknown,
|
userTotalSpacePerDay: unknown,
|
||||||
userUsedSpacePerDay: unknown
|
userUsedSpacePerDay: unknown,
|
||||||
|
chatType: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupFileInfoUpdateParamType {
|
export interface GroupFileInfoUpdateParamType {
|
||||||
@@ -97,112 +98,112 @@ export interface TempOnRecvParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NodeIKernelMsgListener {
|
export class NodeIKernelMsgListener {
|
||||||
onAddSendMsg(msgRecord: RawMessage): any {
|
onAddSendMsg(_msgRecord: RawMessage): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBroadcastHelperDownloadComplete(broadcastHelperTransNotifyInfo: unknown): any {
|
onBroadcastHelperDownloadComplete(_broadcastHelperTransNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBroadcastHelperProgressUpdate(broadcastHelperTransNotifyInfo: unknown): any {
|
onBroadcastHelperProgressUpdate(_broadcastHelperTransNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onChannelFreqLimitInfoUpdate(contact: unknown, z: unknown, freqLimitInfo: unknown): any {
|
onChannelFreqLimitInfoUpdate(_contact: unknown, _z: unknown, _freqLimitInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onContactUnreadCntUpdate(hashMap: unknown): any {
|
onContactUnreadCntUpdate(_hashMap: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCustomWithdrawConfigUpdate(customWithdrawConfig: unknown): any {
|
onCustomWithdrawConfigUpdate(_customWithdrawConfig: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onDraftUpdate(contact: unknown, arrayList: unknown, j2: unknown): any {
|
onDraftUpdate(_contact: unknown, _arrayList: unknown, _j2: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onEmojiDownloadComplete(emojiNotifyInfo: unknown): any {
|
onEmojiDownloadComplete(_emojiNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onEmojiResourceUpdate(emojiResourceInfo: unknown): any {
|
onEmojiResourceUpdate(_emojiResourceInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFeedEventUpdate(firstViewDirectMsgNotifyInfo: unknown): any {
|
onFeedEventUpdate(_firstViewDirectMsgNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFileMsgCome(arrayList: unknown): any {
|
onFileMsgCome(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFirstViewDirectMsgUpdate(firstViewDirectMsgNotifyInfo: unknown): any {
|
onFirstViewDirectMsgUpdate(_firstViewDirectMsgNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFirstViewGroupGuildMapping(arrayList: unknown): any {
|
onFirstViewGroupGuildMapping(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGrabPasswordRedBag(i2: unknown, str: unknown, i3: unknown, recvdOrder: unknown, msgRecord: unknown): any {
|
onGrabPasswordRedBag(_i2: unknown, _str: unknown, _i3: unknown, _recvdOrder: unknown, _msgRecord: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupFileInfoAdd(groupItem: unknown): any {
|
onGroupFileInfoAdd(_groupItem: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupFileInfoUpdate(groupFileListResult: GroupFileInfoUpdateParamType): any {
|
onGroupFileInfoUpdate(_groupFileListResult: GroupFileInfoUpdateParamType): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupGuildUpdate(groupGuildNotifyInfo: unknown): any {
|
onGroupGuildUpdate(_groupGuildNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onGroupTransferInfoAdd(groupItem: unknown): any {
|
onGroupTransferInfoAdd(_groupItem: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupTransferInfoUpdate(groupFileListResult: unknown): any {
|
onGroupTransferInfoUpdate(_groupFileListResult: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGuildInteractiveUpdate(guildInteractiveNotificationItem: unknown): any {
|
onGuildInteractiveUpdate(_guildInteractiveNotificationItem: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGuildMsgAbFlagChanged(guildMsgAbFlag: unknown): any {
|
onGuildMsgAbFlagChanged(_guildMsgAbFlag: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGuildNotificationAbstractUpdate(guildNotificationAbstractInfo: unknown): any {
|
onGuildNotificationAbstractUpdate(_guildNotificationAbstractInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHitCsRelatedEmojiResult(downloadRelateEmojiResultInfo: unknown): any {
|
onHitCsRelatedEmojiResult(_downloadRelateEmojiResultInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHitEmojiKeywordResult(hitRelatedEmojiWordsResult: unknown): any {
|
onHitEmojiKeywordResult(_hitRelatedEmojiWordsResult: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onHitRelatedEmojiResult(relatedWordEmojiInfo: unknown): any {
|
onHitRelatedEmojiResult(_relatedWordEmojiInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onImportOldDbProgressUpdate(importOldDbMsgNotifyInfo: unknown): any {
|
onImportOldDbProgressUpdate(_importOldDbMsgNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onInputStatusPush(inputStatusInfo: {
|
onInputStatusPush(_inputStatusInfo: {
|
||||||
chatType: number;
|
chatType: number;
|
||||||
eventType: number;
|
eventType: number;
|
||||||
fromUin: string;
|
fromUin: string;
|
||||||
@@ -215,55 +216,55 @@ export class NodeIKernelMsgListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onKickedOffLine(kickedInfo: KickedOffLineInfo): any {
|
onKickedOffLine(_kickedInfo: KickedOffLineInfo): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLineDev(arrayList: unknown): any {
|
onLineDev(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLogLevelChanged(j2: unknown): any {
|
onLogLevelChanged(_j2: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgAbstractUpdate(arrayList: unknown): any {
|
onMsgAbstractUpdate(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgBoxChanged(arrayList: unknown): any {
|
onMsgBoxChanged(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgDelete(contact: unknown, arrayList: unknown): any {
|
onMsgDelete(_contact: unknown, _arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgEventListUpdate(hashMap: unknown): any {
|
onMsgEventListUpdate(_hashMap: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgInfoListAdd(arrayList: unknown): any {
|
onMsgInfoListAdd(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgInfoListUpdate(msgList: RawMessage[]): any {
|
onMsgInfoListUpdate(_msgList: RawMessage[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgQRCodeStatusChanged(i2: unknown): any {
|
onMsgQRCodeStatusChanged(_i2: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgRecall(chatType: ChatType, uid: string, msgSeq: string): any {
|
onMsgRecall(_chatType: ChatType, _uid: string, _msgSeq: string): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgSecurityNotify(msgRecord: unknown): any {
|
onMsgSecurityNotify(_msgRecord: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgSettingUpdate(msgSetting: unknown): any {
|
onMsgSettingUpdate(_msgSetting: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,108 +280,108 @@ export class NodeIKernelMsgListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onReadFeedEventUpdate(firstViewDirectMsgNotifyInfo: unknown): any {
|
onReadFeedEventUpdate(_firstViewDirectMsgNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvGroupGuildFlag(i2: unknown): any {
|
onRecvGroupGuildFlag(_i2: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvMsg(arrayList: RawMessage[]): any {
|
onRecvMsg(_arrayList: RawMessage[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvMsgSvrRspTransInfo(j2: unknown, contact: unknown, i2: unknown, i3: unknown, str: unknown, bArr: unknown): any {
|
onRecvMsgSvrRspTransInfo(_j2: unknown, _contact: unknown, _i2: unknown, _i3: unknown, _str: unknown, _bArr: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvOnlineFileMsg(arrayList: unknown): any {
|
onRecvOnlineFileMsg(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvS2CMsg(arrayList: unknown): any {
|
onRecvS2CMsg(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvSysMsg(arrayList: Array<number>): any {
|
onRecvSysMsg(_arrayList: Array<number>): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecvUDCFlag(i2: unknown): any {
|
onRecvUDCFlag(_i2: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRichMediaDownloadComplete(fileTransNotifyInfo: OnRichMediaDownloadCompleteParams): any {
|
onRichMediaDownloadComplete(_fileTransNotifyInfo: OnRichMediaDownloadCompleteParams): any {
|
||||||
}
|
}
|
||||||
|
|
||||||
onRichMediaProgerssUpdate(fileTransNotifyInfo: unknown): any {
|
onRichMediaProgerssUpdate(_fileTransNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRichMediaUploadComplete(fileTransNotifyInfo: unknown): any {
|
onRichMediaUploadComplete(_fileTransNotifyInfo: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchGroupFileInfoUpdate(searchGroupFileResult: unknown): any {
|
onSearchGroupFileInfoUpdate(_searchGroupFileResult: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSendMsgError(j2: unknown, contact: unknown, i2: unknown, str: unknown): any {
|
onSendMsgError(_j2: unknown, _contact: unknown, _i2: unknown, _str: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSysMsgNotification(i2: unknown, j2: unknown, j3: unknown, arrayList: unknown): any {
|
onSysMsgNotification(_i2: unknown, _j2: unknown, _j3: unknown, _arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTempChatInfoUpdate(tempChatInfo: TempOnRecvParams): any {
|
onTempChatInfoUpdate(_tempChatInfo: TempOnRecvParams): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnreadCntAfterFirstView(hashMap: unknown): any {
|
onUnreadCntAfterFirstView(_hashMap: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnreadCntUpdate(hashMap: unknown): any {
|
onUnreadCntUpdate(_hashMap: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserChannelTabStatusChanged(z: unknown): any {
|
onUserChannelTabStatusChanged(_z: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserOnlineStatusChanged(z: unknown): any {
|
onUserOnlineStatusChanged(_z: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserTabStatusChanged(arrayList: unknown): any {
|
onUserTabStatusChanged(_arrayList: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineStatusBigIconDownloadPush(i2: unknown, j2: unknown, str: unknown): any {
|
onlineStatusBigIconDownloadPush(_i2: unknown, _j2: unknown, _str: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineStatusSmallIconDownloadPush(i2: unknown, j2: unknown, str: unknown): any {
|
onlineStatusSmallIconDownloadPush(_i2: unknown, _j2: unknown, _str: unknown): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第一次发现于Linux
|
// 第一次发现于Linux
|
||||||
onUserSecQualityChanged(...args: unknown[]): any {
|
onUserSecQualityChanged(..._args: unknown[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMsgWithRichLinkInfoUpdate(...args: unknown[]): any {
|
onMsgWithRichLinkInfoUpdate(..._args: unknown[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onRedTouchChanged(...args: unknown[]): any {
|
onRedTouchChanged(..._args: unknown[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第一次发现于Win 9.9.9-23159
|
// 第一次发现于Win 9.9.9-23159
|
||||||
onBroadcastHelperProgerssUpdate(...args: unknown[]): any {
|
onBroadcastHelperProgerssUpdate(..._args: unknown[]): any {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -106,15 +106,15 @@ export interface NodeIKernelBuddyService {
|
|||||||
|
|
||||||
getAddMeSetting(): unknown;
|
getAddMeSetting(): unknown;
|
||||||
|
|
||||||
getDoubtBuddyReq(): unknown;
|
getDoubtBuddyReq(reqId: string, num: number,uk:string): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
getDoubtBuddyUnreadNum(): number;
|
getDoubtBuddyUnreadNum(): number;
|
||||||
|
|
||||||
approvalDoubtBuddyReq(uid: number, isAgree: boolean): void;
|
approvalDoubtBuddyReq(uid: string, str1: string, str2: string): void;
|
||||||
|
|
||||||
delDoubtBuddyReq(uid: number): void;
|
delDoubtBuddyReq(uid: number): void;
|
||||||
|
|
||||||
delAllDoubtBuddyReq(): void;
|
delAllDoubtBuddyReq(): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
reportDoubtBuddyReqUnread(): void;
|
reportDoubtBuddyReqUnread(): void;
|
||||||
|
|
||||||
|
@@ -425,7 +425,20 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
switchToOfflineGetRichMediaElement(...args: unknown[]): unknown;
|
switchToOfflineGetRichMediaElement(...args: unknown[]): unknown;
|
||||||
|
|
||||||
downloadRichMedia(...args: unknown[]): unknown;
|
downloadRichMedia(args: {
|
||||||
|
fileModelId: string,
|
||||||
|
downSourceType: number,
|
||||||
|
triggerType: number,
|
||||||
|
msgId: string,
|
||||||
|
chatType: number,
|
||||||
|
peerUid: string,
|
||||||
|
elementId: string,
|
||||||
|
thumbSize: number,
|
||||||
|
downloadType: number,
|
||||||
|
filePath: string
|
||||||
|
} & {
|
||||||
|
downloadSourceType: number, //33800左右一下的老版本 新版34606已经完全上面格式
|
||||||
|
}): unknown;
|
||||||
|
|
||||||
getFirstUnreadMsgSeq(args: {
|
getFirstUnreadMsgSeq(args: {
|
||||||
peerUid: string
|
peerUid: string
|
||||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
model: Type.String(),
|
model: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
@@ -38,6 +38,7 @@ export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null>
|
|||||||
deleteAfterSentFiles: []
|
deleteAfterSentFiles: []
|
||||||
};
|
};
|
||||||
const sendFileEle = await this.core.apis.FileApi.createValidSendFileElement(msgContext, downloadResult.path, payload.name, payload.folder ?? payload.folder_id);
|
const sendFileEle = await this.core.apis.FileApi.createValidSendFileElement(msgContext, downloadResult.path, payload.name, payload.folder ?? payload.folder_id);
|
||||||
|
msgContext.deleteAfterSentFiles.push(downloadResult.path);
|
||||||
await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, [sendFileEle], msgContext.deleteAfterSentFiles);
|
await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, [sendFileEle], msgContext.deleteAfterSentFiles);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, nul
|
|||||||
if (payload.user_id) {
|
if (payload.user_id) {
|
||||||
const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
if (!peerUid) {
|
if (!peerUid) {
|
||||||
throw new Error( `私聊${payload.user_id}不存在`);
|
throw new Error(`私聊${payload.user_id}不存在`);
|
||||||
}
|
}
|
||||||
const isBuddy = await this.core.apis.FriendApi.isBuddy(peerUid);
|
const isBuddy = await this.core.apis.FriendApi.isBuddy(peerUid);
|
||||||
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||||
@@ -48,6 +48,7 @@ export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, nul
|
|||||||
deleteAfterSentFiles: []
|
deleteAfterSentFiles: []
|
||||||
};
|
};
|
||||||
const sendFileEle: SendFileElement = await this.core.apis.FileApi.createValidSendFileElement(msgContext, downloadResult.path, payload.name);
|
const sendFileEle: SendFileElement = await this.core.apis.FileApi.createValidSendFileElement(msgContext, downloadResult.path, payload.name);
|
||||||
|
msgContext.deleteAfterSentFiles.push(downloadResult.path);
|
||||||
await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(await this.getPeer(payload), [sendFileEle], msgContext.deleteAfterSentFiles);
|
await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(await this.getPeer(payload), [sendFileEle], msgContext.deleteAfterSentFiles);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -115,10 +115,16 @@ import { RenameGroupFile } from './extends/RenameGroupFile';
|
|||||||
import { GetRkeyServer } from './packet/GetRkeyServer';
|
import { GetRkeyServer } from './packet/GetRkeyServer';
|
||||||
import { GetRkeyEx } from './packet/GetRkeyEx';
|
import { GetRkeyEx } from './packet/GetRkeyEx';
|
||||||
import { CleanCache } from './system/CleanCache';
|
import { CleanCache } from './system/CleanCache';
|
||||||
|
import SetFriendRemark from './user/SetFriendRemark';
|
||||||
|
import { SetDoubtFriendsAddRequest } from './new/SetDoubtFriendsAddRequest';
|
||||||
|
import { GetDoubtFriendsAddRequest } from './new/GetDoubtFriendsAddRequest';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
|
new SetDoubtFriendsAddRequest(obContext, core),
|
||||||
|
new GetDoubtFriendsAddRequest(obContext, core),
|
||||||
|
new SetFriendRemark(obContext, core),
|
||||||
new GetRkeyEx(obContext, core),
|
new GetRkeyEx(obContext, core),
|
||||||
new GetRkeyServer(obContext, core),
|
new GetRkeyServer(obContext, core),
|
||||||
new SetGroupRemark(obContext, core),
|
new SetGroupRemark(obContext, core),
|
||||||
|
18
src/onebot/action/new/GetDoubtFriendsAddRequest.ts
Normal file
18
src/onebot/action/new/GetDoubtFriendsAddRequest.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
count: Type.Number({ default: 50 }),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class GetDoubtFriendsAddRequest extends OneBotAction<Payload, unknown> {
|
||||||
|
override actionName = ActionName.GetDoubtFriendsAddRequest;
|
||||||
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
return await this.core.apis.FriendApi.getDoubtFriendRequest(payload.count);
|
||||||
|
}
|
||||||
|
}
|
21
src/onebot/action/new/SetDoubtFriendsAddRequest.ts
Normal file
21
src/onebot/action/new/SetDoubtFriendsAddRequest.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
flag: Type.String(),
|
||||||
|
//注意强制String 非isNumeric 不遵守则不符合设计
|
||||||
|
approve: Type.Boolean({ default: true }),
|
||||||
|
//该字段没有语义 仅做保留 强制为True
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class SetDoubtFriendsAddRequest extends OneBotAction<Payload, unknown> {
|
||||||
|
override actionName = ActionName.SetDoubtFriendsAddRequest;
|
||||||
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
return await this.core.apis.FriendApi.handleDoubtFriendRequest(payload.flag);
|
||||||
|
}
|
||||||
|
}
|
@@ -10,6 +10,10 @@ export interface InvalidCheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ActionName = {
|
export const ActionName = {
|
||||||
|
// new extends 完全差异OneBot类别
|
||||||
|
GetDoubtFriendsAddRequest: 'get_doubt_friends_add_request',
|
||||||
|
SetDoubtFriendsAddRequest: 'set_doubt_friends_add_request',
|
||||||
|
// napcat
|
||||||
GetRkeyEx: 'get_rkey',
|
GetRkeyEx: 'get_rkey',
|
||||||
GetRkeyServer: 'get_rkey_server',
|
GetRkeyServer: 'get_rkey_server',
|
||||||
SetGroupRemark: 'set_group_remark',
|
SetGroupRemark: 'set_group_remark',
|
||||||
@@ -35,6 +39,7 @@ export const ActionName = {
|
|||||||
SetGroupLeave: 'set_group_leave',
|
SetGroupLeave: 'set_group_leave',
|
||||||
SetSpecialTitle: 'set_group_special_title',
|
SetSpecialTitle: 'set_group_special_title',
|
||||||
SetFriendAddRequest: 'set_friend_add_request',
|
SetFriendAddRequest: 'set_friend_add_request',
|
||||||
|
SetFriendRemark: 'set_friend_remark',
|
||||||
SetGroupAddRequest: 'set_group_add_request',
|
SetGroupAddRequest: 'set_group_add_request',
|
||||||
GetLoginInfo: 'get_login_info',
|
GetLoginInfo: 'get_login_info',
|
||||||
GoCQHTTP_GetStrangerInfo: 'get_stranger_info',
|
GoCQHTTP_GetStrangerInfo: 'get_stranger_info',
|
||||||
|
25
src/onebot/action/user/SetFriendRemark.ts
Normal file
25
src/onebot/action/user/SetFriendRemark.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
user_id: Type.String(),
|
||||||
|
remark: Type.String()
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export default class SetFriendRemark extends OneBotAction<Payload, null> {
|
||||||
|
override actionName = ActionName.SetFriendRemark;
|
||||||
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload): Promise<null> {
|
||||||
|
let friendUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id);
|
||||||
|
let is_friend = await this.core.apis.FriendApi.isBuddy(friendUid);
|
||||||
|
if (!is_friend) {
|
||||||
|
throw new Error(`用户 ${payload.user_id} 不是好友`);
|
||||||
|
}
|
||||||
|
await this.core.apis.FriendApi.setBuddyRemark(friendUid, payload.remark);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -250,7 +250,34 @@ export class OneBotGroupApi {
|
|||||||
'invite'
|
'invite'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
async parse51TypeEvent(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
|
// 神经腾讯 没了妈妈想出来的
|
||||||
|
// Warn 下面存在高并发危险
|
||||||
|
if (grayTipElement.jsonGrayTipElement.jsonStr) {
|
||||||
|
const json: {
|
||||||
|
align: string,
|
||||||
|
items: Array<{ txt: string, type: string }>
|
||||||
|
} = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
|
if (json.items.length === 1 && json.items[0]?.txt.endsWith('加入群')) {
|
||||||
|
let old_members = structuredClone(this.core.apis.GroupApi.groupMemberCache.get(msg.peerUid));
|
||||||
|
if (!old_members) return;
|
||||||
|
let new_members_map = await this.core.apis.GroupApi.refreshGroupMemberCache(msg.peerUid, true);
|
||||||
|
if (!new_members_map) return;
|
||||||
|
let new_members = Array.from(new_members_map.values());
|
||||||
|
// 对比members查找新成员
|
||||||
|
let new_member = new_members.find((member) => old_members.get(member.uid) == undefined);
|
||||||
|
if (!new_member) return;
|
||||||
|
return new OB11GroupIncreaseEvent(
|
||||||
|
this.core,
|
||||||
|
+msg.peerUid,
|
||||||
|
+new_member.uin,
|
||||||
|
0,
|
||||||
|
'invite',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
async parseGrayTipElement(msg: RawMessage, grayTipElement: GrayTipElement) {
|
||||||
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
||||||
// 解析群组事件 由sysmsg解析
|
// 解析群组事件 由sysmsg解析
|
||||||
@@ -282,6 +309,9 @@ export class OneBotGroupApi {
|
|||||||
return await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
return await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
} else if (grayTipElement.jsonGrayTipElement.busiId == JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
} else if (grayTipElement.jsonGrayTipElement.busiId == JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
||||||
return await this.parseEssenceMsg(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
return await this.parseEssenceMsg(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||||
|
} else if (+(grayTipElement.jsonGrayTipElement.busiId ?? 0) == 51) {
|
||||||
|
// 51是什么?{"align":"center","items":[{"txt":"下一秒起床通过王者荣耀加入群","type":"nor"}]
|
||||||
|
return await this.parse51TypeEvent(msg, grayTipElement);
|
||||||
} else {
|
} else {
|
||||||
return await this.parseOtherJsonEvent(msg, grayTipElement.jsonGrayTipElement.jsonStr, this.core.context);
|
return await this.parseOtherJsonEvent(msg, grayTipElement.jsonGrayTipElement.jsonStr, this.core.context);
|
||||||
}
|
}
|
||||||
|
@@ -907,10 +907,10 @@ export class OneBotMsgApi {
|
|||||||
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
||||||
resMsg.sender.nickname = member?.nick ?? member?.cardName ?? '临时会话';
|
resMsg.sender.nickname = member?.nick ?? member?.cardName ?? '临时会话';
|
||||||
resMsg.temp_source = resMsg.group_id;
|
resMsg.temp_source = 0;
|
||||||
} else {
|
} else {
|
||||||
resMsg.group_id = 284840486;
|
resMsg.group_id = 284840486;
|
||||||
resMsg.temp_source = resMsg.group_id;
|
resMsg.temp_source = 0;
|
||||||
resMsg.sender.nickname = '临时会话';
|
resMsg.sender.nickname = '临时会话';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ import {
|
|||||||
import { OB11Message } from './types';
|
import { OB11Message } from './types';
|
||||||
import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
|
import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
|
||||||
import { OB11HttpSSEServerAdapter } from './network/http-server-sse';
|
import { OB11HttpSSEServerAdapter } from './network/http-server-sse';
|
||||||
|
import { OB11PluginAdapter } from './network/plugin';
|
||||||
|
|
||||||
//OneBot实现类
|
//OneBot实现类
|
||||||
export class NapCatOneBot11Adapter {
|
export class NapCatOneBot11Adapter {
|
||||||
@@ -113,9 +114,9 @@ export class NapCatOneBot11Adapter {
|
|||||||
//创建NetWork服务
|
//创建NetWork服务
|
||||||
|
|
||||||
// 注册Plugin 如果需要基于NapCat进行快速开发
|
// 注册Plugin 如果需要基于NapCat进行快速开发
|
||||||
// this.networkManager.registerAdapter(
|
this.networkManager.registerAdapter(
|
||||||
// new OB11PluginAdapter('myPlugin', this.core, this,this.actions)
|
new OB11PluginAdapter('myPlugin', this.core, this,this.actions)
|
||||||
// );
|
);
|
||||||
for (const key of ob11Config.network.httpServers) {
|
for (const key of ob11Config.network.httpServers) {
|
||||||
if (key.enable) {
|
if (key.enable) {
|
||||||
this.networkManager.registerAdapter(
|
this.networkManager.registerAdapter(
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { OB11EmitEventContent, OB11NetworkReloadType } from './index';
|
import { OB11EmitEventContent, OB11NetworkReloadType } from './index';
|
||||||
import { NapCatOneBot11Adapter, OB11Message } from '@/onebot';
|
import { NapCatOneBot11Adapter, OB11ArrayMessage, OB11Message } from '@/onebot';
|
||||||
import { NapCatCore } from '@/core';
|
import { NapCatCore } from '@/core';
|
||||||
import { PluginConfig } from '../config/config';
|
import { PluginConfig } from '../config/config';
|
||||||
import { plugin_onmessage } from '@/plugin';
|
import { plugin_onmessage } from '@/plugin';
|
||||||
@@ -22,7 +22,7 @@ export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
|||||||
|
|
||||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||||
if (event.post_type === 'message') {
|
if (event.post_type === 'message') {
|
||||||
plugin_onmessage(this.config.name, this.core, this.obContext, event as OB11Message, this.actions, this).then().catch();
|
plugin_onmessage(this.config.name, this.core, this.obContext, event as OB11ArrayMessage, this.actions, this).then().catch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,10 @@ export interface OB11Message {
|
|||||||
post_type?: EventType;
|
post_type?: EventType;
|
||||||
raw?: RawMessage;
|
raw?: RawMessage;
|
||||||
}
|
}
|
||||||
|
export interface OB11ArrayMessage extends OB11Message {
|
||||||
|
message_format: 'array';
|
||||||
|
message: OB11MessageData[];
|
||||||
|
}
|
||||||
|
|
||||||
// 合并转发消息接口定义
|
// 合并转发消息接口定义
|
||||||
export interface OB11ForwardMessage extends OB11Message {
|
export interface OB11ForwardMessage extends OB11Message {
|
||||||
|
@@ -1,11 +1,217 @@
|
|||||||
import { NapCatOneBot11Adapter, OB11Message } from '@/onebot';
|
import { NapCatOneBot11Adapter, OB11ArrayMessage, OB11MessageDataType } from '@/onebot';
|
||||||
import { NapCatCore } from '@/core';
|
import { ChatType, NapCatCore, Peer, RawMessage } from '@/core';
|
||||||
import { ActionMap } from '@/onebot/action';
|
import { ActionMap } from '@/onebot/action';
|
||||||
import { OB11PluginAdapter } from '@/onebot/network/plugin';
|
import { OB11PluginAdapter } from '@/onebot/network/plugin';
|
||||||
|
import { OpenAI } from 'openai';
|
||||||
|
import { RequestUtil } from '@/common/request';
|
||||||
|
import { randomBytes } from 'node:crypto';
|
||||||
|
const client = new OpenAI({
|
||||||
|
apiKey: '',//必填多模态
|
||||||
|
baseURL: 'https://api.bili2233.work/v1'
|
||||||
|
});
|
||||||
|
|
||||||
export const plugin_onmessage = async (adapter: string, _core: NapCatCore, _obCtx: NapCatOneBot11Adapter, message: OB11Message, action: ActionMap, instance: OB11PluginAdapter) => {
|
async function handleMessageArray2String(messages: RawMessage[]): Promise<string[]> {
|
||||||
if (message.raw_message === 'ping') {
|
const result = [];
|
||||||
const ret = await action.get('send_group_msg')?.handle({ group_id: String(message.group_id), message: 'pong' }, adapter, instance.config);
|
let data = '';
|
||||||
console.log(ret);
|
for (let i = 0; i < messages.length; i++) {
|
||||||
|
try {
|
||||||
|
if (messages[i]) {
|
||||||
|
data += await handleMessage2String(messages[i]!) + '\n';
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((i + 1) % 1000 === 0 || i === messages.length - 1) {
|
||||||
|
result.push(data);
|
||||||
|
data = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleMessage2String(message: RawMessage): Promise<string> {
|
||||||
|
let data = '';
|
||||||
|
for (let element of message.elements) {
|
||||||
|
if (element.textElement) {
|
||||||
|
data += element.textElement.content.replaceAll('->', '').replaceAll('<-', '');
|
||||||
|
}
|
||||||
|
if (element.replyElement) {
|
||||||
|
const records = message.records.find(msgRecord => msgRecord.msgId === element.replyElement?.sourceMsgIdInRecords);
|
||||||
|
if (records) {
|
||||||
|
data += '[Reply] 回应别人的消息 ->' + await handleMessage2String(records) + '<-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.length === 0) throw new Error('消息为空');
|
||||||
|
return (message.sendMemberName || message.sendNickName) + ' 说: ->' + data + '<- ';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateChatCompletion(content_data: string): Promise<string> {
|
||||||
|
const chatCompletion = await client.chat.completions.create({
|
||||||
|
messages: [{ role: 'user', content: content_data }],
|
||||||
|
model: 'gemini-2.0-flash-thinking-exp'
|
||||||
|
});
|
||||||
|
console.log(chatCompletion);
|
||||||
|
return chatCompletion.choices[0]?.message.content || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateChatCompletionWithImg(content_data: string, url: string): Promise<string> {
|
||||||
|
const chatCompletion = await client.chat.completions.create({
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: 'user', content: [
|
||||||
|
{
|
||||||
|
type: 'text',
|
||||||
|
text: content_data
|
||||||
|
}, {
|
||||||
|
type: 'image_url',
|
||||||
|
image_url: {
|
||||||
|
url: url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
model: 'gemini-2.0-flash-thinking-exp'
|
||||||
|
});
|
||||||
|
return chatCompletion.choices[0]?.message.content || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const plugin_onmessage = async (
|
||||||
|
adapter: string,
|
||||||
|
core: NapCatCore,
|
||||||
|
_obCtx: NapCatOneBot11Adapter,
|
||||||
|
message: OB11ArrayMessage,
|
||||||
|
action: ActionMap,
|
||||||
|
instance: OB11PluginAdapter
|
||||||
|
) => {
|
||||||
|
|
||||||
|
|
||||||
|
if (!message.message.find(m => m.type === 'text' && m.data.text.includes('#画像'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const user_id = message.message.find(m => m.type === 'at')?.data.qq ?? message.sender.user_id;
|
||||||
|
const user_uid = await core.apis.UserApi.getUidByUinV2(user_id.toString());
|
||||||
|
if (!user_uid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: message.group_id?.toString() ?? '' };
|
||||||
|
const msg = await core.apis.MsgApi.queryFirstMsgBySender(peer, [user_uid]);
|
||||||
|
if (msg.msgList.length < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let msg_tag = '根据下面图片提取该图片的描述的描述,回应只用给出头像描述即可不要给出 好的 等等无关句子也不得提及该提示词,下面为图片内容。';
|
||||||
|
let avater_info = '头像仅供参考,Ta的头像描述: ' + await generateChatCompletionWithImg(msg_tag, `https://thirdqq.qlogo.cn/g?b=sdk&nk=${user_id}&s=100`);
|
||||||
|
console.log(`Final avater_info ret: ${avater_info}`)
|
||||||
|
const msg_string_all = await handleMessageArray2String(msg.msgList);
|
||||||
|
const user_info = await action.get('get_group_member_info')?.handle({ group_id: message.group_id?.toString()!, user_id: user_id }, adapter, instance.config);
|
||||||
|
|
||||||
|
if (msg_string_all.length > 1) {
|
||||||
|
const summaryPromises = msg_string_all.map(async (msg_string, i) => {
|
||||||
|
const content_data = `请根据下面聊天内容,分析 ${user_info?.data?.card || user_info?.data?.nickname} 的聊天风格分析其性格特点和一些有趣的信息和好笑的信息,为其建立用户画像,并加以幽默风趣的吐槽,下面是聊天内容,通过-><-字符区分结构。注意回复内容只用输出内容,不要提及此段话,注意一定不要使用markdown,请采用纯文本回复。附加提示信息:${avater_info} \n精选聊天记录: ${msg_string}`;
|
||||||
|
try {
|
||||||
|
const data = await generateChatCompletion(content_data);
|
||||||
|
if (data) {
|
||||||
|
msg_string_all[i] = '[总结(此消息过长Ai已压缩改为总结)] ->' + data + '<- ';
|
||||||
|
console.log(`Summary for part ${i + 1}: ${data}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
msg_string_all[i] = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await action.get('send_group_msg')?.handle({
|
||||||
|
group_id: String(message.group_id),
|
||||||
|
message: [
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.reply,
|
||||||
|
data: {
|
||||||
|
id: message.message_id.toString()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.text,
|
||||||
|
data: {
|
||||||
|
text: `消息过长,共` + msg.msgList.length + `条消息,预计时间` + Math.round(10 * msg.msgList.length / 1000) + `秒,请稍等...`
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}, adapter, instance.config);
|
||||||
|
await Promise.all(summaryPromises);
|
||||||
|
}
|
||||||
|
|
||||||
|
const msg_string = msg_string_all.join('\n');
|
||||||
|
|
||||||
|
const content_data =
|
||||||
|
`请根据下面聊天内容,分析 ${user_info?.data?.card || user_info?.data?.nickname} 的聊天风格分析其性格特点和一些有趣的信息和好笑的信息,为其建立用户画像,并加以幽默风趣的吐槽,下面是聊天内容,通过-><-字符区分结构。注意回复内容只用输出内容,不要提及此段话,注意一定不要使用markdown,请采用纯文本回复。附加信息:${avater_info} \n精选聊天记录:${msg_string}`;
|
||||||
|
console.log(`Final content data: ${content_data}`);
|
||||||
|
const msg_ret = await generateChatCompletion(content_data);
|
||||||
|
console.log(`Final content ret: ${msg_ret}`)
|
||||||
|
let pic_tag = `请根据下面对该人物性格的分析,并虚构想象一个场景,生成如 (1 cute girl with (cat ear and cat tail:1.2) stands in the garden:1.1), (cute:1.35), (detailed beautiful eyes:1.3), (beautiful face:1.3), casual, silver hair, silver ear, (blue hair:0.8), (blue ear:0.8), long hair, coat, short skirt, hair blowing with the wind, (blue eye:1.2), flowers, (little girl:0.65), butterflys flying around 格式的文本用于描述人物,注意格式为英文加空格加逗号进行区分,请务必多的描述人物和想象和场景,至少50个描述Tag,风格是可爱动漫二次元风,注意一定要是人为主体描述,不要好的什么的回应,只用给出要求格式的文本,不需要 好的 的回应,也不要提及此段话,下面为该人物性格分析.附加信息:${avater_info}.下面是人物分析.\n${msg_ret}`;
|
||||||
|
let pic_tag_ret = await generateChatCompletion(pic_tag);
|
||||||
|
let pic = `https://thirdqq.qlogo.cn/g?b=sdk&nk=${user_id}&s=100`;
|
||||||
|
try {
|
||||||
|
let pic_generate = await RequestUtil.HttpGetJson<{ images?: Array<{ url: string }> }>
|
||||||
|
('https://api.siliconflow.cn/v1/images/generations', 'POST', {
|
||||||
|
"model": "stabilityai/stable-diffusion-xl-base-1.0",
|
||||||
|
"prompt": 'original, (masterpiece), (illustration), (extremely fine and beautiful), perfect detailed, photorealistic, (beautiful and clear background:1.25), (depth of field:0.7),' + pic_tag_ret,
|
||||||
|
"seed": randomBytes(4).readUInt32LE(0),
|
||||||
|
"negative_prompt": "(copyright name:1.5),logo,(watermark:1.5),character_watermark,lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, ((cowboy)),(((pubic))), ((((pubic_hair))))sketch, duplicate, ugly, huge eyes, text, logo, monochrome, worst face, (bad and mutated hands:1.3), (worst quality:2.0), (low quality:2.0), (blurry:2.0), horror, geometry, bad_prompt, (bad hands), (missing fingers), multiple limbs, bad anatomy, (interlocked fingers:1.2), Ugly Fingers, (extra digit and hands and fingers and legs and arms:1.4), crown braid, ((2girl)), (deformed fingers:1.2), (long fingers:1.2),succubus wings,horn,succubus horn,succubus hairstyle, (bad-artist-anime), bad-artist, bad hand"
|
||||||
|
}, {
|
||||||
|
Authorization: 'Bearer ',//必填
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
});
|
||||||
|
if (pic_generate?.images?.[0]) {
|
||||||
|
pic = pic_generate?.images?.[0].url;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
await action.get('send_group_msg')?.handle({
|
||||||
|
group_id: String(message.group_id),
|
||||||
|
message: [{
|
||||||
|
type: OB11MessageDataType.node,
|
||||||
|
data: {
|
||||||
|
user_id: user_id,
|
||||||
|
nickname: user_info?.data?.card || user_info?.data?.nickname || '',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.text,
|
||||||
|
data: { text: msg_ret }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.node,
|
||||||
|
data: {
|
||||||
|
user_id: user_id,
|
||||||
|
nickname: user_info?.data?.card || user_info?.data?.nickname || '',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.text,
|
||||||
|
data: { text: 'Tag: ' + pic_tag_ret }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.node,
|
||||||
|
data: {
|
||||||
|
user_id: user_id,
|
||||||
|
nickname: user_info?.data?.card || user_info?.data?.nickname || '',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: OB11MessageDataType.image,
|
||||||
|
data: {
|
||||||
|
file: pic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, adapter, instance.config);
|
||||||
|
|
||||||
|
};
|
@@ -7,7 +7,8 @@ import { builtinModules } from 'module';
|
|||||||
const external = [
|
const external = [
|
||||||
'silk-wasm',
|
'silk-wasm',
|
||||||
'ws',
|
'ws',
|
||||||
'express'
|
'express',
|
||||||
|
'openai'
|
||||||
];
|
];
|
||||||
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user