1 Star 1 Fork 0

Aliorpse/Yunzai-PxxnHub

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pxxnhub.js 2.78 KB
一键复制 编辑 原始数据 按行查看 历史
Aliorpse 提交于 2024-02-01 05:09 . 删除多余代码
import plugin from "../../lib/plugins/plugin.js";
import { segment } from "oicq";
import puppeteer from "puppeteer";
export class example extends plugin {
constructor() {
super({
name: "PxxnHub",
dsc: "PxxnHub文本生成",
event: "message",
priority: 5000,
rule: [
{
reg: "#ph",
fnc: "PxxnHub",
},
],
});
}
async PxxnHub(e){
let text1 = ""
let text2 = ""
const ms = e.message[0].text.slice(4)
if(ms.length < 2 || ms.length >50){
e.reply(`用法: #ph [Text]
通过\"+\"标识符来换行,只会识别第一个标识符
如果未给明标识符,会自动截取
最少输入两个字符,最多50字
示例: #ph Pxxn+Hub`,true)
return
}
if(ms.indexOf("+") !== -1){
text1 = ms.substring(0, ms.indexOf("+"))
text2 = ms.replace(text1+"+", "")
}else{
text1 = ms.substring(0, Math.floor(ms.length / 2))
text2 = ms.replace(text1, "")
}
const browser = await puppeteer.launch();
const page = await browser.newPage();
let Html = `
<html>
<head>
<style>
body {
margin: 0;
background-size: cover;
float: left;
background-color: #000
}
h1 {
margin: 0;
background-color: #000;
padding: 20px 6px;
font-family: Microsoft YaHei;
color: #f0f0f0;
float: left;
font-size: 50px;
}
span {
margin: 0;
font-family: Microsoft YaHei;
color: #000;
background-color: #f90;
padding: 10px 5px;
border-radius: 7px;
font-size: 50px;
}
</style>
</head>
<body>
<h1>${text1}<span>${text2}</span></h1>
</body>
</html>
`
await page.setContent(Html)
const body = await page.$('body');
const boundingBox = await body.boundingBox();
let height = Math.ceil(boundingBox.height)
let width = Math.ceil(boundingBox.width)
await page.setViewport({
width: width,
height: height,
deviceScaleFactor: 1,
});
e.reply(segment.image(`base64://${
await page.screenshot({
encoding: 'base64'
})}`),true)
page.close()
return
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Aliorpse/yunzai-pxxn-hub.git
[email protected]:Aliorpse/yunzai-pxxn-hub.git
Aliorpse
yunzai-pxxn-hub
Yunzai-PxxnHub
master

搜索帮助