同步 TRSS-Yunzai 消息按钮

仅同步,无法显示
This commit is contained in:
🌌 2023-12-22 22:56:11 +08:00
parent 2a467c9f89
commit 39791196ed
17 changed files with 245 additions and 128 deletions

View File

@ -29,6 +29,4 @@ export class dailyNote extends plugin {
/** 生成图片 */ /** 生成图片 */
this.renderImg('genshin', `html/player/daily-note-${data.game}`, data) this.renderImg('genshin', `html/player/daily-note-${data.game}`, data)
} }
} }

View File

@ -63,13 +63,14 @@ export class exchange extends plugin {
for (let val of code.data.code_list) { for (let val of code.data.code_list) {
if (val.code) { if (val.code) {
codes.push(val.code) codes.push([val.code, segment.button([
{ text: "兑换", callback: `#兑换码使用${val.code}` },
])])
} }
} }
let msg = [`兑换码过期时间: \n${this.deadline}`, ...codes]
let msg = [`${title}-直播兑换码`, `兑换码过期时间: \n${this.deadline}`, ...codes] msg = await common.makeForwardMsg(this.e, msg, `${title}-直播兑换码`)
msg = await common.makeForwardMsg(this.e, msg, msg[0])
await this.reply(msg) await this.reply(msg)
} }

View File

@ -50,6 +50,17 @@ export class gcLog extends plugin {
}) })
this.androidUrl = 'https://docs.qq.com/doc/DUWpYaXlvSklmVXlX' this.androidUrl = 'https://docs.qq.com/doc/DUWpYaXlvSklmVXlX'
this.prefix = this.e?.isSr ? "*" : "#"
this.button = segment.button([
{ text: "角色记录", callback: `${this.prefix}角色记录` },
{ text: "角色统计", callback: `${this.prefix}角色统计` },
],[
{ text: "武器记录", callback: `${this.prefix}武器记录` },
{ text: "武器统计", callback: `${this.prefix}武器统计` },
],[
{ text: "常驻记录", callback: `${this.prefix}常驻记录` },
{ text: "常驻统计", callback: `${this.prefix}常驻统计` },
])
} }
async init () { async init () {
@ -111,7 +122,7 @@ export class gcLog extends plugin {
if (typeof data != 'object') return if (typeof data != 'object') return
await this.renderImg('genshin', `html/gacha/gacha-log`, data) this.reply([await this.renderImg('genshin', `html/gacha/gacha-log`, data, { retType: "base64" }), this.button])
} }
/** #抽卡记录 */ /** #抽卡记录 */
@ -123,7 +134,7 @@ export class gcLog extends plugin {
if (this.e.isAll) { if (this.e.isAll) {
name = `html/gacha/gacha-all-log` name = `html/gacha/gacha-all-log`
} }
await this.renderImg('genshin', name, data) this.reply([await this.renderImg('genshin', name, data, { retType: "base64" }), this.button])
} }
/** 导出记录 */ /** 导出记录 */
@ -152,7 +163,11 @@ export class gcLog extends plugin {
} }
async help () { async help () {
await this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助.png`)) await this.e.reply([segment.image(`file://${_path}/resources/logHelp/记录帮助.png`), segment.button([
{ text: "电脑", callback: "#电脑帮助" },
{ text: "安卓", callback: "#安卓帮助" },
{ text: "苹果", callback: "#苹果帮助" },
])])
} }
async helpPort () { async helpPort () {
@ -170,6 +185,7 @@ export class gcLog extends plugin {
async logCount () { async logCount () {
let data = await new LogCount(this.e).count() let data = await new LogCount(this.e).count()
if (!data) return if (!data) return
this.renderImg('genshin', `html/gacha/log-count`, data)
this.reply([await this.renderImg('genshin', `html/gacha/log-count`, data, { retType: "base64" }), this.button])
} }
} }

View File

@ -30,6 +30,12 @@ export class ledger extends plugin {
} }
] ]
}) })
this.prefix = this.e?.isSr ? "*星琼" : "#原石"
this.button = segment.button([
{ text: "记录", callback: this.prefix },
{ text: "统计", callback: `${this.prefix}统计` },
])
} }
async init () { async init () {
@ -47,7 +53,7 @@ export class ledger extends plugin {
if (!data) return if (!data) return
/** 生成图片 */ /** 生成图片 */
this.renderImg('genshin', `html/ledger/ledger-${data.game}`, data) this.reply([await this.renderImg('genshin', `html/ledger/ledger-${data.game}`, data, { retType: "base64" }), this.button])
} }
/** 原石任务 */ /** 原石任务 */
@ -61,7 +67,7 @@ export class ledger extends plugin {
if (!data) return if (!data) return
/** 生成图片 */ /** 生成图片 */
this.renderImg('genshin', `html/ledger/ledger-count-${data.game}`, data) this.reply([await this.renderImg('genshin', `html/ledger/ledger-count-${data.game}`, data, { retType: "base64" }), this.button])
} }
async ledgerCountHistory () { async ledgerCountHistory () {
@ -69,6 +75,6 @@ export class ledger extends plugin {
if (!data) return if (!data) return
/** 生成图片 */ /** 生成图片 */
this.renderImg('genshin', `html/ledger/ledger-count-${data.game}`, data) this.reply([await this.renderImg('genshin', `html/ledger/ledger-count-${data.game}`, data, { retType: "base64" }), this.button])
} }
} }

View File

@ -138,10 +138,16 @@ export class payLog extends plugin {
} }
return true return true
} else { } else {
this.reply('请私聊发送米游社链接,可以发送【#充值统计帮助】查看链接教程', false) this.reply(['请私聊发送米游社链接,可以发送【#充值统计帮助】查看链接教程',
segment.button([
{ text: "充值帮助", callback: "#充值统计帮助" },
])])
} }
} else { } else {
this.reply('请私聊发送米游社链接,可以发送【#充值统计帮助】查看链接教程', false) this.reply(['请私聊发送米游社链接,可以发送【#充值统计帮助】查看链接教程',
segment.button([
{ text: "充值帮助", callback: "#充值统计帮助" },
])])
} }
return true return true
} }

View File

@ -29,6 +29,14 @@ export class role extends plugin {
fnc: 'roleExplore' fnc: 'roleExplore'
}] }]
}) })
this.prefix = this.e?.isSr ? "*" : "#"
this.button = segment.button([
{ text: "角色", callback: `${this.prefix}角色` },
{ text: "探索", callback: `${this.prefix}探索` },
{ text: "武器", callback: `${this.prefix}武器` },
{ text: "深渊", callback: `${this.prefix}深渊` },
])
} }
/** 初始化配置文件 */ /** 初始化配置文件 */
@ -69,7 +77,7 @@ export class role extends plugin {
console.log('abyss', data) console.log('abyss', data)
if (!data) return if (!data) return
this.renderImg('genshin', 'html/abyss/abyss', data) this.reply([await this.renderImg('genshin', 'html/abyss/abyss', data, { retType: "base64" }), this.button])
} }
/** 深渊十二层 */ /** 深渊十二层 */
@ -77,7 +85,7 @@ export class role extends plugin {
let data = await new Abyss(this.e).getAbyssFloor() let data = await new Abyss(this.e).getAbyssFloor()
if (!data) return if (!data) return
await this.renderImg('genshin', 'html/abyss/abyss-floor', data) this.reply([await this.renderImg('genshin', 'html/abyss/abyss-floor', data, { retType: "base64" }), this.button])
} }
/** 武器 */ /** 武器 */
@ -85,7 +93,7 @@ export class role extends plugin {
let data = await Weapon.get(this.e) let data = await Weapon.get(this.e)
if (!data) return if (!data) return
await this.renderImg('genshin', 'html/avatar/weapon', data) this.reply([await this.renderImg('genshin', 'html/avatar/weapon', data, { retType: "base64" }), this.button])
} }
/** 角色卡片 */ /** 角色卡片 */
@ -93,7 +101,7 @@ export class role extends plugin {
let data = await new RoleIndex(this.e).roleCard() let data = await new RoleIndex(this.e).roleCard()
if (!data) return if (!data) return
await this.renderImg('genshin', 'html/player/role-card', data) this.reply([await this.renderImg('genshin', 'html/player/role-card', data, { retType: "base64" }), this.button])
} }
/** 探险 */ /** 探险 */
@ -101,6 +109,6 @@ export class role extends plugin {
let data = await new RoleIndex(this.e).roleExplore() let data = await new RoleIndex(this.e).roleExplore()
if (!data) return if (!data) return
this.renderImg('genshin', 'html/player/role-explore', data) this.reply([await this.renderImg('genshin', 'html/player/role-explore', data, { retType: "base64" }), this.button])
} }
} }

View File

@ -20,6 +20,12 @@ export class sevenSaints extends plugin {
} }
] ]
}) })
this.button = segment.button([
{ text: "牌组", callback: `#七圣召唤查询牌组` },
{ text: "角色牌", callback: `#七圣召唤查询角色牌` },
{ text: "行动牌", callback: `#七圣召唤查询行动牌` },
])
} }
async deckIndex() { async deckIndex() {
@ -36,7 +42,7 @@ export class sevenSaints extends plugin {
if (!data) return if (!data) return
let img = await puppeteer.screenshot('deck', data) let img = await puppeteer.screenshot('deck', data)
if (img) await this.reply(img) if (img) await this.reply([img, this.button])
} }
async deck_list(id = 0) { async deck_list(id = 0) {
@ -44,7 +50,7 @@ export class sevenSaints extends plugin {
if (!data) return if (!data) return
let img = await puppeteer.screenshot('deckList', data) let img = await puppeteer.screenshot('deckList', data)
if (img) await this.reply(img) if (img) await this.reply([img, this.button])
} }
async deck_cards(id = 0) { async deck_cards(id = 0) {
if (this.e.msg.includes('角色')) id = 1 if (this.e.msg.includes('角色')) id = 1
@ -54,6 +60,6 @@ export class sevenSaints extends plugin {
if (!data) return if (!data) return
let img = await puppeteer.screenshot('deckCard', data) let img = await puppeteer.screenshot('deckCard', data)
if (img) await this.reply(img) if (img) await this.reply([img, this.button])
} }
} }

View File

@ -13,6 +13,9 @@ gsCfg.cpCfg('mys', 'set')
* 1.增加多个来源的攻略图 * 1.增加多个来源的攻略图
* 2.优化获取攻略图逻辑更改为对比图片大小来寻找 * 2.优化获取攻略图逻辑更改为对比图片大小来寻找
* 3.增加攻略说明设置默认攻略功能 * 3.增加攻略说明设置默认攻略功能
*
* 从拓展插件更新
* 作者曉K 更新🌌
*/ */
export class strategy extends plugin { export class strategy extends plugin {
@ -24,7 +27,7 @@ export class strategy extends plugin {
priority: 50, priority: 50,
rule: [ rule: [
{ {
reg: '^#?(更新)?\\S+攻略([1-4])?$', reg: '^#?(更新)?\\S+攻略([1-7])?$',
fnc: 'strategy' fnc: 'strategy'
}, },
{ {
@ -32,7 +35,7 @@ export class strategy extends plugin {
fnc: 'strategy_help' fnc: 'strategy_help'
}, },
{ {
reg: '^#?设置默认攻略([1-4])?$', reg: '^#?设置默认攻略([1-7])?$',
fnc: 'strategy_setting' fnc: 'strategy_setting'
} }
] ]
@ -52,10 +55,16 @@ export class strategy extends plugin {
// 来源:派蒙喵喵屋 // 来源:派蒙喵喵屋
[341284], [341284],
// 来源OH是姜姜呀(需特殊处理) // 来源OH是姜姜呀(需特殊处理)
[341523] [341523],
// 来源曉K → 废物一个
[1582613],
// 来源:坤易
[22148],
// 来源:婧枫赛赛
[1812949]
] ]
this.source = ['西风驿站', '原神观测枢', '派蒙喵喵屋', 'OH是姜姜呀'] this.source = ['西风驿站', '原神观测枢', '派蒙喵喵屋', 'OH是姜姜呀', '曉K', '坤易', '婧枫赛赛']
this.oss = '?x-oss-process=image//resize,s_1200/quality,q_90/auto-orient,0/interlace,1/format,jpg' this.oss = '?x-oss-process=image//resize,s_1200/quality,q_90/auto-orient,0/interlace,1/format,jpg'
} }
@ -66,7 +75,7 @@ export class strategy extends plugin {
fs.mkdirSync(this.path) fs.mkdirSync(this.path)
} }
/** 初始化子目录 */ /** 初始化子目录 */
for (let subId of [1, 2, 3, 4]) { for (let subId of [1, 2, 3, 4, 5, 6, 7]) {
let path = this.path + '/' + subId let path = this.path + '/' + subId
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
fs.mkdirSync(path) fs.mkdirSync(path)
@ -76,7 +85,7 @@ export class strategy extends plugin {
/** #心海攻略 */ /** #心海攻略 */
async strategy () { async strategy () {
let match = /^#?(更新)?(\S+)攻略([1-4])?$/.exec(this.e.msg) let match = /^#?(更新)?(\S+)攻略([1-7])?$/.exec(this.e.msg)
// let isUpdate = !!this.e.msg.includes('更新') // let isUpdate = !!this.e.msg.includes('更新')
let isUpdate = !!match[1] let isUpdate = !!match[1]
@ -104,33 +113,37 @@ export class strategy extends plugin {
} }
this.sfPath = `${this.path}/${group}/${role.name}.jpg` this.sfPath = `${this.path}/${group}/${role.name}.jpg`
let button = []
for (const i of [1, 2, 3, 4, 5, 6, 7])
button.push({ text: String(i), callback: `#${role.name}攻略${i}` })
button = segment.button(button)
if (fs.existsSync(this.sfPath) && !isUpdate) { if (fs.existsSync(this.sfPath) && !isUpdate) {
await this.e.reply(segment.image(`file://${this.sfPath}`)) await this.e.reply([segment.image(`file://${this.sfPath}`), button])
return return
} }
if (await this.getImg(role.name, group)) { if (await this.getImg(role.name, group)) {
await this.e.reply(segment.image(`file://${this.sfPath}`)) await this.e.reply([segment.image(`file://${this.sfPath}`), button])
} }
} }
/** #攻略帮助 */ /** #攻略帮助 */
async strategy_help () { async strategy_help () {
await this.e.reply('攻略帮助:\n#心海攻略[1234]\n#更新早柚攻略[1234]\n#设置默认攻略[1234]\n示例: 心海攻略4\n\n攻略来源:\n1——西风驿站\n2——原神观测枢\n3——派蒙喵喵屋\n4——OH是姜姜呀') await this.e.reply('攻略帮助:\n#心海攻略[1234567]\n#更新早柚攻略[1234567]\n#设置默认攻略[1234567]\n示例: 心海攻略4\n\n攻略来源:\n1——西风驿站\n2——原神观测枢\n3——派蒙喵喵屋\n4——OH是姜姜呀\n5——曉K\n6——坤易\n7——婧枫赛赛(角色配队一图流)')
} }
/** #设置默认攻略1 */ /** #设置默认攻略1 */
async strategy_setting () { async strategy_setting () {
let match = /^#?设置默认攻略([1-4])?$/.exec(this.e.msg) let match = /^#?设置默认攻略([1-7])?$/.exec(this.e.msg)
let set = './plugins/genshin/config/mys.set.yaml' let set = './plugins/genshin/config/mys.set.yaml'
let config = fs.readFileSync(set, 'utf8') let config = fs.readFileSync(set, 'utf8')
let num = Number(match[1]) let num = Number(match[1])
if(isNaN(num)) { if(isNaN(num)) {
await this.e.reply('默认攻略设置方式为: \n#设置默认攻略[1234] \n 请增加数字1-4其中一个') await this.e.reply('默认攻略设置方式为: \n#设置默认攻略[1234567] \n 请增加数字1-7其中一个')
return return
} }
config = config.replace(/defaultSource: [1-4]/g, 'defaultSource: ' + num) config = config.replace(/defaultSource: [1-7]/g, 'defaultSource: ' + num)
fs.writeFileSync(set, config, 'utf8') fs.writeFileSync(set, config, 'utf8')
await this.e.reply('默认攻略已设置为: ' + match[1]) await this.e.reply('默认攻略已设置为: ' + match[1])

View File

@ -16,6 +16,9 @@ export class takeBirthdayPhoto extends plugin {
} }
] ]
}) })
this.button = segment.button([
{ text: "留影叙佳期", input: "#留影叙佳期" },
])
} }
async birthdaystar(e) { async birthdaystar(e) {
@ -23,24 +26,26 @@ export class takeBirthdayPhoto extends plugin {
const userInfo = await this.getCookie(user_id) const userInfo = await this.getCookie(user_id)
if (!userInfo) { if (!userInfo) {
e.reply('请先绑定ck再使用本功能哦~', true) e.reply(['请先绑定ck再使用本功能哦~', segment.button([
{ text: "Cookie帮助", callback: "#Cookie帮助" },
])], true)
return true return true
} }
const e_hk4e_token = await this.getEHK4EToken(userInfo.ck, userInfo.uid) const e_hk4e_token = await this.getEHK4EToken(userInfo.ck, userInfo.uid)
if (!e_hk4e_token) { if (!e_hk4e_token) {
e.reply('获取e-hk4e_token失败请刷新ck后再试~', true) e.reply(['获取e-hk4e_token失败请刷新ck后再试~', this.button], true)
return true return true
} }
const birthday_star_list = await this.getBirthdayStar(userInfo.uid, e_hk4e_token, userInfo.ck) const birthday_star_list = await this.getBirthdayStar(userInfo.uid, e_hk4e_token, userInfo.ck)
if (!birthday_star_list) { if (!birthday_star_list) {
e.reply('获取生日角色失败,请稍后再试~', true) e.reply(['获取生日角色失败,请稍后再试~', this.button], true)
return true return true
} }
if (birthday_star_list.length === 0) { if (birthday_star_list.length === 0) {
e.reply('今天没有生日角色哦~', true) e.reply(['今天没有生日角色哦~', this.button], true)
return true return true
} }
try { try {
@ -49,14 +54,14 @@ export class takeBirthdayPhoto extends plugin {
await e.reply(segment.image(role.take_picture)) await e.reply(segment.image(role.take_picture))
const message = await this.getBirthdayStarImg(userInfo.uid, e_hk4e_token, userInfo.ck, role.role_id) const message = await this.getBirthdayStarImg(userInfo.uid, e_hk4e_token, userInfo.ck, role.role_id)
if (message != 'success') { if (message != 'success') {
await e.reply(message) await e.reply([message, this.button])
return true return true
} else { } else {
await e.reply(`获取${role.name}的图片成功~`, true) await e.reply(`获取${role.name}的图片成功~`, true)
} }
} }
} catch (error) { } catch (error) {
await e.reply(`获取角色留影叙佳期图片失败可能是ck失效...`, true) await e.reply([`获取角色留影叙佳期图片失败可能是ck失效...`, this.button], true)
logger.error(error) logger.error(error)
} }

View File

@ -12,15 +12,15 @@ export class user extends plugin {
priority: 300, priority: 300,
rule: [ rule: [
{ {
reg: '^#*(体力|ck|cookie)帮助', reg: '^#?(体力|[Cc](oo)?[Kk](ie)?)帮助',
fnc: 'ckHelp' fnc: 'ckHelp'
}, },
{ {
reg: '^(ck|cookie|js)代码$', reg: '^#[Cc](oo)?[Kk](ie)?代码$',
fnc: 'ckCode' fnc: 'ckCode'
}, },
{ {
reg: '^#绑定(cookie|ck)$', reg: '^#绑定[Cc](oo)?[Kk](ie)?$',
fnc: 'bingCk' fnc: 'bingCk'
}, },
{ {
@ -29,12 +29,12 @@ export class user extends plugin {
fnc: 'noLogin' fnc: 'noLogin'
}, },
{ {
reg: '^#?(原神|星铁)?我的(ck|cookie)$', reg: '^#?(原神|星铁)?我的[Cc](oo)?[Kk](ie)?$',
event: 'message', event: 'message',
fnc: 'myCk' fnc: 'myCk'
}, },
{ {
reg: '^#?(原神|星铁)?删除(ck|cookie)$', reg: '^#?(原神|星铁)?删除[Cc](oo)?[Kk](ie)?$',
fnc: 'delCk' fnc: 'delCk'
}, },
{ {
@ -50,7 +50,7 @@ export class user extends plugin {
fnc: 'showUid' fnc: 'showUid'
}, },
{ {
reg: '^#\\s*(检查|我的)*ck(状态)*$', reg: '^#\\s*(检查|我的)*[Cc](oo)?[Kk](ie)?(状态)*$',
fnc: 'checkCkStatus' fnc: 'checkCkStatus'
}, },
{ {
@ -77,11 +77,11 @@ export class user extends plugin {
// 由于手机端米游社网页可能获取不到ltuid 可以尝试在通行证页面获取login_uid // 由于手机端米游社网页可能获取不到ltuid 可以尝试在通行证页面获取login_uid
if (/(ltoken|ltoken_v2)/.test(this.e.msg) && /(ltuid|login_uid|ltmid_v2)/.test(this.e.msg)) { if (/(ltoken|ltoken_v2)/.test(this.e.msg) && /(ltuid|login_uid|ltmid_v2)/.test(this.e.msg)) {
if (this.e.isGroup) { if (this.e.isGroup) {
this.reply('请私聊发送cookie', false, { at: true }) this.reply('请私聊发送Cookie', false, { at: true })
return true return true
} }
this.e.ck = this.e.msg this.e.ck = this.e.msg
this.e.msg = '#绑定cookie' this.e.msg = '#绑定Cookie'
return true return true
} }
@ -107,7 +107,7 @@ export class user extends plugin {
/** 未登录ck */ /** 未登录ck */
async noLogin () { async noLogin () {
this.reply('绑定cookie失败\n请先【登录米游社】或【登录通行证】再获取cookie') this.reply('绑定Cookie失败\n请先【登录米游社】或【登录通行证】再获取Cookie')
} }
/** #ck代码 */ /** #ck代码 */
@ -118,7 +118,7 @@ export class user extends plugin {
/** ck帮助 */ /** ck帮助 */
async ckHelp () { async ckHelp () {
let set = gsCfg.getConfig('mys', 'set') let set = gsCfg.getConfig('mys', 'set')
await this.reply(`Cookie绑定配置教程${set.cookieDoc}\n获取cookie后【私聊发送】进行绑定`) await this.reply(`Cookie绑定配置教程${set.cookieDoc}\n获取Cookie后【私聊发送】进行绑定`)
} }
/** 绑定ck */ /** 绑定ck */
@ -126,7 +126,7 @@ export class user extends plugin {
let set = gsCfg.getConfig('mys', 'set') let set = gsCfg.getConfig('mys', 'set')
if (!this.e.ck) { if (!this.e.ck) {
await this.reply(`请【私聊】发送米游社cookie获取教程\n${set.cookieDoc}`) await this.reply(`请【私聊】发送米游社Cookie获取教程\n${set.cookieDoc}`)
return return
} }

View File

@ -12,54 +12,47 @@ export class user extends plugin {
priority: 300, priority: 300,
rule: [{ rule: [{
reg: '^#用户统计$', reg: '^#用户统计$',
fnc: 'userAdmin' fnc: 'userAdmin',
permission: "master",
}, { }, {
reg: '^#(刷新|重置)用户(缓存|统计|ck|Ck|CK)$', reg: '^#(刷新|重置)用户(缓存|统计|ck|Ck|CK)$',
fnc: 'resetCache' fnc: 'resetCache',
permission: "master",
}, { }, {
reg: '^#删除(无效|失效)(用户|ck|Ck|CK)$', reg: '^#删除(无效|失效)(用户|ck|Ck|CK)$',
fnc: 'delDisable' fnc: 'delDisable',
permission: "master",
}] }]
}) })
this.User = new User(e) this.User = new User(e)
} this.button = segment.button([
{ text: "用户统计", callback: "#用户统计" },
checkAuth () { { text: "删除无效", callback: "#删除无效用户" },
if (!this.e.isMaster) { ],[
this.e.reply('只有管理员可用...') { text: "刷新统计", callback: "#刷新用户统计" },
return false { text: "重置统计", callback: "#重置用户统计" },
} ])
return true
} }
/** #用户统计$ */ /** #用户统计$ */
async userAdmin () { async userAdmin () {
if (!this.checkAuth()) {
return true
}
let data = await new User(this.e).userAdmin() let data = await new User(this.e).userAdmin()
if (!data) return true if (!data) return true
/** 生成图片 */ /** 生成图片 */
this.renderImg('genshin', 'html/admin/userAdmin', data) this.reply([await this.renderImg('genshin', 'html/admin/userAdmin', data, { retType: "base64" }), this.button])
} }
/** #刷新用户缓存 / #重置用户缓存 */ /** #刷新用户缓存 / #重置用户缓存 */
async resetCache () { async resetCache () {
if (!this.checkAuth()) {
return true
}
// 清空老数据 // 清空老数据
const clearData = /重置/.test(this.e.msg) const clearData = /重置/.test(this.e.msg)
await MysInfo.initCache(true, clearData) await MysInfo.initCache(true, clearData)
this.e.reply(`用户缓存已${clearData ? '重置' : '刷新'}...\n通过【#用户统计】命令可查看详情`) this.reply([`用户缓存已${clearData ? '重置' : '刷新'}...\n通过【#用户统计】命令可查看详情`, this.button])
} }
async delDisable () { async delDisable () {
if (!this.checkAuth()) {
return true
}
let count = await MysInfo.delDisable() let count = await MysInfo.delDisable()
this.e.reply(count > 0 ? `已删除${count}个无效用户` : '暂无无效用户...') this.reply([count > 0 ? `已删除${count}个无效用户` : '暂无无效用户...', this.button])
} }
} }

View File

@ -70,7 +70,7 @@ export default class ExportLog extends base {
lang: list[0].lang, lang: list[0].lang,
export_time: moment().format('YYYY-MM-DD HH:mm:ss'), export_time: moment().format('YYYY-MM-DD HH:mm:ss'),
export_timestamp: moment().format('X'), export_timestamp: moment().format('X'),
export_app: 'Miao-Yunzai', export_app: 'TRSS-Yunzai',
export_app_version: cfg.package.version, export_app_version: cfg.package.version,
}, },
list list

View File

@ -310,7 +310,11 @@ export default class Ledger extends base {
} }
// console.log(NoteData) // console.log(NoteData)
if (!NoteData || lodash.isEmpty(NoteData)) { if (!NoteData || lodash.isEmpty(NoteData)) {
this.e.reply(`${this.e?.isSr ? '暂无星琼数据,请先发送 *星琼' : '暂无原石数据,请先发送 #原石'}`, false, { at: true }) this.e.reply(this.e?.isSr ? ['暂无星琼数据,请先发送 *星琼', segment.button([
{ text: "星琼", input: "*星琼" },
])] : ['暂无原石数据,请先发送 #原石', segment.button([
{ text: "原石", input: "#原石" },
])], false, { at: true })
return false return false
} }
NoteData = NoteData[nowYear] NoteData = NoteData[nowYear]

View File

@ -6,7 +6,7 @@ import MysUser from './MysUser.js'
import DailyCache from './DailyCache.js' import DailyCache from './DailyCache.js'
export default class MysInfo { export default class MysInfo {
static tips = '请先#绑定cookie\n发送【体力帮助】查看配置教程' static tips = '请先#绑定Cookie\n发送【Cookie帮助】查看配置教程'
constructor (e) { constructor (e) {
if (e) { if (e) {
@ -28,6 +28,9 @@ export default class MysInfo {
this.auth = ['dailyNote', 'bbs_sign_info', 'bbs_sign_home', 'bbs_sign', 'ys_ledger', 'compute', 'avatarSkill', 'detail', 'blueprint', 'UserGame', 'deckList', 'avatar_cardList', 'action_cardList', 'avatarInfo'] this.auth = ['dailyNote', 'bbs_sign_info', 'bbs_sign_home', 'bbs_sign', 'ys_ledger', 'compute', 'avatarSkill', 'detail', 'blueprint', 'UserGame', 'deckList', 'avatar_cardList', 'action_cardList', 'avatarInfo']
this.gtest = false this.gtest = false
this.mysButton = segment.button([
{ text: "米游社", link: "https://miyoushe.com" },
])
} }
static async init (e, api) { static async init (e, api) {
@ -93,7 +96,9 @@ export default class MysInfo {
let atUser = await NoteUser.create(at) let atUser = await NoteUser.create(at)
uid = atUser.getUid(e) uid = atUser.getUid(e)
if (uid) return String(uid) if (uid) return String(uid)
if (e.noTips !== true) e.reply('尚未绑定uid', false, { at }) if (e.noTips !== true) e.reply(['尚未绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
])], false, { at })
return false return false
} }
@ -111,7 +116,9 @@ export default class MysInfo {
return user.autoRegUid(uid, e) return user.autoRegUid(uid, e)
} }
if (e.noTips !== true) e.reply('请先#绑定uid', false, { at }) if (e.noTips !== true) e.reply(['请先#绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
])], false, { at })
return false return false
} }
@ -129,7 +136,9 @@ export default class MysInfo {
let selfUser = at ? await NoteUser.create(at) : user let selfUser = at ? await NoteUser.create(at) : user
if (!selfUser.hasCk) { if (!selfUser.hasCk) {
if (e.noTips !== true) e.reply('尚未绑定cookie', false, { at: selfUser.qq }) if (e.noTips !== true) e.reply(['尚未绑定Cookie', segment.button([
{ text: "Cookie帮助", callback: "#Cookie帮助" },
])], false, { at: selfUser.qq })
return false return false
} }
@ -304,11 +313,15 @@ export default class MysInfo {
if (this.e.noTips === true) return if (this.e.noTips === true) return
if (!this.uid) { if (!this.uid) {
this.e.reply('请先#绑定uid') this.e.reply(['请先#绑定uid', segment.button([
{ text: "绑定UID", input: "#绑定uid" },
])])
} }
if (!this.ckInfo.ck) { if (!this.ckInfo.ck) {
this.e.reply('暂无可用CK请绑定更多用户或设置公共ck..') this.e.reply(['暂无可用CK请绑定更多用户或设置公共ck..', segment.button([
{ text: "Cookie帮助", callback: "#Cookie帮助" },
])])
} }
this.e.noTips = true this.e.noTips = true
@ -342,7 +355,7 @@ export default class MysInfo {
async checkCode (res, type, mysApi = {}, data = {}, isTask = false) { async checkCode (res, type, mysApi = {}, data = {}, isTask = false) {
if (!res) { if (!res) {
if (!isTask) this.e.reply('米游社接口请求失败,暂时无法查询') if (!isTask) this.e.reply(['米游社接口请求失败,暂时无法查询', this.mysButton])
return false return false
} }
@ -364,30 +377,30 @@ export default class MysInfo {
if (/(登录|login)/i.test(res.message)) { if (/(登录|login)/i.test(res.message)) {
if (this.ckInfo.uid) { if (this.ckInfo.uid) {
logger.mark(`[ck失效][uid:${this.uid}][qq:${this.userId}]`) logger.mark(`[ck失效][uid:${this.uid}][qq:${this.userId}]`)
if (!isTask) this.e.reply(`UID:${this.ckInfo.uid},米游社cookie已失效`) if (!isTask) this.e.reply([`UID:${this.ckInfo.uid},米游社Cookie已失效`, this.mysButton])
} else { } else {
logger.mark(`[公共ck失效][ltuid:${this.ckInfo.ltuid}]`) logger.mark(`[公共ck失效][ltuid:${this.ckInfo.ltuid}]`)
if (!isTask) this.e.reply('米游社查询失败,请稍后再试') if (!isTask) this.e.reply(['米游社查询失败,请稍后再试', this.mysButton])
} }
if (!isTask) await this.delCk() if (!isTask) await this.delCk()
} else { } else {
if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message}`) if (!isTask) this.e.reply([`米游社接口报错,暂时无法查询:${res.message}`, this.mysButton])
} }
break break
case 1008: case 1008:
if (!isTask) this.e.reply('\n请先去米游社绑定角色', false, { at: this.userId }) if (!isTask) this.e.reply(['请先去米游社绑定角色', this.mysButton], false, { at: this.userId })
break break
case 10101: case 10101:
if (!isTask) { if (!isTask) {
await this.disableToday() await this.disableToday()
this.e.reply('查询已达今日上限') this.e.reply(['查询已达今日上限', this.mysButton])
} }
break break
case 10102: case 10102:
if (res.message === 'Data is not public for the user') { if (res.message === 'Data is not public for the user') {
if (!isTask) this.e.reply(`\nUID:${this.uid},米游社数据未公开`, false, { at: this.userId }) if (!isTask) this.e.reply([`\nUID:${this.uid},米游社数据未公开`, this.mysButton], false, { at: this.userId })
} else { } else {
if (!isTask) this.e.reply(`uid:${this.uid},请先去米游社绑定角色`) if (!isTask) this.e.reply([`uid:${this.uid},请先去米游社绑定角色`, this.mysButton])
} }
break break
// 伙伴不存在~ // 伙伴不存在~
@ -395,7 +408,7 @@ export default class MysInfo {
if (res.api === 'detail') res.retcode = 0 if (res.api === 'detail') res.retcode = 0
break break
case 5003: case 5003:
if (!isTask) this.e.reply('米游社账号异常,暂时无法查询') if (!isTask) this.e.reply(['米游社账号异常,暂时无法查询', this.mysButton])
break break
case 1034: case 1034:
let handler = this.e.runtime?.handler || {} let handler = this.e.runtime?.handler || {}
@ -408,14 +421,14 @@ export default class MysInfo {
if (!res || res?.retcode == 1034) { if (!res || res?.retcode == 1034) {
logger.mark(`[米游社查询失败][uid:${this.uid}][qq:${this.userId}] 遇到验证码`) logger.mark(`[米游社查询失败][uid:${this.uid}][qq:${this.userId}] 遇到验证码`)
if (!isTask) this.e.reply('米游社查询遇到验证码,请稍后再试') if (!isTask) this.e.reply(['米游社查询遇到验证码,请稍后再试', this.mysButton])
} }
break break
case 10307: case 10307:
if (!isTask) this.e.reply('版本更新期间,数据维护中') if (!isTask) this.e.reply(['版本更新期间,数据维护中', this.mysButton])
break break
default: default:
if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message || 'error'}`) if (!isTask) this.e.reply([`米游社接口报错,暂时无法查询:${res.message || 'error'}`, this.mysButton])
break break
} }
if (res.retcode !== 0) { if (res.retcode !== 0) {

View File

@ -276,11 +276,9 @@ export default class MysNews extends base {
replyMsg(img, title) { replyMsg(img, title) {
if (!img || img.length <= 0) return false if (!img || img.length <= 0) return false
if (img.length == 1) { if (title) img = [title, ...img]
if (title) return [title, ...img] if (img.length <= 2) return img
return img return common.makeForwardMsg(this.e, [img])
}
return common.makeForwardMsg(this.e, img, title)
} }
async mysNewsTask() { async mysNewsTask() {

View File

@ -46,7 +46,7 @@ export default class User extends base {
this.e.ck = this.ck this.e.ck = this.ck
} }
if (!this.e.ck) { if (!this.e.ck) {
await this.e.reply(`请【私聊】发送米游社cookie获取教程\n${set.cookieDoc}`) await this.e.reply(`请【私聊】发送米游社Cookie获取教程\n${set.cookieDoc}`)
return return
} }
@ -59,14 +59,14 @@ export default class User extends base {
}) })
if (!param.cookie_token && !param.cookie_token_v2) { if (!param.cookie_token && !param.cookie_token_v2) {
await this.e.reply('发送cookie不完整\n请退出米游社【重新登录】刷新完整cookie') await this.e.reply('发送Cookie不完整\n请退出米游社【重新登录】刷新完整Cookie')
return return
} }
// TODO独立的mys数据不走缓存ltuid // TODO独立的mys数据不走缓存ltuid
let mys = await MysUser.create(param.ltuid || param.ltuid_v2 || param.account_id_v2 || param.ltmid_v2) let mys = await MysUser.create(param.ltuid || param.ltuid_v2 || param.account_id_v2 || param.ltmid_v2)
if (!mys) { if (!mys) {
await this.e.reply('发送cookie不完整或数据错误') await this.e.reply('发送Cookie不完整或数据错误')
return return
} }
let data = {} let data = {}
@ -92,10 +92,10 @@ export default class User extends base {
/** 检查ck是否失效 */ /** 检查ck是否失效 */
let uidRet = await mys.reqMysUid() let uidRet = await mys.reqMysUid()
if (uidRet.status !== 0) { if (uidRet.status !== 0) {
logger.mark(`绑定cookie错误1${this.checkMsg || 'cookie错误'}`) logger.mark(`绑定Cookie错误1${this.checkMsg || 'Cookie错误'}`)
// 清除mys数据 // 清除mys数据
mys._delCache() mys._delCache()
return await this.e.reply(`绑定cookie失败${this.checkMsg || 'cookie错误'}`) return await this.e.reply(`绑定Cookie失败${this.checkMsg || 'Cookie错误'}`)
} }
// 判断data.ltuid是否是数字 // 判断data.ltuid是否是数字
@ -107,22 +107,23 @@ export default class User extends base {
this.ltuid = userInfo.uid || this.ltuid this.ltuid = userInfo.uid || this.ltuid
this.ck = `${this.ck}ltuid=${this.ltuid};` this.ck = `${this.ck}ltuid=${this.ltuid};`
} else { } else {
logger.mark(`绑定cookie错误2${userFullInfo.message || 'cookie错误'}`) logger.mark(`绑定Cookie错误2${userFullInfo.message || 'Cookie错误'}`)
return await this.e.reply(`绑定cookie失败${userFullInfo.message || 'cookie错误'}`) return await this.e.reply(`绑定Cookie失败${userFullInfo.message || 'Cookie错误'}`)
} }
} }
logger.mark(`${this.e.logFnc} 检查cookie正常 [ltuid:${mys.ltuid}]`) logger.mark(`${this.e.logFnc} 检查Cookie正常 [ltuid:${mys.ltuid}]`)
await user.addMysUser(mys) await user.addMysUser(mys)
await mys.initCache() await mys.initCache()
await user.save() await user.save()
logger.mark(`${this.e.logFnc} 保存cookie成功 [ltuid:${mys.ltuid}]`) logger.mark(`${this.e.logFnc} 保存Cookie成功 [ltuid:${mys.ltuid}]`)
let uidMsg = ['绑定cookie成功', mys.getUidInfo()] let uidMsg = ['绑定Cookie成功', mys.getUidInfo()]
await this.e.reply(uidMsg.join('\n')) await this.e.reply(uidMsg.join('\n'))
let msg = [] let msg = []
let button = []
if (mys.hasGame('gs')) { if (mys.hasGame('gs')) {
msg.push( msg.push(
'原神模块支持:', '原神模块支持:',
@ -135,6 +136,19 @@ export default class User extends base {
'【#练度统计】技能统计列表', '【#练度统计】技能统计列表',
'【#面板】【#更新面板】面板信息' '【#面板】【#更新面板】面板信息'
) )
button.push([
{ text: "#uid", callback: "#uid" },
{ text: "#我的ck", callback: "#我的ck" },
{ text: "#删除ck", callback: "#删除ck" },
],[
{ text: "#体力", callback: "#体力" },
{ text: "#原石", callback: "#原石" },
{ text: "#原石统计", callback: "#原石统计" },
],[
{ text: "#练度统计", callback: "#练度统计" },
{ text: "#面板", callback: "#面板" },
{ text: "#更新面板", callback: "#更新面板" },
])
} }
if (mys.hasGame('sr')) { if (mys.hasGame('sr')) {
msg.push( msg.push(
@ -144,8 +158,16 @@ export default class User extends base {
'【*体力】体力信息', '【*体力】体力信息',
'【*面板】【*更新面板】面板信息' '【*面板】【*更新面板】面板信息'
) )
button.push([
{ text: "*uid", callback: "*uid" },
{ text: "*删除ck", callback: "*删除ck" },
{ text: "*体力", callback: "*体力" },
],[
{ text: "*面板", callback: "*面板" },
{ text: "*更新面板", callback: "*更新面板" },
])
} }
msg = await common.makeForwardMsg(this.e, ['使用命令说明', msg.join('\n')], '绑定成功:使用命令说明') msg = await common.makeForwardMsg(this.e, [[msg.join('\n'), segment.button(...button)]], '绑定成功:使用命令说明')
await this.e.reply(msg) await this.e.reply(msg)
} }
@ -168,7 +190,7 @@ export default class User extends base {
if (!mys) { if (!mys) {
return `删除失败当前的UID${uidData?.uid}无CK信息` return `删除失败当前的UID${uidData?.uid}无CK信息`
} }
let msg = ['绑定cookie已删除', mys.getUidInfo()] let msg = ['绑定Cookie已删除', mys.getUidInfo()]
await user.delMysUser(uidData.ltuid) await user.delMysUser(uidData.ltuid)
return msg.join('\n') return msg.join('\n')
} }
@ -188,12 +210,16 @@ export default class User extends base {
let game = this.e let game = this.e
let uidList = user.getUidList(game) let uidList = user.getUidList(game)
if (index > uidList.length) { if (index > uidList.length) {
return await this.e.reply('uid序号输入错误') return await this.e.reply(['uid序号输入错误', segment.button([
{ text: "删除uid", input: "#删除uid" },
])])
} }
index = Number(index) - 1 index = Number(index) - 1
let uidObj = uidList[index] let uidObj = uidList[index]
if (uidObj.type === 'ck') { if (uidObj.type === 'ck') {
return await this.e.reply('CK对应UID无法直接删除请通过【#删除ck】命令来删除') return await this.e.reply(['CK对应UID无法直接删除请通过【#删除ck】命令来删除', segment.button([
{ text: "删除ck", callback: "#删除ck" },
])])
} }
await user.delRegUid(uidObj.uid, game) await user.delRegUid(uidObj.uid, game)
return await this.showUid() return await this.showUid()
@ -248,10 +274,26 @@ export default class User extends base {
} }
}) })
}) })
let e = this.e return this.e.reply([await this.e.runtime.render('genshin', 'html/user/uid-list', { uids }, { retType: "base64" }), segment.button([
return e.runtime.render('genshin', 'html/user/uid-list', { { text: "绑定UID", input: "#绑定uid" },
uids { text: "切换UID", input: "#uid" },
}) { text: "删除UID", input: "#删除uid" },
],[
{ text: "角色", callback: "#角色" },
{ text: "探索", callback: "#探索" },
{ text: "武器", callback: "#武器" },
{ text: "深渊", callback: "#深渊" },
],[
{ text: "统计", callback: "#练度统计" },
{ text: "面板", callback: "#面板" },
{ text: "体力", callback: "#体力" },
{ text: "原石", callback: "#原石" },
],[
{ text: "留影", callback: "#留影叙佳期" },
{ text: "七圣", callback: "#七圣召唤查询牌组" },
{ text: "抽卡", callback: "#抽卡记录" },
{ text: "充值", callback: "#充值记录" },
])])
} }
/** 切换uid */ /** 切换uid */
@ -260,7 +302,9 @@ export default class User extends base {
let game = this.e let game = this.e
let uidList = user.getUidList(game) let uidList = user.getUidList(game)
if (index > uidList.length) { if (index > uidList.length) {
return await this.e.reply('uid序号输入错误') return await this.e.reply(['uid序号输入错误', segment.button([
{ text: "切换uid", input: "#uid" },
])])
} }
index = Number(index) - 1 index = Number(index) - 1
user.setMainUid(index, game) user.setMainUid(index, game)
@ -455,11 +499,13 @@ export default class User extends base {
async myCk () { async myCk () {
let user = await this.user() let user = await this.user()
if (!user.hasCk) { if (!user.hasCk) {
this.e.reply('当前尚未绑定cookie') this.e.reply(['当前尚未绑定Cookie', segment.button([
{ text: "帮助", input: "#Cookie帮助" },
])])
} }
let mys = user.getMysUser(this.e) let mys = user.getMysUser(this.e)
if (mys) { if (mys) {
await this.e.reply(`当前绑定cookie\nuid${mys.getUid(this.e)}`) await this.e.reply(`当前绑定Cookie\nuid${mys.getUid(this.e)}`)
await this.e.reply(mys.ck) await this.e.reply(mys.ck)
} }
} }
@ -493,7 +539,11 @@ export default class User extends base {
cks.push(`当前生效uid${uid}\n通过【#uid】命令可查看并切换UID`) cks.push(`当前生效uid${uid}\n通过【#uid】命令可查看并切换UID`)
} }
await this.e.reply(cks.join('\n----\n'), false, { at: true }) await this.e.reply([cks.join('\n----\n'), segment.button([
{ text: "绑定UID", input: "#绑定uid" },
{ text: "切换UID", input: "#uid" },
{ text: "删除UID", input: "#删除uid" },
])], false, { at: true })
} }
async userAdmin () { async userAdmin () {