mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🎈 pref:优化用户交互
This commit is contained in:
parent
4540a69e1b
commit
c3d6c4c704
@ -1,7 +1,8 @@
|
|||||||
import { REDIS_YUNZAI_WEBUI } from "../constants/constant.js";
|
import { REDIS_YUNZAI_WEBUI } from "../constants/constant.js";
|
||||||
import config from "../model/config.js";
|
import config from "../model/config.js";
|
||||||
import { redisSetKey } from "../utils/redis-util.js";
|
import { redisSetKey } from "../utils/redis-util.js";
|
||||||
import { getBotLoginInfo, getBotStatus, getBotVersionInfo } from "../utils/yunzai-util.js";
|
import { getBotLoginInfo, getBotStatus, getBotVersionInfo, sendPrivateMsg } from "../utils/yunzai-util.js";
|
||||||
|
import os from "os";
|
||||||
|
|
||||||
export class WebUI extends plugin {
|
export class WebUI extends plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -51,6 +52,13 @@ export class WebUI extends plugin {
|
|||||||
await this.initData(e, realIsOpenWebUI);
|
await this.initData(e, realIsOpenWebUI);
|
||||||
// 这里有点延迟,需要写反
|
// 这里有点延迟,需要写反
|
||||||
e.reply(`R插件可视化面板:${ realIsOpenWebUI ? "✅已开启" : "❌已关闭" },重启后生效`);
|
e.reply(`R插件可视化面板:${ realIsOpenWebUI ? "✅已开启" : "❌已关闭" },重启后生效`);
|
||||||
|
if (realIsOpenWebUI) {
|
||||||
|
const networkInterfaces = os.networkInterfaces();
|
||||||
|
const ipAddress = Object.values(networkInterfaces)
|
||||||
|
.flat()
|
||||||
|
.filter(detail => detail.family === 'IPv4' && !detail.internal)[0].address;
|
||||||
|
await sendPrivateMsg(e, `R插件可视化面板地址:${ ipAddress }:4016`);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import os from "os";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将只有 text 类型的数组转换为原生的 {Bot.makeForwardMsg}
|
* 将只有 text 类型的数组转换为原生的 {Bot.makeForwardMsg}
|
||||||
* @param e
|
* @param e
|
||||||
@ -152,3 +154,16 @@ export async function getBotStatus(e) {
|
|||||||
export async function getBotVersionInfo(e) {
|
export async function getBotVersionInfo(e) {
|
||||||
return await e.bot.sendApi("get_version_info");
|
return await e.bot.sendApi("get_version_info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送私聊消息
|
||||||
|
* @param e
|
||||||
|
* @param message
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
export async function sendPrivateMsg(e, message) {
|
||||||
|
e.bot.sendApi("send_private_msg", {
|
||||||
|
user_id: e.user_id,
|
||||||
|
message: message,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user