Merge branch 'type-enhancement' of https://github.com/NapNeko/NapCatQQ into type-enhancement

This commit is contained in:
pohgxz 2026-01-27 16:18:26 +08:00
commit 7a44ee02dc
7 changed files with 24 additions and 12 deletions

View File

@ -38,7 +38,7 @@ jobs:
- name: Build napcat-schema - name: Build napcat-schema
run: | run: |
cd packages/napcat-schema cd packages/napcat-schema
pnpm run build:schema pnpm run build:openapi
- name: Checkout NapCatDocs - name: Checkout NapCatDocs
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@ -114,8 +114,9 @@ export class NTQQOnlineApi {
fileElement: { fileElement: {
fileName: actualFolderName, fileName: actualFolderName,
filePath: folderPath, filePath: folderPath,
fileSize: "",
}, },
} as any; };
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
const startTime = Math.floor(Date.now() / 1000) - 2; const startTime = Math.floor(Date.now() / 1000) - 2;
@ -173,7 +174,7 @@ export class NTQQOnlineApi {
* 线 * 线
* @param peer * @param peer
*/ */
async getOnlineFileMsg (peer: Peer) : Promise<any> { async getOnlineFileMsg (peer: Peer): Promise<any> {
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
return await msgService.getOnlineFileMsgs(peer); return await msgService.getOnlineFileMsgs(peer);
} }
@ -183,7 +184,7 @@ export class NTQQOnlineApi {
* @param peer * @param peer
* @param msgId * @param msgId
*/ */
async cancelMyOnlineFileMsg (peer: Peer, msgId: string) : Promise<void> { async cancelMyOnlineFileMsg (peer: Peer, msgId: string): Promise<void> {
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
await msgService.cancelSendMsg(peer, msgId); await msgService.cancelSendMsg(peer, msgId);
} }
@ -194,7 +195,7 @@ export class NTQQOnlineApi {
* @param msgId * @param msgId
* @param elementId * @param elementId
*/ */
async refuseOnlineFileMsg (peer: Peer, msgId: string, elementId: string) : Promise<void> { async refuseOnlineFileMsg (peer: Peer, msgId: string, elementId: string): Promise<void> {
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
const arrToSend = { const arrToSend = {
msgId, msgId,
@ -215,7 +216,7 @@ export class NTQQOnlineApi {
* @param elementId * @param elementId
* @constructor * @constructor
*/ */
async receiveOnlineFileOrFolder (peer: Peer, msgId: string, elementId: string) : Promise<any> { async receiveOnlineFileOrFolder (peer: Peer, msgId: string, elementId: string): Promise<any> {
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
const arrToSend = { const arrToSend = {
msgId, msgId,
@ -233,7 +234,7 @@ export class NTQQOnlineApi {
* @param peer * @param peer
* @param msgId * @param msgId
*/ */
async switchFileToOffline (peer: Peer, msgId: string) : Promise<void> { async switchFileToOffline (peer: Peer, msgId: string): Promise<void> {
const msgService = this.context.session.getMsgService(); const msgService = this.context.session.getMsgService();
await msgService.switchToOfflineSendMsg(peer, msgId); await msgService.switchToOfflineSendMsg(peer, msgId);
} }

View File

@ -19,7 +19,8 @@ type ReturnType = Static<typeof ReturnSchema>;
export class ClickInlineKeyboardButton extends OneBotAction<PayloadType, ReturnType> { export class ClickInlineKeyboardButton extends OneBotAction<PayloadType, ReturnType> {
override actionName = ActionName.ClickInlineKeyboardButton; override actionName = ActionName.ClickInlineKeyboardButton;
override payloadSchema = PayloadSchema; override payloadSchema = PayloadSchema;
override returnSchema = ReturnSchema; override actionSummary = '点击内联键盘按钮'; override returnSchema = ReturnSchema;
override actionSummary = '点击内联键盘按钮';
override actionTags = ['消息扩展']; override actionTags = ['消息扩展'];
override payloadExample = { override payloadExample = {
group_id: '123456', group_id: '123456',

View File

@ -5,6 +5,7 @@ import { resolve, dirname } from 'node:path';
import { TSchema } from '@sinclair/typebox'; import { TSchema } from '@sinclair/typebox';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction'; import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
import { napCatVersion } from 'napcat-common/src/version';
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename); const __dirname = dirname(__filename);
@ -69,7 +70,7 @@ export function generateOpenAPI () {
info: { info: {
title: 'NapCat OneBot 11 HTTP API', title: 'NapCat OneBot 11 HTTP API',
description: 'NapCatOneBot11 HTTP POST 接口文档', description: 'NapCatOneBot11 HTTP POST 接口文档',
version: '1.0.0' version: napCatVersion
}, },
tags: [ tags: [
{ name: '消息接口', description: '发送、删除、获取消息相关接口' }, { name: '消息接口', description: '发送、删除、获取消息相关接口' },

View File

@ -5,11 +5,13 @@
"type": "module", "type": "module",
"main": "index.ts", "main": "index.ts",
"scripts": { "scripts": {
"build:schema": "vite build & node ./dist/schemas.mjs" "build:openapi": "vite build & node ./dist/schemas.mjs"
}, },
"dependencies": { "dependencies": {
"@sinclair/typebox": "^0.34.38", "@sinclair/typebox": "^0.34.38",
"napcat-onebot": "workspace:*" "napcat-onebot": "workspace:*",
"napcat-common": "workspace:*",
"napcat-vite": "workspace:*"
}, },
"devDependencies": { "devDependencies": {
"tsx": "^4.7.1", "tsx": "^4.7.1",

View File

@ -2,7 +2,7 @@ import { defineConfig } from 'vite';
import path, { resolve } from 'path'; import path, { resolve } from 'path';
import { builtinModules } from 'module'; import { builtinModules } from 'module';
import nodeResolve from '@rollup/plugin-node-resolve'; import nodeResolve from '@rollup/plugin-node-resolve';
import napcatVersion from 'napcat-vite/vite-plugin-version';
// 依赖排除 // 依赖排除
const external = [ const external = [
'ws', 'ws',
@ -25,6 +25,7 @@ export default defineConfig({
}, },
plugins: [ plugins: [
nodeResolve(), nodeResolve(),
napcatVersion()
], ],
build: { build: {
target: 'esnext', target: 'esnext',

View File

@ -261,9 +261,15 @@ importers:
'@sinclair/typebox': '@sinclair/typebox':
specifier: ^0.34.38 specifier: ^0.34.38
version: 0.34.41 version: 0.34.41
napcat-common:
specifier: workspace:*
version: link:../napcat-common
napcat-onebot: napcat-onebot:
specifier: workspace:* specifier: workspace:*
version: link:../napcat-onebot version: link:../napcat-onebot
napcat-vite:
specifier: workspace:*
version: link:../napcat-vite
devDependencies: devDependencies:
tsx: tsx:
specifier: ^4.7.1 specifier: ^4.7.1