From 1c965ef51594528ab7b3d335a6338b3a5caf4853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 13 May 2024 09:32:25 +0800 Subject: [PATCH] feat: api Extend RebootNormol --- src/onebot11/action/index.ts | 3 ++- src/onebot11/action/system/Reboot.ts | 18 ++++++++++++++++-- src/onebot11/action/types.ts | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index f747374f..c36a04fe 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -54,9 +54,10 @@ import { GetGroupEssence } from './group/GetGroupEssence'; import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from '@/onebot11/action/msg/ForwardSingleMsg'; import { GetFriendWithCategory } from './extends/GetFriendWithCategory'; import { SendGroupNotice } from './go-cqhttp/SendGroupNotice'; -import Reboot from './system/Reboot'; +import { Reboot, RebootNormol } from './system/Reboot'; export const actionHandlers = [ + new RebootNormol(), new GetFile(), new Debug(), new Reboot(), diff --git a/src/onebot11/action/system/Reboot.ts b/src/onebot11/action/system/Reboot.ts index 77d520d3..728cdc36 100644 --- a/src/onebot11/action/system/Reboot.ts +++ b/src/onebot11/action/system/Reboot.ts @@ -1,4 +1,4 @@ -import { rebootWithQuickLogin } from '@/common/utils/reboot'; +import { rebootWithNormolLogin, rebootWithQuickLogin } from '@/common/utils/reboot'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { selfInfo } from '@/core/data'; @@ -7,7 +7,7 @@ interface Payload { delay: number } -export default class Reboot extends BaseAction { +export class Reboot extends BaseAction { actionName = ActionName.Reboot; protected async _handle(payload: Payload): Promise { @@ -21,3 +21,17 @@ export default class Reboot extends BaseAction { return null; } } +export class RebootNormol extends BaseAction { + actionName = ActionName.Reboot; + + protected async _handle(payload: Payload): Promise { + if (payload.delay) { + setTimeout(() => { + rebootWithNormolLogin(); + }, payload.delay); + } else { + rebootWithNormolLogin(); + } + return null; + } +} diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index c19ff28c..96c94482 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -15,6 +15,7 @@ export interface InvalidCheckResult { export enum ActionName { // 以下为扩展napcat扩展 + RebootNormol = 'reboot_normol',//无快速登录重新启动 GetRobotUinRange = 'get_robot_uin_range', SetOnlineStatus = 'set_online_status', GetFriendsWithCategory = 'get_friends_with_category',