feat: try add reboot

This commit is contained in:
手瓜一十雪
2024-05-12 17:56:57 +08:00
parent 20b7e9b6b5
commit 69f4383678
4 changed files with 25 additions and 13 deletions

View File

@@ -61,12 +61,12 @@ export abstract class HttpServerBase {
this.listen(port, host); this.listen(port, host);
} catch (e: any) { } catch (e: any) {
logError('HTTP服务启动失败', e.toString()); logError('HTTP服务启动失败', e.toString());
// llonebotError.httpServerError = "HTTP服务启动失败, " + e.toString() // httpServerError = "HTTP服务启动失败, " + e.toString()
} }
} }
stop() { stop() {
// llonebotError.httpServerError = "" // httpServerError = ""
if (this.server) { if (this.server) {
this.server.close(); this.server.close();
this.server = null; this.server = null;

View File

@@ -1,15 +1,28 @@
import { exit } from "process"; import { exit } from "process";
import { resolve } from "path"; import { resolve } from "path";
async function reboot() { import { writeFile, writeFileSync } from "fs";
async function rebootWithQuickLogin(uin: string) {
let batScript = resolve(__dirname, './napcat.bat'); let batScript = resolve(__dirname, './napcat.bat');
let batUtf8Script = resolve(__dirname, './napcat-utf8.bat'); let batUtf8Script = resolve(__dirname, './napcat-utf8.bat');
let bashScript = resolve(__dirname, './napcat.sh'); let bashScript = resolve(__dirname, './napcat.sh');
//如果是win系统写出 5s延迟启动 默认batUtf8Script启动
// 如果是linux系统写出 5s延迟启动 默认bashScript启动
if (process.platform === 'win32') { if (process.platform === 'win32') {
// console.log('正在重启...'); writeFileSync(resolve(__dirname, './reboot-utf8.bat'), `
@echo off
timeout /t 5 /nobreak
start /b /wait %~dp0\\napcat-utf8.bat -q ${uin}
`);
// 启动cmd执行脚本
} else if (process.platform === 'linux') { } else if (process.platform === 'linux') {
//console.log('正在重启...'); writeFileSync(resolve(__dirname, './reboot.sh'), `
#!/bin/bash
timeout 5
./napcat-utf8.sh -q ${uin}
`);
// 启动bash执行脚本
} }
exit(0); exit(0);
} }

View File

@@ -14,7 +14,10 @@ export interface InvalidCheckResult {
} }
export enum ActionName { export enum ActionName {
// llonebot // 以下为扩展napcat扩展
GetRobotUinRange = 'get_robot_uin_range',
SetOnlineStatus = 'set_online_status',
GetFriendsWithCategory = 'get_friends_with_category',
GetGroupIgnoreAddRequest = 'get_group_ignore_add_request', GetGroupIgnoreAddRequest = 'get_group_ignore_add_request',
SetQQAvatar = 'set_qq_avatar', SetQQAvatar = 'set_qq_avatar',
GetConfig = 'get_config', GetConfig = 'get_config',
@@ -54,10 +57,6 @@ export enum ActionName {
GetRecord = 'get_record', GetRecord = 'get_record',
CleanCache = 'clean_cache', CleanCache = 'clean_cache',
GetCookies = 'get_cookies', GetCookies = 'get_cookies',
// 以下为扩展napcat扩展
GetRobotUinRange = 'get_robot_uin_range',
SetOnlineStatus = 'set_online_status',
GetFriendsWithCategory = 'get_friends_with_category',
// 以下为go-cqhttp api // 以下为go-cqhttp api
GoCQHTTP_SendGroupNotice = '_send_group_notice', GoCQHTTP_SendGroupNotice = '_send_group_notice',
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list', GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',

View File

@@ -205,7 +205,7 @@ export class NapCatOnebot11 {
try { try {
notify.time = Date.now(); notify.time = Date.now();
const notifyTime = parseInt(notify.seq) / 1000 / 1000; const notifyTime = parseInt(notify.seq) / 1000 / 1000;
// log(`群通知时间${notifyTime}`, `LLOneBot启动时间${this.bootTime}`); // log(`群通知时间${notifyTime}`, `启动时间${this.bootTime}`);
if (notifyTime < this.bootTime) { if (notifyTime < this.bootTime) {
continue; continue;
} }