From c2b4dd2afdff3ed391e7b4d38f875d78e09c872a 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: Sun, 12 May 2024 22:19:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Reboot=20Api(=E6=9C=AA=E7=BB=8F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot11/action/index.ts | 2 ++ src/onebot11/action/system/Reboot.ts | 23 +++++++++++++++++++++++ src/onebot11/action/types.ts | 1 + 3 files changed, 26 insertions(+) create mode 100644 src/onebot11/action/system/Reboot.ts diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index b9bedf69..f747374f 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -54,10 +54,12 @@ 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'; export const actionHandlers = [ new GetFile(), new Debug(), + new Reboot(), // new GetConfigAction(), // new SetConfigAction(), // new GetGroupAddRequest(), diff --git a/src/onebot11/action/system/Reboot.ts b/src/onebot11/action/system/Reboot.ts new file mode 100644 index 00000000..77d520d3 --- /dev/null +++ b/src/onebot11/action/system/Reboot.ts @@ -0,0 +1,23 @@ +import { rebootWithQuickLogin } from '@/common/utils/reboot'; +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { selfInfo } from '@/core/data'; + +interface Payload { + delay: number +} + +export default class Reboot extends BaseAction { + actionName = ActionName.Reboot; + + protected async _handle(payload: Payload): Promise { + if (payload.delay) { + setTimeout(() => { + rebootWithQuickLogin(selfInfo.uin); + }, payload.delay); + } else { + rebootWithQuickLogin(selfInfo.uin); + } + return null; + } +} diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index b3d49a85..c19ff28c 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -27,6 +27,7 @@ export enum ActionName { ForwardFriendSingleMsg = 'forward_friend_single_msg', ForwardGroupSingleMsg = 'forward_group_single_msg', // onebot 11 + Reboot = 'set_restart', SendLike = 'send_like', GetLoginInfo = 'get_login_info', GetFriendList = 'get_friend_list',