新增状态随机默认背景图,更新版本1.4.6

This commit is contained in:
yeyang
2024-05-27 18:27:24 +08:00
parent fce14fda08
commit 64fb0327ff
7 changed files with 37 additions and 11 deletions

View File

@@ -1,3 +1,17 @@
# 1.4.6
* 状态新增默认背景图随机,`backdrop`配置设置为false则一直使用默认背景图ⁿᵉʷ
* 默认背景图路径修改为**resources/state/img/bg**目录下请将背景图移至该目录
*`backdropDefault`设置为`random`即随机选择该目录下一张图片
* 新增`#投票设置(超时时间|最低票数|禁言时间)`命令ⁿᵉʷ
* 新增投票配置项**groupAdmin.yaml[minNum,BanTime,veto,voteAdmin]**ⁿᵉʷ
* 优化拉黑拉白保留注释
* 状态pro `插件`信息一栏增加fnc和tack显示
* 删除帮助中的`#今天谁生日`
* 修复部分设备状态FastFetch显示异常
* 修复群数据7天报错
* 修复私聊搜番400报错
* 一点点细节优化
# 1.4.5
* 新增`看/取群头像`功能ⁿᵉʷ
* `椰奶状态`支持回复获取背景原图

View File

@@ -22,14 +22,17 @@ statusTask: true
# 如果出现内存异常的情况可将此配置项开启,如果打开后报错请将监控任务关闭
statusPowerShellStart: false
# 背景图片api
# 背景图片api设置为false则一直使用默认背景
# CF跳板(会损失一点访问时间但后期API地址可以自动更新)
# http://dir.dengfenglai.icu
# 默认地址(直连但是不确定是否会GG)
# https://t.mwm.moe/mp/
backdrop: "http://dir.dengfenglai.icu"
# 当api请求失败时使用的默认背景图请放置在resources/state/img目录下修改为你的文件名
backdropDefault: "default_bg.jpg"
# 当api请求失败时使用的默认背景图请放置在resources/state/img/bg目录下
# random - 随机选择state/img/bg目录里的一张图片
# default_bg.jpg 可直接指定bg目录里一张图片注意请带上后缀名
backdropDefault: "random"
# 关闭node的那个圈圈
closedNodeInfo: true

View File

@@ -9,7 +9,7 @@ export default async function getBotState(e) {
const botList = _getBotList(e)
const dataPromises = botList.map(async(i) => {
const bot = Bot[i]
if (!bot?.uin) return ""
if (!bot?.uin) return false
const { nickname = "未知", status = 11, apk, version } = bot
@@ -44,7 +44,7 @@ export default async function getBotState(e) {
}
})
return Promise.all(dataPromises)
return Promise.all(dataPromises).then(r => r.filter(Boolean))
}
async function getAvatarColor(url) {

View File

@@ -1,6 +1,8 @@
import { Config } from "../../components/index.js"
import requset from "../../lib/request/request.js"
import { createAbortCont } from "./utils.js"
import fs from "fs"
import _ from "lodash"
export default async function getStyle() {
return {
@@ -9,11 +11,9 @@ export default async function getStyle() {
}
export async function getBackground() {
const { backdrop, backdropDefault } = Config.state
if (!backdrop?.startsWith("http")) {
return backdrop
}
let { controller, clearTimeout } = await createAbortCont(5000)
try {
if (!backdrop) throw Error("配置项backdrop为假")
const startTime = Date.now()
const buffer = await requset.get(backdrop, {
@@ -34,9 +34,9 @@ export async function getBackground() {
const buffBase64 = arrayBufferToBase64(buffer)
return `data:image/jpeg;base64,${buffBase64}`
} catch (err) {
logger.warn(`[Yenai-Plugin][状态]背景图请求失败,使用默认背景图 “${backdropDefault}” ,错误原因: ${err.message}`)
const Plugin_Path = "../../../../../plugins/yenai-plugin"
return `${Plugin_Path}/resources/state/img/${backdropDefault}`
const bg = getDefaultBackdrop(backdropDefault)
backdrop && logger.warn(`[Yenai-Plugin][状态]背景图请求失败,使用默认背景图 “${bg}” ,错误原因: ${err.message}`)
return bg
} finally {
clearTimeout()
}
@@ -45,3 +45,12 @@ export async function getBackground() {
function arrayBufferToBase64(arrayBuffer) {
return Buffer.from(arrayBuffer).toString("base64")
}
function getDefaultBackdrop(backdropDefault) {
const Plugin_Path = "../../../../../plugins/yenai-plugin"
const Bg_Path = "./plugins/yenai-plugin/resources/state/img/bg"
if (backdropDefault === "random") {
backdropDefault = _.sample(fs.readdirSync(Bg_Path))
logger.debug(`[Yenai-Plugin][状态]使用随机背景图 “${backdropDefault}`)
}
return `${Plugin_Path}/resources/state/img/bg/${backdropDefault}`
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB