revert change

This commit is contained in:
Kokomi 2023-05-28 15:25:23 +08:00
parent fa1d710372
commit b561ab4b3b
25 changed files with 270 additions and 186 deletions

View File

@ -1,8 +1,11 @@
# 3.1.0 Dev
# 3.1.0
* !!!暂未完成,会有很多错误,不建议升级!!!
* 重构CK与UID管理逻辑
* 底层对星铁查询进行支持
* 支持多UID绑定可绑定多个UID并进行切换
* 支持原神与星铁UID共存可针对查询命令分配对应UID
* 新增`#删除uid1`命令,可对`#uid`列表内的绑定UID进行删除
* 使用sqlite进行ck与uid存储
* 底层对星铁查询进行支持 **@cvs**
# 3.0.2

View File

@ -4,23 +4,27 @@
需要同时安装[miao-plugin](https://github.com/yoimiya-kokomi/miao-plugin.git) 且后续的一些底层改造可能会改变数据结构无法直接迁回原版Yunzai请根据自己需求情况慎重安装
使用[icqq](https://github.com/icqqjs/icqq) 登录防止oicq可能出现的低版本问题
---
与原版Yunzai-Bot的差异
与原Yunzai独立的仓库去除了较为敏感的签到功能以尝试恢复[Github](https://github.com/yoimiya-kokomi/Miao-Yunzai.git)
环境。附加[Gitee](https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git)
**【注意】:** 由于是独立新的仓库,【只建议新部署/部署后迁移】不建议原Bot直接换源强更
* 由于是独立新的仓库,【只建议新部署/部署后迁移】不建议原Bot直接换源强更
* 使用icqq登录防止oicq可能出现的低版本问题如只需要此特性可使用[Yunzai-V3](https://gitee.com/yoimiya-kokomi/Yunzai-Bot) )
* 基础功能会保持与Yunzai同步迭代更新如只需原版Yunzai功能则无需切换
* **一些新特性:** Miao-Yunzai会逐步重构增加新特性与功能可能会有功能与形态上的变化。如期望功能更加稳定可使用此仓库[Yunzai-V3](https://gitee.com/yoimiya-kokomi/Yunzai-Bot)
* **移除了签到功能:** 与原Yunzai独立的仓库去除了较为敏感的签到功能以尝试恢复[Github](https://github.com/yoimiya-kokomi/Miao-Yunzai.git)
环境。附加[Gitee](https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git)
* **默认启用喵版的功能:** 【#角色】【#深渊】【#帮助】等功能默认启用喵版,原版的逻辑会屏蔽,以便于后续逐步精简资源
## Miao-Yunzai后续计划
先刨坑,但也许会咕咕咕
* 功能与`miao-plugin`部分功能进行整合或升级
* 角色卡片、抽卡分析等使用`miao-plugin`版本
* [√] 角色卡片、抽卡分析等使用`miao-plugin`版本
* `miao-plugin`的帮助、设置、版本信息会升至`Miao-Yunzai`,以支持更多场景
* 一些底层会与`miao-plugin`做更深层的联动,以支持一些高级功能
* [√] 星铁底层支持,原神&星铁多UID支持
* 基于面板信息的uid管理及认证
* ck切换感知等
* 逐步实验一些新的特性
@ -77,7 +81,6 @@ pnpm install -P
node app
```
## 常见问题
### puppeteer 相关问题
@ -88,26 +91,33 @@ linux环境其他环境请自行探索
puppeteer Chromium 启动中...
Error: Failed to launch the browser process!
```
1. 先检查node版本是否大于14 (不大于14请去升级版本)
```sh
node -v
```
2. 如果大于14 则可能是缺失一些库 请安装这些 (点击代码块右上角直接复制,如果报错可以尝试 sudo)
### 依赖库
```sh
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y
```
### 字体(实测下来貌似还不够)
### 乱码字体解决办法centos安装不了请换源
```sh
yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y
yum groupinstall fonts -y
```
## 致谢
| Nickname | Contribution |
|:-------------------------------------------------------------:|-------------------|
|:-------------------------------------------------------------:|------------------|
| [Yunzai v3.0](https://gitee.com/le-niao/Yunzai-Bot) | 乐神的Yunzai-Bot V3 |
| [GardenHamster](https://github.com/GardenHamster/GenshinPray) | 模拟抽卡背景素材来源 |
| [西风驿站](https://bbs.mihoyo.com/ys/collection/839181) | 角色攻略图来源 |
| [米游社友人A](https://bbs.mihoyo.com/ys/collection/428421) | 角色突破素材图来源 |
| [icqq](https://github.com/icqqjs/icqq) | ICQQ |

View File

@ -2,5 +2,5 @@
qq:
# 密码,为空则用扫码登录,扫码登录现在仅能在同一ip下进行
pwd:
# 1:安卓手机、 2:aPad 、 3:安卓手表、 4:MacOS 、 5:iPad 、 6:old_Android
platform: 5
# 1:安卓手机、 2:aPad 、 3:安卓手表、 4:MacOS 、 5:iPad 、 6:安卓8.8.88
platform: 6

View File

@ -62,6 +62,10 @@ class Cfg {
return this.getConfig('renderer');
}
get notice() {
return this.getConfig('notice');
}
/** 主人qq */
get masterQQ () {
let masterQQ = this.getConfig('other').masterQQ || []
@ -99,6 +103,13 @@ class Cfg {
return { ...def, ...config }
}
/** notice配置 */
getNotice () {
let def = this.getdefSet('notice')
let config = this.getConfig('notice')
return { ...def, ...config }
}
/**
* @param app 功能
* @param name 配置文件名称

View File

@ -31,7 +31,7 @@ async function UpdateTitle() {
title += ' iPad'
break
case 6:
title += ' old_Android'
title += ' 安卓8.8.88'
break
default:
}
@ -73,9 +73,6 @@ async function checkInit () {
/** 检查qq.yaml */
await createQQ()
//** 更新标题 */
await UpdateTitle()
/** 日志设置 */
setLog()
@ -83,5 +80,8 @@ async function checkInit () {
await redisInit()
checkRun()
await checkRun()
//** 更新标题 */
await UpdateTitle()
}

View File

@ -33,10 +33,10 @@ export default async function createQQ () {
message: '请选择登录端口:',
name: 'platform',
default: '6',
choices: ['old_Android', 'iPad', '安卓手机', '安卓手表', 'MacOS', 'aPad'],
choices: ['安卓8.8.88', 'iPad', '安卓手机', '安卓手表', 'MacOS', 'aPad'],
filter: (val) => {
switch (val) {
case 'old_Android':return 6
case '安卓8.8.88':return 6
case 'iPad':return 5
case 'MacOS':return 4
case '安卓手机':return 1

View File

@ -73,13 +73,18 @@ export default class loginEvent extends EventListener {
type: 'list',
name: 'type',
message: '触发滑动验证需要获取ticket通过验证请选择获取方式:',
choices: ['1.手动获取ticket', '2.滑动验证app请求码获取']
choices: ['0.自动获取ticket', '1.手动获取ticket', '2.滑动验证app请求码获取']
}
])
await common.sleep(200)
let ticket
if (ret.type == '0.自动获取ticket') {
ticket = await this.getTicket(event.url)
if (!ticket) console.log('\n请求错误返回手动获取ticket方式\n')
}
if (ret.type == '2.滑动验证app请求码获取') {
ticket = await this.requestCode(event.url)
if (!ticket) console.log('\n请求错误返回手动获取ticket方式\n')
@ -103,6 +108,27 @@ export default class loginEvent extends EventListener {
this.client.submitSlider(ticket.trim())
}
async getTicket (url) {
let req = `https://hlhs-nb.cn/captcha/slider?key=${Bot.uin}`
await fetch(req, {
method: 'POST',
body: JSON.stringify({ url })
})
console.log('\n----请打开下方链接并在2分钟内进行验证----')
console.log(`${logger.green(req)}\n----完成后将自动进行登录----`)
for (let i = 0; i < 40; i++) {
let res = await fetch(req, {
method: 'POST',
body: JSON.stringify({ submit: Bot.uin })
})
res = await res.json()
if (res.data?.ticket) return res.data.ticket
await common.sleep(3000)
}
}
async requestCode (url) {
let txhelper = {
url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me')

View File

@ -359,7 +359,8 @@ class PluginsLoader {
// 判断是否是星铁命令,若是星铁命令则标准化处理
// e.isSr = true且命令标准化为 #星铁 开头
let srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
if (srReg.test(msg)) {
let gclink = /\/common\//.test(msg)
if (srReg.test(msg) || gclink) {
e.isSr = true
msg = msg.replace(srReg, '#星铁')
}

View File

@ -1,6 +1,6 @@
{
"name": "miao-yunzai",
"version": "3.0.2",
"version": "3.1.0",
"author": "Yoimiya-Kokomi, Le-niao",
"description": "QQ group Bot",
"main": "app.js",
@ -21,7 +21,7 @@
"chalk": "^5.2.0",
"chokidar": "^3.5.3",
"https-proxy-agent": "5.0.1",
"icqq": "0.3.1",
"icqq": "^0.3.14",
"image-size": "^1.0.2",
"inquirer": "^8.2.5",
"lodash": "^4.17.21",
@ -33,14 +33,14 @@
"node-xlsx": "^0.21.2",
"oicq": "^2.3.1",
"pm2": "^5.3.0",
"puppeteer": "^19.11.1",
"puppeteer": "^20.2.1",
"redis": "^4.6.6",
"sequelize": "^6.31.1",
"sqlite3": "^5.1.6",
"yaml": "^2.2.2"
},
"devDependencies": {
"eslint": "^8.40.0",
"eslint": "^8.41.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",

View File

@ -5,7 +5,7 @@ import lodash from 'lodash'
import MysInfo from '../model/mys/mysInfo.js'
export class exchange extends plugin {
constructor (e) {
constructor(e) {
super({
name: '兑换码',
dsc: '前瞻直播兑换码',
@ -24,7 +24,8 @@ export class exchange extends plugin {
})
}
async getCode () {
async getCode() {
this.code_ver = ''
this.now = parseInt(Date.now() / 1000)
let actid = await this.getActId()
if (!actid) return
@ -33,47 +34,57 @@ export class exchange extends plugin {
/** index info */
let index = await this.getData('index')
if (!index || !index.data) return
if(index.data === null){
if (index.data === null) {
return await this.reply(`错误:\n${index.message}`)
}
this.mi18n = index.data.mi18n
let mi18n = await this.getData('mi18n')
if (index.data.remain > 0) {
let version = mi18n['act-title'].match(/\d.\d/g)
return await this.reply(`暂无直播兑换码\n${version}版本前瞻${mi18n['empty-code-text']}`)
let index_data = index.data.live;
let title = index_data['title'];
this.code_ver = index_data['code_ver'];
if (index_data.remain > 0) {
return await this.reply(`暂无直播兑换码\n${title}`)
}
let code = await this.getData('code')
if (!code) return
if (!code || !code.data?.code_list) return
let codes = [];
for (let val of code.data.code_list) {
if (val.code){
//let title = (val.title || '').replace(/\<.*?\>/g,'')
codes.push(val.code)
}
}
code = lodash.map(code, 'code')
let msg = ''
if (code.length >= 3) {
msg = [`${mi18n['act-title']}-直播兑换码`, `${mi18n['exchange-tips']}`, ...code]
if (codes.length >= 3) {
msg = [`${title}-直播兑换码`, `兑换码存在有效期,请及时兑换哦~`, ...codes]
msg = await common.makeForwardMsg(this.e, msg, msg[0])
} else if (this.e.msg.includes('#')) {
msg += code.join('\n')
msg += codes.join('\n')
} else {
msg = `${mi18n['act-title']}-直播兑换码\n`
msg += `${mi18n['exchange-tips']}\n\n`
msg += code.join('\n')
msg = `${title}-直播兑换码\n`
msg += codes.join('\n')
}
await this.reply(msg)
}
async getData (type) {
async getData(type) {
let url = {
index: `https://api-takumi.mihoyo.com/event/bbslive/index?act_id=${this.actId}`,
mi18n: `https://webstatic.mihoyo.com/admin/mi18n/bbs_cn/${this.mi18n}/${this.mi18n}-zh-cn.json`,
code: `https://webstatic.mihoyo.com/bbslive/code/${this.actId}.json?version=1&time=${this.now}`,
index: `https://api-takumi.mihoyo.com/event/miyolive/index`,
code: `https://api-takumi-static.mihoyo.com/event/miyolive/refreshCode?version=${this.code_ver}&time=${this.now}`,
actId: "https://bbs-api.mihoyo.com/painter/api/user_instant/list?offset=0&size=20&uid=75276550",
}
let response
try {
response = await fetch(url[type], { method: 'get' })
response = await fetch(url[type], {
method: 'get',
headers: {
'x-rpc-act_id': this.actId
}
})
} catch (error) {
logger.error(error.toString())
return false
@ -87,18 +98,6 @@ export class exchange extends plugin {
return res
}
// async getActId () {
// let ret = await this.getData('actId')
// if (!ret || ret.retcode !== 0) return false
// let post = lodash.map(ret.data.posts, 'post')
// post = lodash.maxBy(post, 'created_at')
// let actId = post.content.replace(/\[链接\]|\[图片\]/g, '').trim()
// if (!actId) return false
// return actId
// }
async getActId() {
// 获取 "act_id"
let ret = await this.getData('actId')
@ -119,7 +118,7 @@ export class exchange extends plugin {
let shit = JSON.parse(post.structured_content);
for (let segment of shit) {
if (segment.insert.toString().includes('观看直播') && segment.attributes.link) {
let matched = segment.attributes.link.match(/act_id=(\d{8}ys\d{4})/);
let matched = segment.attributes.link.match(/act_id=(.*?)&/);
if (matched) {
actId = matched[1];
}
@ -133,10 +132,10 @@ export class exchange extends plugin {
return actId;
}
async useCode(){
async useCode() {
let cdkCode = this.e.message[0].text.split(/#(兑换码使用|cdk-u) /, 3)[2];
let res = await MysInfo.get(this.e, 'useCdk',{cdk:cdkCode})
if(res){
let res = await MysInfo.get(this.e, 'useCdk', { cdk: cdkCode })
if (res) {
this.e.reply(`${res.data.msg}`)
}
}

View File

@ -60,12 +60,20 @@ export class mysNews extends plugin {
this.file = './plugins/genshin/config/mys.pushNews.yaml'
/** 定时任务 */
this.task = {
this.task = [
{
cron: gsCfg.getConfig('mys', 'pushNews').pushTime,
name: '米游社公告推送任务',
fnc: () => this.mysNewsTask(),
log: false
},
{
cron: gsCfg.getConfig('mys', 'pushNews').pushTime,
name: '崩坏星穹铁道公告推送任务',
fnc: () => this.srmysNewsTask(),
log: false
}
]
}
async init () {
@ -87,7 +95,7 @@ export class mysNews extends plugin {
}
async mysNewsTask () {
let mysNews = new srNews(this.e)
let mysNews = new MysNews(this.e)
await mysNews.mysNewsTask()
}

View File

@ -37,6 +37,10 @@ export class user extends plugin {
reg: '^#?删除(ck|cookie)$',
fnc: 'delCk'
},
{
reg: '^#?(原神|星铁)?(删除|解绑)uid\\s*[0-9]{1,2}$',
fnc: 'delUid'
},
{
reg: '^#(原神|星铁)?绑定(uid|UID)?[1-9][0-9]{8}$',
fnc: 'bingUid'
@ -146,6 +150,15 @@ export class user extends plugin {
}
}
async delUid () {
let index = this.e.msg.match(/[0-9]{1,2}$/g)
let uidIdx = index && index[0]
let game = this.e
if (uidIdx) {
await this.User.delUid(uidIdx, game)
}
}
/** 我的ck */
async myCk () {
if (this.e.isGroup) {

View File

@ -1,3 +1,21 @@
- up4:
- 绮良良
- 云堇
- 重云
up5:
- 宵宫
up5_2:
- 八重神子
weapon5:
- 飞雷之弦振
- 神乐之真意
weapon4:
- 恶王丸
- 笛剑
- 匣里灭辰
- 流浪乐章
- 弓藏
endTime: "2023-06-13 18:00:00"
- up4:
- 卡维
- 坎蒂丝

View File

@ -1,3 +1,12 @@
- from: '2023-05-17 18:00:00'
to: '2023-06-06 14:59:59'
five:
- 景元
four:
- 停云
- 素裳
- 三月七
name: 天戈麾斥
- from: '2023-04-26 08:00:00'
to: '2023-05-17 16:00:00'
five:

View File

@ -1,3 +1,12 @@
- from: '2023-05-17 18:00:00'
to: '2023-06-06 14:59:59'
five:
- 拂晓之前
four:
- 与行星相会
- 唯有沉默
- 余生的第一天
name: 流光定影
- from: '2023-04-26 08:00:00'
to: '2023-05-17 16:00:00'
five:

View File

@ -1,3 +1,13 @@
- from: '2023-05-24 06:00:00'
to: '2023-06-13 17:59:59'
five:
- 宵宫
- 八重神子
four:
- 绮良良
- 云堇
- 重云
name: 焰色天河|华紫樱绯
- from: '2023-05-02 18:00:00'
to: '2023-05-23 14:59:59'
five:

View File

@ -1,3 +1,15 @@
- from: '2023-05-24 06:00:00'
to: '2023-06-13 17:59:59'
five:
- 飞雷之弦振
- 神乐之真意
four:
- 恶王丸
- 笛剑
- 匣里灭辰
- 流浪乐章
- 弓藏
name: 神铸赋形
- from: '2023-05-02 18:00:00'
to: '2023-05-23 14:59:59'
five:

View File

@ -18,7 +18,6 @@ export default class BaseModel extends Model {
static initDB (model, columns) {
let name = model.name
console.log('Model Name', name)
name = name.replace(/DB$/, 's')
model.init(columns, { sequelize, tableName: name })
model.COLUMNS = columns

View File

@ -55,7 +55,7 @@ export default class GachaLog extends base {
if (i <= 1) await common.sleep(500)
}
await this.e.reply(`抽卡记录更新完成,您还可回复\n【#${this?.e?.isSr?'光锥':'武器'}记录】统计${this?.e?.isSr?'光锥':'武器'}池数据\n【#角色统计】按卡池统计数据\n【#导出记录】导出记录数据`)
await this.e.reply(`抽卡记录更新完成,您还可回复\n【#${this?.e?.isSr?'星铁光锥':'武器'}记录】统计${this?.e?.isSr?'星铁光锥':'武器'}池数据\n【#${this?.e?.isSr?'星铁':''}角色统计】按卡池统计数据\n【#导出记录】导出记录数据`)
this.isLogUrl = true
@ -82,7 +82,8 @@ export default class GachaLog extends base {
dealUrl(url) {
// timestamp=1641338980〈=zh-cn 修复链接有奇怪符号
url = url.replace(/〈=/g, '&').split('getGachaLog?')[1]
url = url.replace(/〈=/g, '&')
if (url.includes("getGachaLog?")) url = url.split('getGachaLog?')[1]
// 处理参数
let arr = new URLSearchParams(url).entries()

View File

@ -158,6 +158,7 @@ export default class NoteUser extends BaseModel {
})
let uidReg = /\d{9}/
let regUidCount = 0
// 存在数据库记录则进行设置
if (gameDB) {
@ -166,9 +167,10 @@ export default class NoteUser extends BaseModel {
lodash.forEach(['verify', 'reg'], (uidType) => {
lodash.forEach(regUids, (ds, uid) => {
uid = uid + ''
if (uid && uidReg.test(uid) && ds.type === uidType && !uidMap[key][uid]) {
if (regUidCount <= 5 && uid && uidReg.test(uid) && ds.type === uidType && !uidMap[key][uid]) {
uidMap[key][uid] = { uid, type: ds.type }
uidList[key].push(uid)
regUidCount++
}
})
})
@ -242,21 +244,32 @@ export default class NoteUser extends BaseModel {
// 添加UID
addRegUid (uid, game = 'gs') {
async addRegUid (uid, game = 'gs') {
let gameKey = this.gameKey(game)
uid = uid + ''
if (!this.uidMap[gameKey][uid]) {
this.uidMap[gameKey][uid] = { uid, type: 'reg' }
}
await this.save()
this.setMainUid(uid, game)
// todo 优化保存
await this.save()
}
// 删除UID
delRegUid (uid, game = 'gs') {
async delRegUid (uid, game = 'gs') {
let gameKey = this.gameKey(game)
if (this.uidMap[gameKey][uid] && this.uidMap[gameKey][uid].type !== 'ck') {
lodash.remove(this.uidList[gameKey], (u) => u + '' === uid + '')
delete this.uidMap[gameKey][uid]
lodash.remove(this.uidList[gameKey], (u) => u === uid)
if (this.mainUid[gameKey] === uid) {
this.mainUid[gameKey] = ''
}
}
await this.save()
if (this.mainUid[gameKey] === '') {
this.setMainUid(this.uidList[gameKey][0], game)
await this.save()
}
}
@ -277,7 +290,7 @@ export default class NoteUser extends BaseModel {
* @param force 若已存在绑定uid关系是否强制更新
*/
async setRegUid (uid = '', game = 'gs', force = false) {
if (this.getRegUid(game) && false) {
if (this.getRegUid(game) && !force) {
return uid
}
await this.addRegUid(uid, game)

View File

@ -118,7 +118,7 @@ export default class MysInfo {
if (!matchMsgUid) uid = user.getUid(e)
if (uid) {
/** 没有绑定的自动绑定 */
return await user.setRegUid(uid, false)
return await user.setRegUid(uid, e, false)
}
if (e.noTips !== true) e.reply('请先#绑定uid', false, { at })

View File

@ -48,7 +48,6 @@ export default class Note extends base {
let { data } = res
let nowDay = moment().date()
let nowUnix = Number(moment().format('X'))
/** 树脂 */
let resinMaxTime
if (data.stamina_recover_time > 0) {

View File

@ -44,86 +44,13 @@ export default class MysNews extends base {
const param = await this.newsDetail(postId)
const img = await this.rander(param)
const img = await this.render(param)
return await this.replyMsg(img, `崩坏星穹铁道${typeName}${param.data.post.subject}`)
}
async rander (param) {
const pageHeight = 7000
await puppeteer.browserInit()
if (!puppeteer.browser) return false
const savePath = puppeteer.dealTpl('mysNews', param)
if (!savePath) return false
const page = await puppeteer.browser.newPage()
try {
await page.goto(`file://${_path}${lodash.trim(savePath, '.')}`, { timeout: 120000 })
const body = await page.$('#container') || await page.$('body')
const boundingBox = await body.boundingBox()
const num = Math.round(boundingBox.height / pageHeight) || 1
if (num > 1) {
await page.setViewport({
width: boundingBox.width,
height: pageHeight + 100
})
}
const img = []
for (let i = 1; i <= num; i++) {
const randData = {
type: 'jpeg',
quality: 90
}
if (i != 1 && i == num) {
await page.setViewport({
width: boundingBox.width,
height: parseInt(boundingBox.height) - pageHeight * (num - 1)
})
}
if (i != 1 && i <= num) {
await page.evaluate(() => window.scrollBy(0, 7000))
}
let buff
if (num == 1) {
buff = await body.screenshot(randData)
} else {
buff = await page.screenshot(randData)
}
if (num > 2) await common.sleep(200)
puppeteer.renderNum++
/** 计算图片大小 */
const kb = (buff.length / 1024).toFixed(2) + 'kb'
logger.mark(`[图片生成][${this.model}][${puppeteer.renderNum}次] ${kb}`)
img.push(segment.image(buff))
}
await page.close().catch((err) => logger.error(err))
if (num > 1) {
logger.mark(`[图片生成][${this.model}] 处理完成`)
}
return img
} catch (error) {
logger.error(`图片生成失败:${this.model}:${error}`)
/** 关闭浏览器 */
if (puppeteer.browser) {
await puppeteer.browser.close().catch((err) => logger.error(err))
}
puppeteer.browser = false
}
async render (param) {
return await puppeteer.screenshots(this.model, param)
}
async newsDetail (postId) {
@ -324,7 +251,7 @@ export default class MysNews extends base {
logger.mark(`[崩坏星穹铁道${typeName}推送] ${param.data.post.subject}`)
this[postId] = {
img: await this.rander(param),
img: await this.render(param),
title: param.data.post.subject
}
}

View File

@ -6,7 +6,6 @@ import common from '../../../lib/common/common.js'
import MysInfo from './mys/mysInfo.js'
import NoteUser from './mys/NoteUser.js'
import MysUser from './mys/MysUser.js'
import MysUtil from './mys/MysUtil.js'
import { promisify } from 'node:util'
import YAML from 'yaml'
import { Data } from '#miao'
@ -156,8 +155,23 @@ export default class User extends base {
if (!uid) return
uid = uid[0]
let user = await this.user()
user.addRegUid(uid, this.e)
await user.save()
await user.addRegUid(uid, this.e)
return await this.showUid()
}
async delUid (index) {
let user = await this.user()
let game = this.e
let uidList = user.getUidList(game)
if (index > uidList.length) {
return await this.e.reply('uid序号输入错误')
}
index = Number(index) - 1
let uidObj = uidList[index]
if (uidObj.type === 'ck') {
return await this.e.reply('CK对应UID无法直接删除请通过【#删除ck】命令来删除')
}
await user.delRegUid(uidObj.uid, game)
return await this.showUid()
}
@ -165,27 +179,25 @@ export default class User extends base {
async showUid () {
let user = await this.user()
let msg = []
lodash.forEach({ gs: '原神', sr: '星穹铁道' }, (gameName, game) => {
let typeMap = { ck: 'CK Uid', reg: '绑定 Uid' }
lodash.forEach({ gs: '原神 (#uid)', sr: '星穹铁道 (*uid)' }, (gameName, game) => {
let uidList = user.getUidList(game)
let currUid = user.getUid(game)
msg.push(`${gameName}`)
if (uidList.length === 0) {
msg.push(`暂无,通过${game === 'gs' ? '#' : '*'}绑定123456789来绑定UID`)
return true
}
msg.push(`${gameName}`)
lodash.forEach(uidList, (ds, idx) => {
let tmp = `${++idx}: ${ds.uid} (${ds.type})`
let tmp = `${++idx}: ${ds.uid} (${typeMap[ds.type]})`
if (currUid * 1 === ds.uid * 1) {
tmp += ' ☑'
}
msg.push(tmp)
})
})
if (msg.length > 0) {
msg.unshift('通过【#uid+序号】来切换uid')
msg.unshift('通过【#uid+序号】来切换uid【#删除uid+序号】删除uid')
await this.e.reply(msg.join('\n'))
} else {
await this.e.reply('尚未绑定UID发送CK或通过【#绑定123456789】命令来绑定UID')
}
}
/** 切换uid */
@ -255,10 +267,14 @@ export default class User extends base {
/** 加载V3ck */
async loadOldDataV3 (data) {
let dir = './data/MysCookie/'
Data.createDir('./data/MysCookieBak')
Data.createDir('./temp/MysCookieBak')
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
const readFile = promisify(fs.readFile)
let promises = []
if (files.length === 0) {
fs.rmdirSync('./data/MysCookie/')
return
}
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
const res = await Promise.all(promises)
let ret = {}
@ -321,7 +337,7 @@ export default class User extends base {
}
await user.save()
if (fs.existsSync(`./data/MysCookie/${qq}.yaml`)) {
fs.rename(`./data/MysCookie/${qq}.yaml`, `./data/MysCookieBak/${qq}.yaml`, (err) => {
fs.rename(`./data/MysCookie/${qq}.yaml`, `./temp/MysCookieBak/${qq}.yaml`, (err) => {
if (err) console.log(err)
})
}

View File

@ -104,7 +104,7 @@ export class update extends plugin {
let type = '更新'
if (this.e.msg.includes('强制')) {
type = '强制更新'
cm = `git reset --hard origin/master && ${cm}`
cm = `git fetch --all && git reset --hard && ${cm}`
}
if (plugin) {