mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
1 Commits
1999
...
forward-fi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
acccb7fce8 |
@@ -4,7 +4,7 @@
|
||||
"name": "NapCatQQ",
|
||||
"slug": "NapCat.Framework",
|
||||
"description": "高性能的 OneBot 11 协议实现",
|
||||
"version": "4.7.43",
|
||||
"version": "4.7.33",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "4.7.43",
|
||||
"version": "4.7.33",
|
||||
"scripts": {
|
||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||
@@ -41,7 +41,6 @@
|
||||
"ajv": "^8.13.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
"commander": "^13.0.0",
|
||||
"compressing": "^1.10.1",
|
||||
"cors": "^2.8.5",
|
||||
"esbuild": "0.25.0",
|
||||
"eslint": "^9.14.0",
|
||||
@@ -54,16 +53,16 @@
|
||||
"image-size": "^1.1.1",
|
||||
"json5": "^2.2.3",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"napcat.protobuf": "^1.1.4",
|
||||
"typescript": "^5.3.3",
|
||||
"typescript-eslint": "^8.13.0",
|
||||
"vite": "^6.0.1",
|
||||
"vite-plugin-cp": "^6.0.0",
|
||||
"vite-tsconfig-paths": "^5.1.0",
|
||||
"winston": "^3.17.0"
|
||||
"napcat.protobuf": "^1.1.4",
|
||||
"winston": "^3.17.0",
|
||||
"compressing": "^1.10.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@napi-rs/canvas": "^0.1.69",
|
||||
"express": "^5.0.0",
|
||||
"silk-wasm": "^3.6.1",
|
||||
"ws": "^8.18.0"
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB |
@@ -115,7 +115,7 @@ async function tryDownload(options: string | HttpDownloadOptions, useReferer: bo
|
||||
if (useReferer && !headers['Referer']) {
|
||||
headers['Referer'] = url;
|
||||
}
|
||||
const fetchRes = await fetch(url, { headers, redirect: 'follow' }).catch((err) => {
|
||||
const fetchRes = await fetch(url, { headers }).catch((err) => {
|
||||
if (err.cause) {
|
||||
throw err.cause;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
export const napCatVersion = '4.7.43';
|
||||
export const napCatVersion = '4.7.33';
|
||||
|
@@ -345,7 +345,6 @@ export class NTQQFileApi {
|
||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||
[{
|
||||
fileModelId: '0',
|
||||
downSourceType: 0,
|
||||
downloadSourceType: 0,
|
||||
triggerType: 1,
|
||||
msgId: msgId,
|
||||
|
@@ -86,31 +86,4 @@ export class NTQQFriendApi {
|
||||
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,21 +258,5 @@
|
||||
"3.2.17-34467": {
|
||||
"appid": 537282292,
|
||||
"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,28 +327,12 @@
|
||||
"send": "770CDC0",
|
||||
"recv": "77106F0"
|
||||
},
|
||||
"9.9.19-34362-x64": {
|
||||
"9.9.19-34362-x64":{
|
||||
"send": "3BD80D0",
|
||||
"recv": "3BDC8D0"
|
||||
},
|
||||
"9.9.19-34467-x64": {
|
||||
"send": "3BD8690",
|
||||
"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,30 +40,12 @@ export class NodeIKernelBuddyListener {
|
||||
}
|
||||
|
||||
onDelBatchBuddyInfos(arg: unknown): any {
|
||||
console.log('onDelBatchBuddyInfos not implemented', ...arguments);
|
||||
}
|
||||
|
||||
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> {
|
||||
onDoubtBuddyReqChange(arg: unknown): any {
|
||||
}
|
||||
|
||||
onDoubtBuddyReqUnreadNumChange(_num: number): void | Promise<void> {
|
||||
onDoubtBuddyReqUnreadNumChange(arg: unknown): any {
|
||||
}
|
||||
|
||||
onNickUpdated(arg: unknown): any {
|
||||
|
@@ -21,8 +21,7 @@ export interface OnRichMediaDownloadCompleteParams {
|
||||
clientMsg: string,
|
||||
businessId: number,
|
||||
userTotalSpacePerDay: unknown,
|
||||
userUsedSpacePerDay: unknown,
|
||||
chatType: number,
|
||||
userUsedSpacePerDay: unknown
|
||||
}
|
||||
|
||||
export interface GroupFileInfoUpdateParamType {
|
||||
@@ -98,112 +97,112 @@ export interface TempOnRecvParams {
|
||||
}
|
||||
|
||||
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;
|
||||
eventType: number;
|
||||
fromUin: string;
|
||||
@@ -216,55 +215,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 {
|
||||
|
||||
}
|
||||
|
||||
@@ -280,108 +279,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
|
||||
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
|
||||
onBroadcastHelperProgerssUpdate(..._args: unknown[]): any {
|
||||
onBroadcastHelperProgerssUpdate(...args: unknown[]): any {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -106,15 +106,15 @@ export interface NodeIKernelBuddyService {
|
||||
|
||||
getAddMeSetting(): unknown;
|
||||
|
||||
getDoubtBuddyReq(reqId: string, num: number,uk:string): Promise<GeneralCallResult>;
|
||||
getDoubtBuddyReq(): unknown;
|
||||
|
||||
getDoubtBuddyUnreadNum(): number;
|
||||
|
||||
approvalDoubtBuddyReq(uid: string, str1: string, str2: string): void;
|
||||
approvalDoubtBuddyReq(uid: number, isAgree: boolean): void;
|
||||
|
||||
delDoubtBuddyReq(uid: number): void;
|
||||
|
||||
delAllDoubtBuddyReq(): Promise<GeneralCallResult>;
|
||||
delAllDoubtBuddyReq(): void;
|
||||
|
||||
reportDoubtBuddyReqUnread(): void;
|
||||
|
||||
|
@@ -425,20 +425,7 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
switchToOfflineGetRichMediaElement(...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;
|
||||
downloadRichMedia(...args: unknown[]): unknown;
|
||||
|
||||
getFirstUnreadMsgSeq(args: {
|
||||
peerUid: string
|
||||
|
@@ -3,7 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
model: Type.Optional(Type.String()),
|
||||
model: Type.String(),
|
||||
});
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
@@ -38,7 +38,6 @@ export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null>
|
||||
deleteAfterSentFiles: []
|
||||
};
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, nul
|
||||
if (payload.user_id) {
|
||||
const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!peerUid) {
|
||||
throw new Error(`私聊${payload.user_id}不存在`);
|
||||
throw new Error( `私聊${payload.user_id}不存在`);
|
||||
}
|
||||
const isBuddy = await this.core.apis.FriendApi.isBuddy(peerUid);
|
||||
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||
@@ -48,7 +48,6 @@ export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, nul
|
||||
deleteAfterSentFiles: []
|
||||
};
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
@@ -115,16 +115,10 @@ import { RenameGroupFile } from './extends/RenameGroupFile';
|
||||
import { GetRkeyServer } from './packet/GetRkeyServer';
|
||||
import { GetRkeyEx } from './packet/GetRkeyEx';
|
||||
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) {
|
||||
|
||||
const actionHandlers = [
|
||||
new SetDoubtFriendsAddRequest(obContext, core),
|
||||
new GetDoubtFriendsAddRequest(obContext, core),
|
||||
new SetFriendRemark(obContext, core),
|
||||
new GetRkeyEx(obContext, core),
|
||||
new GetRkeyServer(obContext, core),
|
||||
new SetGroupRemark(obContext, core),
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
OB11MessageData,
|
||||
OB11MessageDataType,
|
||||
OB11MessageForward,
|
||||
OB11MessageMixType,
|
||||
OB11MessageNode,
|
||||
OB11PostContext,
|
||||
@@ -12,7 +13,7 @@ import { MessageUnique } from '@/common/message-unique';
|
||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendArkElement, SendMessageElement } from '@/core';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ForwardMsgBuilder } from '@/common/forward-msg-builder';
|
||||
import { stringifyWithBigInt } from '@/common/helper';
|
||||
import { isNumeric, stringifyWithBigInt } from '@/common/helper';
|
||||
import { PacketMsg } from '@/core/packet/message/message';
|
||||
import { rawMsgWithSendMsg } from '@/core/packet/message/converter';
|
||||
|
||||
@@ -152,21 +153,25 @@ export class SendMsgBase extends OneBotAction<OB11PostSendMsg, ReturnDataType> {
|
||||
} else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) {
|
||||
throw Error(`发送转发消息(res_id:${returnMsgAndResId.res_id} 失败`);
|
||||
}
|
||||
} else {
|
||||
// if (getSpecialMsgNum(payload, OB11MessageDataType.music)) {
|
||||
// const music: OB11MessageCustomMusic = messages[0] as OB11MessageCustomMusic;
|
||||
// if (music) {
|
||||
// }
|
||||
// }
|
||||
} else if (await this.getIsFowardOneMsg(messages)) {
|
||||
let onebot_inner_forward = await this.getIsFowardOneMsg(messages);
|
||||
if (!onebot_inner_forward) throw Error('转发消息失败,未找到消息');
|
||||
const real_msgid = MessageUnique.getMsgIdAndPeerByShortId(+onebot_inner_forward.data.id)?.MsgId || onebot_inner_forward.data.id;
|
||||
await this.core.apis.MsgApi.forwardMsg(peer,
|
||||
peer,
|
||||
[real_msgid]
|
||||
);
|
||||
// 暂时没办法筛选的委屈办法
|
||||
return { message_id: +onebot_inner_forward.data.id };
|
||||
}
|
||||
// log("send msg:", peer, sendElements)
|
||||
|
||||
const { sendElements, deleteAfterSentFiles } = await this.obContext.apis.MsgApi
|
||||
.createSendElements(messages, peer);
|
||||
const returnMsg = await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles);
|
||||
return { message_id: returnMsg.id! };
|
||||
}
|
||||
|
||||
private async getIsFowardOneMsg(message: OB11MessageData[]): Promise<OB11MessageForward | undefined> {
|
||||
return message.find(msg => msg.type === OB11MessageDataType.forward && isNumeric(msg.data.id)) as OB11MessageForward | undefined;
|
||||
}
|
||||
private async uploadForwardedNodesPacket(msgPeer: Peer, messageNodes: OB11MessageNode[], source?: string, news?: {
|
||||
text: string
|
||||
}[], summary?: string, prompt?: string, parentMeta?: {
|
||||
|
@@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
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,10 +10,6 @@ export interface InvalidCheckResult {
|
||||
}
|
||||
|
||||
export const ActionName = {
|
||||
// new extends 完全差异OneBot类别
|
||||
GetDoubtFriendsAddRequest: 'get_doubt_friends_add_request',
|
||||
SetDoubtFriendsAddRequest: 'set_doubt_friends_add_request',
|
||||
// napcat
|
||||
GetRkeyEx: 'get_rkey',
|
||||
GetRkeyServer: 'get_rkey_server',
|
||||
SetGroupRemark: 'set_group_remark',
|
||||
@@ -39,7 +35,6 @@ export const ActionName = {
|
||||
SetGroupLeave: 'set_group_leave',
|
||||
SetSpecialTitle: 'set_group_special_title',
|
||||
SetFriendAddRequest: 'set_friend_add_request',
|
||||
SetFriendRemark: 'set_friend_remark',
|
||||
SetGroupAddRequest: 'set_group_add_request',
|
||||
GetLoginInfo: 'get_login_info',
|
||||
GoCQHTTP_GetStrangerInfo: 'get_stranger_info',
|
||||
|
@@ -1,25 +0,0 @@
|
||||
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,34 +250,7 @@ export class OneBotGroupApi {
|
||||
'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) {
|
||||
if (grayTipElement.subElementType === NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_GROUP) {
|
||||
// 解析群组事件 由sysmsg解析
|
||||
@@ -309,9 +282,6 @@ export class OneBotGroupApi {
|
||||
return await this.parsePaiYiPai(msg, grayTipElement.jsonGrayTipElement.jsonStr);
|
||||
} else if (grayTipElement.jsonGrayTipElement.busiId == JsonGrayBusiId.AIO_GROUP_ESSENCE_MSG_TIP) {
|
||||
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 {
|
||||
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);
|
||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
||||
resMsg.sender.nickname = member?.nick ?? member?.cardName ?? '临时会话';
|
||||
resMsg.temp_source = 0;
|
||||
resMsg.temp_source = resMsg.group_id;
|
||||
} else {
|
||||
resMsg.group_id = 284840486;
|
||||
resMsg.temp_source = 0;
|
||||
resMsg.temp_source = resMsg.group_id;
|
||||
resMsg.sender.nickname = '临时会话';
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,6 @@ import {
|
||||
import { OB11Message } from './types';
|
||||
import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
|
||||
import { OB11HttpSSEServerAdapter } from './network/http-server-sse';
|
||||
import { OB11PluginAdapter } from './network/plugin';
|
||||
|
||||
//OneBot实现类
|
||||
export class NapCatOneBot11Adapter {
|
||||
@@ -114,9 +113,9 @@ export class NapCatOneBot11Adapter {
|
||||
//创建NetWork服务
|
||||
|
||||
// 注册Plugin 如果需要基于NapCat进行快速开发
|
||||
this.networkManager.registerAdapter(
|
||||
new OB11PluginAdapter('myPlugin', this.core, this,this.actions)
|
||||
);
|
||||
// this.networkManager.registerAdapter(
|
||||
// new OB11PluginAdapter('myPlugin', this.core, this,this.actions)
|
||||
// );
|
||||
for (const key of ob11Config.network.httpServers) {
|
||||
if (key.enable) {
|
||||
this.networkManager.registerAdapter(
|
||||
|
@@ -22,7 +22,7 @@ export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
||||
|
||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||
if (event.post_type === 'message') {
|
||||
plugin_onmessage(this.config.name, this.core, this.obContext, event as OB11Message, this.actions, this).then().catch(console.log);
|
||||
plugin_onmessage(this.config.name, this.core, this.obContext, event as OB11Message, this.actions, this).then().catch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,203 +0,0 @@
|
||||
/**
|
||||
* TapTap账号管理类
|
||||
*/
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
export class TapAccountManager {
|
||||
private userBindTapMap = new Map<string, {
|
||||
default: string;
|
||||
list: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
}>;
|
||||
}>();
|
||||
private dataFilePath: string;
|
||||
|
||||
constructor(dataDir: string = './data') {
|
||||
// 确保数据目录存在
|
||||
if (!fs.existsSync(dataDir)) {
|
||||
fs.mkdirSync(dataDir, { recursive: true });
|
||||
}
|
||||
this.dataFilePath = path.join(dataDir, 'tap_accounts.json');
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
saveData() {
|
||||
try {
|
||||
// 将 Map 转换为可序列化的对象
|
||||
const dataObj: Record<string, any> = {};
|
||||
this.userBindTapMap.forEach((value, key) => {
|
||||
dataObj[key] = value;
|
||||
});
|
||||
|
||||
fs.writeFileSync(
|
||||
this.dataFilePath,
|
||||
JSON.stringify(dataObj, null, 2),
|
||||
'utf-8'
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('保存 TapTap 账号数据失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
loadData() {
|
||||
try {
|
||||
if (fs.existsSync(this.dataFilePath)) {
|
||||
const fileContent = fs.readFileSync(this.dataFilePath, 'utf-8');
|
||||
const dataObj = JSON.parse(fileContent);
|
||||
|
||||
// 清空当前数据并加载新数据
|
||||
this.userBindTapMap.clear();
|
||||
for (const [key, value] of Object.entries(dataObj)) {
|
||||
this.userBindTapMap.set(key, value as any);
|
||||
}
|
||||
|
||||
console.log('TapTap 账号数据已加载');
|
||||
} else {
|
||||
console.log('未找到 TapTap 账号数据文件,将创建新的数据存储');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载 TapTap 账号数据失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定TapTap ID
|
||||
*/
|
||||
async bindAccount(userId: string, tapId: string, characterName: string): Promise<boolean> {
|
||||
// 用户首次绑定账号
|
||||
if (!this.userBindTapMap.has(userId)) {
|
||||
this.userBindTapMap.set(userId, {
|
||||
default: tapId,
|
||||
list: [{
|
||||
id: tapId,
|
||||
name: characterName
|
||||
}]
|
||||
});
|
||||
await this.saveData();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 用户已有账号,追加新账号
|
||||
const userData = this.userBindTapMap.get(userId)!;
|
||||
// 检查是否已经绑定过该ID
|
||||
if (!userData.list.some(item => item.id === tapId)) {
|
||||
userData.list.push({
|
||||
id: tapId,
|
||||
name: characterName
|
||||
});
|
||||
userData.default = tapId; // 新绑定的账号自动设为默认
|
||||
await this.saveData();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 账号已存在
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换默认TapTap ID
|
||||
*/
|
||||
async switchAccount(userId: string, tapId: string): Promise<boolean> {
|
||||
const userData = this.userBindTapMap.get(userId);
|
||||
if (!userData) return false;
|
||||
|
||||
const accountItem = userData.list.find(item => item.id === tapId);
|
||||
if (!accountItem) return false;
|
||||
|
||||
userData.default = tapId;
|
||||
await this.saveData();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除绑定的TapTap ID
|
||||
* @returns 删除结果、剩余默认账号信息(如果有)
|
||||
*/
|
||||
async deleteAccount(userId: string, tapId: string): Promise<{
|
||||
success: boolean;
|
||||
deletedAccount?: { id: string; name: string; };
|
||||
defaultAccount?: { id: string; name: string; };
|
||||
isEmpty: boolean;
|
||||
}> {
|
||||
const userData = this.userBindTapMap.get(userId);
|
||||
if (!userData) {
|
||||
return { success: false, isEmpty: true };
|
||||
}
|
||||
|
||||
const index = userData.list.findIndex(item => item.id === tapId);
|
||||
if (index === -1) {
|
||||
return { success: false, isEmpty: false };
|
||||
}
|
||||
|
||||
const deletedAccount = userData.list[index];
|
||||
userData.list.splice(index, 1);
|
||||
|
||||
// 如果删除的是当前默认账号,则需要重新设置默认账号
|
||||
if (userData.default === tapId) {
|
||||
userData.default = userData.list.length > 0 ? userData.list[0]?.id ?? '' : '';
|
||||
}
|
||||
|
||||
// 如果没有绑定账号了,则删除该用户的记录
|
||||
let result;
|
||||
if (userData.list.length === 0) {
|
||||
this.userBindTapMap.delete(userId);
|
||||
result = {
|
||||
success: true,
|
||||
deletedAccount,
|
||||
isEmpty: true
|
||||
};
|
||||
} else {
|
||||
const defaultAccount = userData.list.find(item => item.id === userData.default);
|
||||
result = {
|
||||
success: true,
|
||||
deletedAccount,
|
||||
defaultAccount,
|
||||
isEmpty: false
|
||||
};
|
||||
}
|
||||
|
||||
await this.saveData();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账号列表
|
||||
*/
|
||||
getAccountList(userId: string): {
|
||||
hasAccounts: boolean;
|
||||
accounts?: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
}>;
|
||||
} {
|
||||
const userData = this.userBindTapMap.get(userId);
|
||||
if (!userData || userData.list.length === 0) {
|
||||
return { hasAccounts: false };
|
||||
}
|
||||
|
||||
const accounts = userData.list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
isDefault: item.id === userData.default
|
||||
}));
|
||||
|
||||
return { hasAccounts: true, accounts };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户当前默认账号ID
|
||||
*/
|
||||
getDefaultAccount(userId: string): {
|
||||
hasDefault: boolean;
|
||||
tapId?: string;
|
||||
} {
|
||||
const userData = this.userBindTapMap.get(userId);
|
||||
if (!userData || !userData.default) {
|
||||
return { hasDefault: false };
|
||||
}
|
||||
return { hasDefault: true, tapId: userData.default };
|
||||
}
|
||||
}
|
@@ -1,255 +0,0 @@
|
||||
export interface GameUserDetail {
|
||||
data: Data;
|
||||
now: number;
|
||||
success: boolean;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
config: Config;
|
||||
external_url: string;
|
||||
is_bind: boolean;
|
||||
list: DataList[];
|
||||
next_page: string;
|
||||
prev_page: string;
|
||||
role_id: string;
|
||||
sharing: Sharing;
|
||||
show_bind_button: boolean;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
app_icon: AppIcon;
|
||||
banner: Banner;
|
||||
font_class: string;
|
||||
font_color: string;
|
||||
label: Label;
|
||||
show_bind_expired_alert: boolean;
|
||||
tint: number;
|
||||
title: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface AppIcon {
|
||||
color: string;
|
||||
height: number;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_size: number;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
width: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Banner {
|
||||
color: string;
|
||||
height: number;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_size: number;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
width: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface DataList {
|
||||
basic_module?: BasicModule;
|
||||
character_module?: CharacterModule;
|
||||
episode_module?: EpisodeModule;
|
||||
is_sharing: boolean;
|
||||
item_progress?: ItemProgress;
|
||||
module_type: number;
|
||||
weapon_module?: WeaponModule;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface BasicModule {
|
||||
avatar: BasicModuleAvatar;
|
||||
custom_items: BasicModuleCustomItem[];
|
||||
custom_title: string;
|
||||
info: Info[];
|
||||
name: string;
|
||||
role_id: string;
|
||||
subtitle: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface BasicModuleAvatar {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface BasicModuleCustomItem {
|
||||
is_main: boolean;
|
||||
key: string;
|
||||
value: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
main_value: string;
|
||||
name: string;
|
||||
sub_value: string;
|
||||
value: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface CharacterModule {
|
||||
custom_title: string;
|
||||
list: CharacterModuleList[];
|
||||
total: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface CharacterModuleList {
|
||||
grade: string;
|
||||
image: PurpleImage;
|
||||
level: number;
|
||||
name: string;
|
||||
talent_level: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface PurpleImage {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface EpisodeModule {
|
||||
custom_items: EpisodeModuleCustomItem[];
|
||||
custom_title: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface EpisodeModuleCustomItem {
|
||||
is_main: boolean;
|
||||
key: string;
|
||||
value: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface ItemProgress {
|
||||
custom_title: string;
|
||||
list: ItemProgressList[];
|
||||
table_tabs: string[];
|
||||
total: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface ItemProgressList {
|
||||
avatar: ListAvatar;
|
||||
name: string;
|
||||
progress: Progress;
|
||||
sort: Sort;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface ListAvatar {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Progress {
|
||||
current: number;
|
||||
max: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Sort {
|
||||
icon: Icon;
|
||||
value: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Icon {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface WeaponModule {
|
||||
custom_title: string;
|
||||
list: WeaponModuleList[];
|
||||
total: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface WeaponModuleList {
|
||||
grade: string;
|
||||
image: FluffyImage;
|
||||
level: number;
|
||||
name: string;
|
||||
props: string[];
|
||||
rarity: Rarity;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface FluffyImage {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Rarity {
|
||||
color: string;
|
||||
medium_url: string;
|
||||
original_format: string;
|
||||
original_url: string;
|
||||
small_url: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface Sharing {
|
||||
description: string;
|
||||
image: null;
|
||||
moment_params: MomentParams;
|
||||
qr_code: string;
|
||||
title: string;
|
||||
url: string;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
||||
export interface MomentParams {
|
||||
app_id: number;
|
||||
group_label_id: number;
|
||||
hashtag_ids: number[];
|
||||
[property: string]: any;
|
||||
}
|
@@ -1,195 +0,0 @@
|
||||
import { createCanvas, loadImage, GlobalFonts } from '@napi-rs/canvas';
|
||||
|
||||
interface MenuCommand {
|
||||
command: string;
|
||||
description: string;
|
||||
highlight?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999帮助菜单图片 (自适应美化版)
|
||||
* @returns 生成的图片的base64编码
|
||||
*/
|
||||
export async function generate1999HelpMenu(): Promise<string> {
|
||||
try {
|
||||
// 字体注册
|
||||
const fontsToTry = [
|
||||
{ path: 'C:\\Windows\\Fonts\\msyh.ttc', name: 'Microsoft YaHei' },
|
||||
{ path: 'C:\\Windows\\Fonts\\msyhbd.ttc', name: 'Microsoft YaHei Bold' },
|
||||
{ path: 'C:\\Windows\\Fonts\\simhei.ttf', name: 'SimHei' }
|
||||
];
|
||||
let fontFamily = 'sans-serif';
|
||||
let fontFamilyBold = 'sans-serif';
|
||||
for (const font of fontsToTry) {
|
||||
try {
|
||||
if (!GlobalFonts.has(font.name)) {
|
||||
GlobalFonts.registerFromPath(font.path, font.name);
|
||||
}
|
||||
if (font.name.includes('Bold')) {
|
||||
fontFamilyBold = font.name;
|
||||
} else if (fontFamily === 'sans-serif') {
|
||||
fontFamily = font.name;
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
if (fontFamilyBold === 'sans-serif') fontFamilyBold = fontFamily;
|
||||
|
||||
// 画布设置
|
||||
const width = 2560;
|
||||
const height = 1440;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// 背景处理
|
||||
const backgroundPath = "E:\\NewDevelop\\NapCatQQ\\src\\canvas\\image\\normal\\01.jpg";
|
||||
try {
|
||||
const backgroundImage = await loadImage(backgroundPath);
|
||||
const scale = Math.max(width / backgroundImage.width, height / backgroundImage.height);
|
||||
const scaledWidth = backgroundImage.width * scale;
|
||||
const scaledHeight = backgroundImage.height * scale;
|
||||
const x = (width - scaledWidth) / 2;
|
||||
const y = (height - scaledHeight) / 2;
|
||||
ctx.drawImage(backgroundImage, x, y, scaledWidth, scaledHeight);
|
||||
ctx.save();
|
||||
ctx.filter = 'blur(20px) brightness(0.75)';
|
||||
ctx.drawImage(backgroundImage, x, y, scaledWidth, scaledHeight);
|
||||
ctx.restore();
|
||||
} catch {
|
||||
const gradient = ctx.createLinearGradient(0, 0, width, height);
|
||||
gradient.addColorStop(0, '#2a2a40');
|
||||
gradient.addColorStop(1, '#4a3a60');
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
}
|
||||
// 半透明叠加层
|
||||
ctx.fillStyle = 'rgba(15, 15, 25, 0.65)';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
// 命令列表
|
||||
const commands: MenuCommand[] = [
|
||||
{ command: '#1999 绑定 <TapTap ID>', description: '将您的 TapTap ID 与机器人绑定', highlight: true },
|
||||
{ command: '#1999 切换 <TapTap ID>', description: '切换当前操作的 TapTap ID' },
|
||||
{ command: '#1999 删除 <TapTap ID>', description: '解除指定的 TapTap ID 绑定' },
|
||||
{ command: '#1999 账号', description: '查看所有已绑定的 TapTap 账号', highlight: true },
|
||||
{ command: '#1999 信息', description: '查询当前选中账号的游戏信息', highlight: true },
|
||||
{ command: '#1999 心相', description: '浏览当前账号拥有的心相详情' },
|
||||
{ command: '#1999 角色', description: '浏览当前账号拥有的角色详情' },
|
||||
{ command: '#1999 帮助', description: '显示此帮助菜单' }
|
||||
];
|
||||
|
||||
// 动态计算卡片宽度
|
||||
ctx.font = `bold 40px ${fontFamilyBold}`;
|
||||
let maxCommandWidth = 0;
|
||||
let maxDescWidth = 0;
|
||||
for (const cmd of commands) {
|
||||
maxCommandWidth = Math.max(maxCommandWidth, ctx.measureText(cmd.command).width);
|
||||
ctx.font = `32px ${fontFamily}`;
|
||||
maxDescWidth = Math.max(maxDescWidth, ctx.measureText(cmd.description).width);
|
||||
ctx.font = `bold 40px ${fontFamilyBold}`;
|
||||
}
|
||||
const baseCardWidth = Math.max(maxCommandWidth, maxDescWidth) + 120;
|
||||
const minCardWidth = 420;
|
||||
const maxCardWidth = Math.min(baseCardWidth, width * 0.38);
|
||||
const cardWidth = Math.max(minCardWidth, Math.min(maxCardWidth, baseCardWidth));
|
||||
|
||||
// 卡片参数
|
||||
const cardHeight = Math.floor(height * 0.07) + 44;
|
||||
const cardBorderRadius = 24;
|
||||
const cardShadow = 'rgba(60, 40, 120, 0.18)';
|
||||
const textPaddingLeft = 38;
|
||||
// 自适应间距,最大不超过指定值
|
||||
const maxColGap = 44;
|
||||
const maxRowGap = 32;
|
||||
const minColGap = 24;
|
||||
const minRowGap = 18;
|
||||
|
||||
// 动态计算列数,保证整体不空旷且不挤
|
||||
let cols = Math.min(commands.length, Math.floor((width - 160) / (cardWidth + minColGap)));
|
||||
cols = Math.max(1, cols);
|
||||
let colGap = Math.floor((width - cols * cardWidth) / (cols + 1));
|
||||
colGap = Math.max(minColGap, Math.min(colGap, maxColGap));
|
||||
const rows = Math.ceil(commands.length / cols);
|
||||
let rowGap = Math.floor((height - rows * cardHeight - 120) / (rows + 1));
|
||||
rowGap = Math.max(minRowGap, Math.min(rowGap, maxRowGap));
|
||||
|
||||
// 计算整体卡片区尺寸,实现居中
|
||||
const cardsAreaWidth = cols * cardWidth + (cols - 1) * colGap;
|
||||
const cardsAreaHeight = rows * cardHeight + (rows - 1) * rowGap;
|
||||
const cardsStartX = Math.floor((width - cardsAreaWidth) / 2);
|
||||
const cardsStartY = Math.floor((height - cardsAreaHeight) / 2);
|
||||
|
||||
// 绘制命令卡片
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
for (let i = 0; i < commands.length; i++) {
|
||||
const cmd = commands[i];
|
||||
if (!cmd) continue;
|
||||
const col = i % cols;
|
||||
const row = Math.floor(i / cols);
|
||||
const x = cardsStartX + col * (cardWidth + colGap);
|
||||
const y = cardsStartY + row * (cardHeight + rowGap);
|
||||
|
||||
// 卡片阴影
|
||||
ctx.save();
|
||||
ctx.shadowColor = cardShadow;
|
||||
ctx.shadowBlur = 16;
|
||||
ctx.shadowOffsetY = 6;
|
||||
|
||||
// 卡片背景
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(x, y, cardWidth, cardHeight, cardBorderRadius);
|
||||
ctx.closePath();
|
||||
if (cmd.highlight) {
|
||||
const cardGradient = ctx.createLinearGradient(x, y, x + cardWidth, y);
|
||||
cardGradient.addColorStop(0, 'rgba(110, 80, 250, 0.60)');
|
||||
cardGradient.addColorStop(1, 'rgba(150, 110, 255, 0.72)');
|
||||
ctx.fillStyle = cardGradient;
|
||||
} else {
|
||||
ctx.fillStyle = 'rgba(45, 45, 65, 0.89)';
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
|
||||
// 左侧高亮条
|
||||
if (cmd.highlight) {
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(x, y, cardWidth, cardHeight, cardBorderRadius);
|
||||
ctx.clip();
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.fillRect(x, y, 12, cardHeight);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// 文本
|
||||
const commandTextX = x + textPaddingLeft;
|
||||
const commandTextY = y + cardHeight * 0.38;
|
||||
const descriptionTextY = y + cardHeight * 0.74;
|
||||
|
||||
ctx.fillStyle = cmd.highlight ? '#f0e8ff' : '#c0d4ff';
|
||||
ctx.font = `bold 40px ${fontFamilyBold}`;
|
||||
ctx.fillText(cmd.command, commandTextX, commandTextY);
|
||||
|
||||
ctx.fillStyle = cmd.highlight ? 'rgba(255,255,255,1)' : 'rgba(225,230,245,0.92)';
|
||||
ctx.font = `32px ${fontFamily}`;
|
||||
ctx.fillText(cmd.description, commandTextX, descriptionTextY);
|
||||
}
|
||||
|
||||
// 底部 NapCat & Plugin
|
||||
const bottomTextY = height - 36;
|
||||
ctx.font = `23px ${fontFamily}`;
|
||||
ctx.fillStyle = 'rgba(255,255,255,0.62)';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'bottom';
|
||||
ctx.fillText('NapCat & Plugin', width / 2, bottomTextY);
|
||||
|
||||
// 转换为base64
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
const base64Image = `base64://${buffer.toString('base64')}`;
|
||||
return base64Image;
|
||||
} catch (error) {
|
||||
console.error('生成菜单时发生错误:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import { GameUserDetail } from './api';
|
||||
|
||||
/**
|
||||
* 获取用户游戏记录信息
|
||||
* @param tap_id TapTap用户ID
|
||||
* @returns 用户游戏记录信息
|
||||
*/
|
||||
|
||||
export async function get_user(tap_id: string): Promise<GameUserDetail> {
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
'app_id': '221062',
|
||||
'user_id': tap_id,
|
||||
'X-UA': 'V=1&PN=WebApp&LANG=zh_CN&VN_CODE=102&VN=0.1.0&LOC=CN&PLT=Android&DS=Android&UID=00e000ee-00e0-0e0e-ee00-f0c95d8ca115&VID=444444444&OS=Android&OSV=14.0.1'
|
||||
});
|
||||
|
||||
const url = `https://www.taptap.cn/webapiv2/game-record/v1/detail-by-user?${params.toString()}`;
|
||||
return await RequestUtil.HttpGetJson(url, 'GET');
|
||||
} catch (error) {
|
||||
console.error('获取用户游戏记录失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -1,219 +1,11 @@
|
||||
import { NapCatOneBot11Adapter, OB11Message, OB11MessageDataType } from '@/onebot';
|
||||
import { NapCatOneBot11Adapter, OB11Message } from '@/onebot';
|
||||
import { NapCatCore } from '@/core';
|
||||
import { ActionMap } from '@/onebot/action';
|
||||
import { OB11PluginAdapter } from '@/onebot/network/plugin';
|
||||
import { TapAccountManager } from './TapAccountManager';
|
||||
import { sendMessage } from './sendMessage';
|
||||
import { get_user } from './get_user';
|
||||
import { generate1999HelpMenu } from './canvas';
|
||||
import { generate1999AccountListImage, generate1999BindImage, generate1999CharacterImage, generate1999InfoImage, generate1999SwitchImage, generate1999WeaponImage } from './new';
|
||||
|
||||
const tapAccountManager = new TapAccountManager();
|
||||
|
||||
export const plugin_onmessage = async (
|
||||
_adapter: string,
|
||||
_core: NapCatCore,
|
||||
_obCtx: NapCatOneBot11Adapter,
|
||||
message: OB11Message,
|
||||
action: ActionMap,
|
||||
_instance: OB11PluginAdapter
|
||||
) => {
|
||||
if (message.raw_message.startsWith('#1999 绑定')) {
|
||||
const tap_id = message.raw_message.slice(8).trim();
|
||||
const userId = message.user_id.toString();
|
||||
|
||||
if (tap_id.length === 0) {
|
||||
await sendMessage(message, action, '请输入正确的 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 验证账号有效性并获取角色名称
|
||||
const userInfo = await get_user(tap_id);
|
||||
const characterName = userInfo.data.list[0]?.basic_module?.name;
|
||||
if (!characterName) {
|
||||
await sendMessage(message, action, '获取角色名称失败,请检查账号是否有效');
|
||||
return;
|
||||
}
|
||||
// 使用账号管理器绑定账号
|
||||
tapAccountManager.bindAccount(userId, tap_id, characterName);
|
||||
await sendMessage(message, action, [{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999BindImage(tap_id, characterName),
|
||||
summary: '绑定成功'
|
||||
}
|
||||
}]);
|
||||
} catch (error) {
|
||||
await sendMessage(message, action, `绑定失败,可能是TapTap ID无效或未关联游戏账号`);
|
||||
console.error(`绑定TapTap ID失败:`, error);
|
||||
}
|
||||
export const plugin_onmessage = async (adapter: string, _core: NapCatCore, _obCtx: NapCatOneBot11Adapter, message: OB11Message, action: ActionMap, instance: OB11PluginAdapter) => {
|
||||
if (message.raw_message === 'ping') {
|
||||
const ret = await action.get('send_group_msg')?.handle({ group_id: String(message.group_id), message: 'pong' }, adapter, instance.config);
|
||||
console.log(ret);
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 切换')) {
|
||||
const tap_id = message.raw_message.slice(8).trim();
|
||||
const userId = message.user_id.toString();
|
||||
|
||||
if (tap_id.length === 0) {
|
||||
await sendMessage(message, action, '请输入要切换的 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用账号管理器切换账号
|
||||
const result = tapAccountManager.switchAccount(userId, tap_id);
|
||||
if (!result) {
|
||||
const accountList = tapAccountManager.getAccountList(userId);
|
||||
if (!accountList.hasAccounts) {
|
||||
await sendMessage(message, action, '您尚未绑定任何账号,请先使用"#1999 绑定"命令');
|
||||
} else {
|
||||
await sendMessage(message, action, `未找到ID为 ${tap_id} 的绑定记录,请先绑定该账号`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const accountInfo = tapAccountManager.getAccountList(userId);
|
||||
const account = accountInfo.accounts?.find(a => a.id === tap_id);
|
||||
await sendMessage(message, action, [{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999SwitchImage(tap_id, account?.name ?? ''),
|
||||
summary: '切换成功'
|
||||
}
|
||||
}]);
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 删除')) {
|
||||
const tap_id = message.raw_message.slice(8).trim();
|
||||
const userId = message.user_id.toString();
|
||||
|
||||
if (tap_id.length === 0) {
|
||||
await sendMessage(message, action, '请输入要删除的 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用账号管理器删除账号
|
||||
const result = await tapAccountManager.deleteAccount(userId, tap_id);
|
||||
|
||||
if (!result.success) {
|
||||
if (result.isEmpty) {
|
||||
await sendMessage(message, action, '您尚未绑定任何账号');
|
||||
} else {
|
||||
await sendMessage(message, action, `未找到ID为 ${tap_id} 的绑定记录`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.isEmpty) {
|
||||
await sendMessage(message, action, `已删除账号 ${tap_id}(${result.deletedAccount?.name}),您当前没有绑定任何账号`);
|
||||
} else {
|
||||
await sendMessage(message, action, `已删除账号 ${tap_id}(${result.deletedAccount?.name}),当前默认账号为 ${result.defaultAccount?.id}(${result.defaultAccount?.name})`);
|
||||
}
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 账号')) {
|
||||
const userId = message.user_id.toString();
|
||||
const accountList = tapAccountManager.getAccountList(userId);
|
||||
|
||||
if (!accountList.hasAccounts) {
|
||||
await sendMessage(message, action, '您尚未绑定任何账号');
|
||||
return;
|
||||
}
|
||||
|
||||
await sendMessage(message, action, [{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999AccountListImage(accountList.accounts!),
|
||||
summary: '账号列表'
|
||||
}
|
||||
}]);
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 信息')) {
|
||||
const userId = message.user_id.toString();
|
||||
const defaultAccount = tapAccountManager.getDefaultAccount(userId);
|
||||
|
||||
if (!defaultAccount.hasDefault) {
|
||||
await sendMessage(message, action, '请先绑定 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
const tap_id = defaultAccount.tapId!;
|
||||
|
||||
try {
|
||||
const userInfo = await get_user(tap_id);
|
||||
const user_1999_name = userInfo.data.list[0]?.basic_module?.name;
|
||||
if (!user_1999_name) {
|
||||
await sendMessage(message, action, '获取账号信息失败,请检查账号是否有效');
|
||||
return;
|
||||
}
|
||||
await sendMessage(message, action, [{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999InfoImage(userInfo),
|
||||
summary: '账号信息'
|
||||
}
|
||||
}]);
|
||||
} catch (error) {
|
||||
await sendMessage(message, action, '获取账号信息失败,请检查账号是否有效');
|
||||
console.error('获取用户信息失败:', error);
|
||||
}
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 心相')) {
|
||||
const userId = message.user_id.toString();
|
||||
const defaultAccount = tapAccountManager.getDefaultAccount(userId);
|
||||
|
||||
if (!defaultAccount.hasDefault) {
|
||||
await sendMessage(message, action, '请先绑定 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
const tap_id = defaultAccount.tapId!;
|
||||
try {
|
||||
const userInfo = await get_user(tap_id);
|
||||
await sendMessage(message, action, [
|
||||
{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999WeaponImage(userInfo),
|
||||
summary: '心相信息'
|
||||
}
|
||||
}
|
||||
]);
|
||||
} catch (error) {
|
||||
await sendMessage(message, action, '获取心相信息失败,请检查账号是否有效');
|
||||
console.error('获取心相信息失败:', error);
|
||||
}
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 角色')) {
|
||||
const userId = message.user_id.toString();
|
||||
const defaultAccount = tapAccountManager.getDefaultAccount(userId);
|
||||
|
||||
if (!defaultAccount.hasDefault) {
|
||||
await sendMessage(message, action, '请先绑定 TapTap ID');
|
||||
return;
|
||||
}
|
||||
|
||||
const tap_id = defaultAccount.tapId!;
|
||||
try {
|
||||
const userInfo = await get_user(tap_id);
|
||||
const user_1999_name = userInfo.data.list[0]?.basic_module?.name;
|
||||
if (!user_1999_name) {
|
||||
await sendMessage(message, action, '获取角色信息失败,请检查账号是否有效');
|
||||
return;
|
||||
}
|
||||
await sendMessage(message, action, [
|
||||
{
|
||||
type: OB11MessageDataType.image,
|
||||
data: {
|
||||
file: await generate1999CharacterImage(userInfo),
|
||||
summary: '角色信息'
|
||||
}
|
||||
}
|
||||
]);
|
||||
} catch (error) {
|
||||
await sendMessage(message, action, '获取角色信息失败,请检查账号是否有效');
|
||||
console.error('获取角色信息失败:', error);
|
||||
}
|
||||
}
|
||||
else if (message.raw_message.startsWith('#1999 帮助') || message.raw_message.startsWith('#1999 菜单')) {
|
||||
await sendMessage(message, action, [
|
||||
{ type: OB11MessageDataType.image, data: { file: await generate1999HelpMenu() } }
|
||||
]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@@ -1,387 +0,0 @@
|
||||
import { createCanvas, loadImage, GlobalFonts } from '@napi-rs/canvas';
|
||||
import { GameUserDetail } from './api';
|
||||
|
||||
// 字体注册工具
|
||||
function getFontFamily() {
|
||||
const fontsToTry = [
|
||||
{ path: 'C:\\Windows\\Fonts\\msyh.ttc', name: 'Microsoft YaHei' },
|
||||
{ path: 'C:\\Windows\\Fonts\\msyhbd.ttc', name: 'Microsoft YaHei Bold' },
|
||||
{ path: 'C:\\Windows\\Fonts\\simhei.ttf', name: 'SimHei' }
|
||||
];
|
||||
let fontFamily = 'sans-serif';
|
||||
let fontFamilyBold = 'sans-serif';
|
||||
for (const font of fontsToTry) {
|
||||
try {
|
||||
if (!GlobalFonts.has(font.name)) {
|
||||
GlobalFonts.registerFromPath(font.path, font.name);
|
||||
}
|
||||
if (font.name.includes('Bold')) {
|
||||
fontFamilyBold = font.name;
|
||||
} else if (fontFamily === 'sans-serif') {
|
||||
fontFamily = font.name;
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
if (fontFamilyBold === 'sans-serif') fontFamilyBold = fontFamily;
|
||||
return { fontFamily, fontFamilyBold };
|
||||
}
|
||||
|
||||
// 背景绘制工具
|
||||
async function drawBackground(ctx: any, width: number, height: number) {
|
||||
const backgroundPath = "E:\\NewDevelop\\NapCatQQ\\src\\canvas\\image\\normal\\01.jpg";
|
||||
try {
|
||||
const backgroundImage = await loadImage(backgroundPath);
|
||||
const scale = Math.max(width / backgroundImage.width, height / backgroundImage.height);
|
||||
const scaledWidth = backgroundImage.width * scale;
|
||||
const scaledHeight = backgroundImage.height * scale;
|
||||
const x = (width - scaledWidth) / 2;
|
||||
const y = (height - scaledHeight) / 2;
|
||||
ctx.drawImage(backgroundImage, x, y, scaledWidth, scaledHeight);
|
||||
ctx.save();
|
||||
ctx.filter = 'blur(20px) brightness(0.75)';
|
||||
ctx.drawImage(backgroundImage, x, y, scaledWidth, scaledHeight);
|
||||
ctx.restore();
|
||||
} catch {
|
||||
const gradient = ctx.createLinearGradient(0, 0, width, height);
|
||||
gradient.addColorStop(0, '#2a2a40');
|
||||
gradient.addColorStop(1, '#4a3a60');
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
}
|
||||
ctx.fillStyle = 'rgba(15, 15, 25, 0.65)';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
}
|
||||
|
||||
// 标题美化工具
|
||||
function drawTitle(ctx: any, text: string, width: number, y: number, fontFamilyBold: string) {
|
||||
// 小标题条
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 0.32;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.fillRect(width / 2 - 220, y - 38, 440, 54);
|
||||
ctx.restore();
|
||||
// 标题
|
||||
ctx.font = `bold 44px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#f0e8ff';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText(text, width / 2, y);
|
||||
// 下划线
|
||||
ctx.save();
|
||||
ctx.strokeStyle = '#c5a8ff';
|
||||
ctx.lineWidth = 3;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(width / 2 - 80, y + 18);
|
||||
ctx.lineTo(width / 2 + 80, y + 18);
|
||||
ctx.stroke();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// 信息行绘制
|
||||
function drawInfoLine(ctx: any, text: string, x: number, y: number, font: string, color: string | CanvasGradient | CanvasPattern) {
|
||||
ctx.font = font;
|
||||
// 兼容 CanvasGradient/CanvasPattern 和 string
|
||||
if (typeof color === 'string' || color instanceof CanvasGradient || color instanceof CanvasPattern) {
|
||||
ctx.fillStyle = color;
|
||||
} else {
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
}
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillText(text, x, y);
|
||||
}
|
||||
|
||||
// 卡片小块绘制
|
||||
function drawMiniCard(ctx: any, x: number, y: number, w: number, h: number, radius: number, shadow = true, color?: string, shadowColor?: string) {
|
||||
ctx.save();
|
||||
if (shadow) {
|
||||
ctx.shadowColor = shadowColor ?? 'rgba(60, 40, 120, 0.13)';
|
||||
ctx.shadowBlur = 12;
|
||||
}
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(x, y, w, h, radius);
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = color ?? 'rgba(45, 45, 65, 0.89)';
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// 底部标识
|
||||
function drawFooter(ctx: any, width: number, height: number, fontFamily: string) {
|
||||
ctx.font = `22px ${fontFamily}`;
|
||||
ctx.fillStyle = 'rgba(255,255,255,0.62)';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'bottom';
|
||||
ctx.fillText('NapCat & Plugin', width / 2, height - 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999 信息图片
|
||||
*/
|
||||
export async function generate1999InfoImage(userInfo: any): Promise<string> {
|
||||
const { fontFamily, fontFamilyBold } = getFontFamily();
|
||||
const width = 2560, height = 1440;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
await drawBackground(ctx, width, height);
|
||||
|
||||
// 标题
|
||||
drawTitle(ctx, '账号信息', width, 120, fontFamilyBold);
|
||||
|
||||
// 信息内容
|
||||
const startX = width / 2 - 350, startY = 220, lineH = 62;
|
||||
const infoList = [
|
||||
`昵称: ${userInfo.data.list[0]?.basic_module?.name ?? '-'}`,
|
||||
`角色ID: ${userInfo.data.list[0]?.basic_module?.role_id ?? '-'}`,
|
||||
`角色数量: ${userInfo.data.list[0]?.basic_module?.custom_items[0]?.value ?? '-'}`,
|
||||
`登录天数: ${userInfo.data.list[0]?.basic_module?.custom_items[1]?.value ?? '-'}`,
|
||||
`雨滴数量: ${userInfo.data.list[0]?.basic_module?.custom_items[2]?.value ?? '-'}`,
|
||||
`你何时睁眼看这个世界: ${userInfo.data.list[1]?.episode_module?.custom_items[0]?.value ?? '-'}`,
|
||||
`你在哪一幕: ${userInfo.data.list[1]?.episode_module?.custom_items[1]?.value ?? '-'}`,
|
||||
`人工梦游: ${userInfo.data.list[1]?.episode_module?.custom_items[2]?.value ?? '-'}`,
|
||||
];
|
||||
ctx.font = `bold 36px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
infoList.forEach((txt, i) => {
|
||||
drawInfoLine(ctx, txt, startX, startY + i * lineH, ctx.font, ctx.fillStyle);
|
||||
});
|
||||
|
||||
drawFooter(ctx, width, height, fontFamily);
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
return `base64://${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999 心相图片
|
||||
*/
|
||||
export async function generate1999WeaponImage(userInfo: GameUserDetail): Promise<string> {
|
||||
const { fontFamily, fontFamilyBold } = getFontFamily();
|
||||
const width = 2560, height = 1440;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
await drawBackground(ctx, width, height);
|
||||
|
||||
drawTitle(ctx, '心相', width, 120, fontFamilyBold);
|
||||
|
||||
ctx.font = `bold 34px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
drawInfoLine(ctx, `昵称: ${userInfo.data.list[0]?.basic_module?.name ?? '-'}`, width / 2 - 350, 180, ctx.font, ctx.fillStyle);
|
||||
drawInfoLine(ctx, `角色ID: ${userInfo.data.list[0]?.basic_module?.role_id ?? '-'}`, width / 2 - 350, 230, ctx.font, ctx.fillStyle);
|
||||
|
||||
const weaponList = userInfo.data.list[3]?.weapon_module?.list ?? [];
|
||||
const cardW = 420, cardH = 110, gapX = 38, gapY = 32;
|
||||
const imgSize = 90;
|
||||
const textLeft = 36 + imgSize + 18; // 缩略图+间隔
|
||||
const cols = Math.min(5, Math.floor((width - 2 * gapX) / (cardW + gapX)));
|
||||
const areaW = cols * cardW + (cols - 1) * gapX;
|
||||
const startX = (width - areaW) / 2;
|
||||
let y = 280;
|
||||
ctx.font = `bold 32px ${fontFamilyBold}`;
|
||||
for (let idx = 0; idx < weaponList.length; idx++) {
|
||||
const item = weaponList[idx];
|
||||
const col = idx % cols, row = Math.floor(idx / cols);
|
||||
const x = startX + col * (cardW + gapX);
|
||||
const cy = y + row * (cardH + gapY);
|
||||
drawMiniCard(ctx, x, cy, cardW, cardH, 22);
|
||||
|
||||
if (!item) continue; // 跳过空值
|
||||
// 绘制缩略图
|
||||
if (item.image?.small_url) {
|
||||
try {
|
||||
const img = await loadImage(item.image.small_url);
|
||||
const imgX = x + 18;
|
||||
const imgY = cy + (cardH - imgSize) / 2;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.arc(imgX + imgSize / 2, imgY + imgSize / 2, imgSize / 2, 0, Math.PI * 2);
|
||||
ctx.closePath();
|
||||
ctx.clip();
|
||||
ctx.drawImage(img, imgX, imgY, imgSize, imgSize);
|
||||
ctx.restore();
|
||||
} catch { }
|
||||
}
|
||||
|
||||
ctx.fillStyle = '#f0e8ff';
|
||||
ctx.font = `bold 32px ${fontFamilyBold}`;
|
||||
ctx.fillText(item.name ?? '-', x + textLeft, cy + cardH / 2 - 12);
|
||||
ctx.font = `28px ${fontFamily}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.fillText(`LV.${item.level ?? '-'}`, x + textLeft, cy + cardH / 2 + 32);
|
||||
}
|
||||
|
||||
drawFooter(ctx, width, height, fontFamily);
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
return `base64://${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999 角色图片
|
||||
*/
|
||||
export async function generate1999CharacterImage(userInfo: GameUserDetail): Promise<string> {
|
||||
const { fontFamily, fontFamilyBold } = getFontFamily();
|
||||
const width = 2560, height = 1440;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
await drawBackground(ctx, width, height);
|
||||
|
||||
drawTitle(ctx, '角色', width, 120, fontFamilyBold);
|
||||
|
||||
ctx.font = `bold 34px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
drawInfoLine(ctx, `昵称: ${userInfo.data.list[0]?.basic_module?.name ?? '-'}`, width / 2 - 350, 180, ctx.font, ctx.fillStyle);
|
||||
drawInfoLine(ctx, `角色ID: ${userInfo.data.list[0]?.basic_module?.role_id ?? '-'}`, width / 2 - 350, 230, ctx.font, ctx.fillStyle);
|
||||
|
||||
const charList = userInfo.data.list[2]?.character_module?.list ?? [];
|
||||
const cardW = 420, cardH = 110, gapX = 38, gapY = 32;
|
||||
const imgSize = 90;
|
||||
const textLeft = 36 + imgSize + 18;
|
||||
const cols = Math.min(5, Math.floor((width - 2 * gapX) / (cardW + gapX)));
|
||||
const areaW = cols * cardW + (cols - 1) * gapX;
|
||||
const startX = (width - areaW) / 2;
|
||||
let y = 280;
|
||||
ctx.font = `bold 32px ${fontFamilyBold}`;
|
||||
for (let idx = 0; idx < charList.length; idx++) {
|
||||
const item = charList[idx];
|
||||
const col = idx % cols, row = Math.floor(idx / cols);
|
||||
const x = startX + col * (cardW + gapX);
|
||||
const cy = y + row * (cardH + gapY);
|
||||
drawMiniCard(ctx, x, cy, cardW, cardH, 22);
|
||||
|
||||
// 绘制缩略图
|
||||
if (!item) continue; // 跳过空值
|
||||
if (item.image?.small_url) {
|
||||
try {
|
||||
const img = await loadImage(item.image.small_url);
|
||||
const imgX = x + 18;
|
||||
const imgY = cy + (cardH - imgSize) / 2;
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.arc(imgX + imgSize / 2, imgY + imgSize / 2, imgSize / 2, 0, Math.PI * 2);
|
||||
ctx.closePath();
|
||||
ctx.clip();
|
||||
ctx.drawImage(img, imgX, imgY, imgSize, imgSize);
|
||||
ctx.restore();
|
||||
} catch { }
|
||||
}
|
||||
|
||||
ctx.fillStyle = '#f0e8ff';
|
||||
ctx.font = `bold 32px ${fontFamilyBold}`;
|
||||
ctx.fillText(item.name ?? '-', x + textLeft, cy + cardH / 2 - 12);
|
||||
ctx.font = `28px ${fontFamily}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.fillText(`LV.${item.level ?? '-'}`, x + textLeft, cy + cardH / 2 + 32);
|
||||
}
|
||||
|
||||
drawFooter(ctx, width, height, fontFamily);
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
return `base64://${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999 绑定/切换结果图片
|
||||
*/
|
||||
async function generateSimpleResultImage(title: string, tapId: string, characterName: string): Promise<string> {
|
||||
const { fontFamily, fontFamilyBold } = getFontFamily();
|
||||
const width = 900, height = 340;
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
await drawBackground(ctx, width, height);
|
||||
|
||||
// 标题
|
||||
drawTitle(ctx, title, width, 80, fontFamilyBold);
|
||||
|
||||
// 内容卡片
|
||||
const cardW = 700, cardH = 120, cardX = (width - cardW) / 2, cardY = 120;
|
||||
drawMiniCard(
|
||||
ctx,
|
||||
cardX,
|
||||
cardY,
|
||||
cardW,
|
||||
cardH,
|
||||
20,
|
||||
true,
|
||||
'rgba(197,168,255,0.18)',
|
||||
'rgba(197,168,255,0.13)'
|
||||
);
|
||||
|
||||
// TapTap ID
|
||||
ctx.font = `bold 28px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillText(`TapTap ID:`, cardX + 36, cardY + 48);
|
||||
ctx.font = `bold 28px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#fffbe6';
|
||||
ctx.fillText(tapId, cardX + 180, cardY + 48);
|
||||
|
||||
// 角色名称
|
||||
ctx.font = `bold 28px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#c5a8ff';
|
||||
ctx.fillText(`角色名称:`, cardX + 36, cardY + 88);
|
||||
ctx.font = `bold 28px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#ffe066';
|
||||
ctx.fillText(characterName, cardX + 180, cardY + 88);
|
||||
|
||||
drawFooter(ctx, width, height, fontFamily);
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
return `base64://${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
export async function generate1999BindImage(tapId: string, characterName: string): Promise<string> {
|
||||
return generateSimpleResultImage('绑定成功', tapId, characterName);
|
||||
}
|
||||
|
||||
export async function generate1999SwitchImage(tapId: string, characterName: string): Promise<string> {
|
||||
return generateSimpleResultImage('切换成功', tapId, characterName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成REVERSE.1999 账号列表图片
|
||||
*/
|
||||
export async function generate1999AccountListImage(accountList: { id: string, name: string, isDefault?: boolean }[]): Promise<string> {
|
||||
const { fontFamily, fontFamilyBold } = getFontFamily();
|
||||
const width = 900;
|
||||
const cardW = 700, cardH = 56, gapY = 18;
|
||||
const listH = accountList.length * cardH + (accountList.length - 1) * gapY;
|
||||
const height = Math.max(340, 120 + listH + 60);
|
||||
const canvas = createCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
await drawBackground(ctx, width, height);
|
||||
|
||||
// 标题
|
||||
drawTitle(ctx, '已绑定账号列表', width, 80, fontFamilyBold);
|
||||
|
||||
// 列表区域起始Y,垂直居中
|
||||
const startY = Math.max(140, (height - listH) / 2);
|
||||
|
||||
for (let i = 0; i < accountList.length; i++) {
|
||||
const item = accountList[i];
|
||||
if (!item) continue; // 跳过空值
|
||||
const x = (width - cardW) / 2;
|
||||
const y = startY + i * (cardH + gapY);
|
||||
|
||||
// 卡片颜色
|
||||
const cardColor = item.isDefault ? 'rgba(255, 224, 102, 0.22)' : 'rgba(197, 168, 255, 0.18)';
|
||||
const shadowColor = item.isDefault ? 'rgba(255, 224, 102, 0.18)' : 'rgba(197, 168, 255, 0.13)';
|
||||
drawMiniCard(ctx, x, y, cardW, cardH, 16, true, cardColor, shadowColor);
|
||||
|
||||
// 账号ID(小号,灰色)
|
||||
ctx.font = `22px ${fontFamily}`;
|
||||
ctx.fillStyle = '#b0b0c8';
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillText(`ID: ${item.id}`, x + 28, y + 26);
|
||||
|
||||
// 账号名(大号,主色)
|
||||
ctx.font = `bold 26px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = item.isDefault ? '#ffe066' : '#c5a8ff';
|
||||
ctx.fillText(item.name, x + 28, y + 48);
|
||||
|
||||
// 当前使用标识
|
||||
if (item.isDefault) {
|
||||
ctx.font = `bold 18px ${fontFamilyBold}`;
|
||||
ctx.fillStyle = '#fffbe6';
|
||||
ctx.fillText('(当前使用)', x + 28 + ctx.measureText(item.name).width + 12, y + 48);
|
||||
}
|
||||
}
|
||||
|
||||
drawFooter(ctx, width, height, fontFamily);
|
||||
const buffer = canvas.toBuffer('image/png');
|
||||
return `base64://${buffer.toString('base64')}`;
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
import { OB11Message, OB11MessageData } from '@/onebot';
|
||||
import { ActionMap } from '@/onebot/action';
|
||||
|
||||
/**
|
||||
* 发送消息工具函数
|
||||
*/
|
||||
export async function sendMessage<T extends OB11MessageData[] | string>(
|
||||
message: OB11Message,
|
||||
action: ActionMap,
|
||||
content: T
|
||||
) {
|
||||
if (message.message_type === 'private') {
|
||||
await action.get('send_msg')?._handle({
|
||||
user_id: message.user_id.toString(),
|
||||
message: content,
|
||||
});
|
||||
} else {
|
||||
await action.get('send_msg')?._handle({
|
||||
group_id: message.group_id?.toString(),
|
||||
message: content,
|
||||
});
|
||||
}
|
||||
};
|
@@ -7,8 +7,7 @@ import { builtinModules } from 'module';
|
||||
const external = [
|
||||
'silk-wasm',
|
||||
'ws',
|
||||
'express',
|
||||
'@napi-rs/canvas'
|
||||
'express'
|
||||
];
|
||||
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
||||
|
||||
|
Reference in New Issue
Block a user