修正ck绑定问题,以及支持星铁体力查询;

关于uid绑定问题:
由于目前整体的ck以及uid管理逻辑需要重写,导致目前uid切换会导致功能异常问题
目前的话麻烦尽量
后续整体数据将会使用数据库(sqllite)进行维护以避免类似情况发送
This commit is contained in:
Ctrlcvs 2023-05-06 16:29:11 +08:00
parent 973d10cda6
commit f6890f27c4
12 changed files with 657 additions and 217 deletions

View File

@ -13,7 +13,7 @@ export class dailyNote extends plugin {
event: 'message',
priority: 300,
rule: [{
reg: '^#*(体力|树脂|查询体力)$',
reg: '^#*(原神|星铁|崩坏星穹铁道|铁道)?(体力|树脂|查询体力)$',
fnc: 'note'
}]
})

View File

@ -374,30 +374,16 @@ export default class MysUser extends BaseModel {
}
static async getGameRole (ck, serv = 'mys') {
let biz=['hk4e_cn','hkrpg_cn']
let url = {
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=',
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
hoyolab: 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global'
}
let list=[];
let result;
if(serv=='mys'){
for(let item of biz){
result=await fetch(url[serv]+item, { method: 'get', headers: { Cookie: ck } })
if(result.ok){
result=await result.json()
if(result?.data?.list.length>0){
list.push(...result.data.list)
}
}
}
result.data.list=list
}else{
let res = await fetch(url[serv], { method: 'get', headers: { Cookie: ck } })
if (!res.ok) return false
result = await res.json()
}
return result
let res = await fetch(url[serv], { method: 'get', headers: { Cookie: ck } })
if (!res.ok) return false
res = await res.json()
return res
}
// 获取米游社通行证id
@ -472,11 +458,11 @@ export default class MysUser extends BaseModel {
}
if (!res) return ret(msg, false)
if (!res.data.list || res.data.list.length <= 0) {
return ret('该账号尚未绑定原神角色', false)
return ret('该账号尚未绑定原神或星穹角色', false)
}
for (let val of res.data.list) {
if (/\d{9}/.test(val.game_uid)) {
if (/\d{9}/.test(val.game_uid)&&val.game_biz=='hk4e_cn') {
uids.push(val.game_uid + '')
}
}

View File

@ -142,8 +142,7 @@ export default class NoteUser extends BaseModel {
* 主要供内部调用建议使用 user.uid 获取用户uid
* @returns {Promise<*>}
*/
async getRegUid () {
let redisKey = `Yz:genshin:mys:qq-uid:${this.qq}`
async getRegUid (redisKey = `Yz:genshin:mys:qq-uid:${this.qq}`) {
let uid = await redis.get(redisKey)
if (uid) {
await redis.setEx(redisKey, 3600 * 24 * 30, uid)

View File

@ -0,0 +1,149 @@
/**
* 整合接口用于查询数据
* 方便后续用于解耦
* 临时处理后续大概率重写 主要原因
*/
export default class apiTool {
/**
*
* @param {用户uid} uid
* @param {区服} server
* @param {是否为星穹铁道或其他游戏? type(bool or string)} isSr
*/
constructor(uid, server, isSr = false) {
this.uid = uid
this.isSr = isSr
this.server = server
this.game='genshin'
if(isSr) this.game='honkaisr'
if(typeof isSr !== 'boolean'){
this.game=isSr
}
}
getUrlMap = (data = {}) => {
let host, hostRecord
if (['cn_gf01', 'cn_qd01', 'prod_gf_cn','prod_qd_cn'].includes(this.server)) {
host = 'https://api-takumi.mihoyo.com/'
hostRecord = 'https://api-takumi-record.mihoyo.com/'
} else if (['os_usa', 'os_euro', 'os_asia', 'os_cht'].includes(this.server)) {
host = 'https://api-os-takumi.mihoyo.com/'
hostRecord = 'https://bbs-api-os.mihoyo.com/'
}
let urlMap = {
genshin: {
/** 首页宝箱 */
index: {
url: `${hostRecord}game_record/app/genshin/api/index`,
query: `role_id=${this.uid}&server=${this.server}`
},
/** 深渊 */
spiralAbyss: {
url: `${hostRecord}game_record/app/genshin/api/spiralAbyss`,
query: `role_id=${this.uid}&schedule_type=${data.schedule_type || 1}&server=${this.server}`
},
/** 角色详情 */
character: {
url: `${hostRecord}game_record/app/genshin/api/character`,
body: { role_id: this.uid, server: this.server }
},
/** 树脂 */
dailyNote: {
url: `${hostRecord}game_record/app/genshin/api/dailyNote`,
query: `role_id=${this.uid}&server=${this.server}`
},
/** 详情 */
detail: {
url: `${host}event/e20200928calculate/v1/sync/avatar/detail`,
query: `uid=${this.uid}&region=${this.server}&avatar_id=${data.avatar_id}`
},
/** 札记 */
ys_ledger: {
url: 'https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo',
query: `month=${data.month}&bind_uid=${this.uid}&bind_region=${this.server}`
},
/** 养成计算器 */
compute: {
url: `${host}event/e20200928calculate/v2/compute`,
body: data
},
blueprintCompute: {
url: `${host}event/e20200928calculate/v1/furniture/compute`,
body: data
},
/** 养成计算器 */
blueprint: {
url: `${host}event/e20200928calculate/v1/furniture/blueprint`,
query: `share_code=${data.share_code}&region=${this.server}`
},
/** 角色技能 */
avatarSkill: {
url: `${host}event/e20200928calculate/v1/avatarSkill/list`,
query: `avatar_id=${data.avatar_id}`
},
/** 七圣召唤数据 */
basicInfo: {
url: `${hostRecord}game_record/app/genshin/api/gcg/basicInfo`,
query: `role_id=${this.uid}&server=${this.server}`
},
/**使用兑换码 目前仅限国际服,来自于国服的uid请求已在myinfo.js的init方法提前拦截 */
useCdk: {
url: 'PLACE_HOLDER',
query: null
}
},
honkaisr: {
/** 首页宝箱 */
index: {
url: `${hostRecord}game_record/app/hkrpg/api/index`,
query: `role_id=${this.uid}&server=${this.server}`
},
UserGame:{
url:`${host}common/badge/v1/login/account`,
body: { uid: this.uid, region: this.server,lang:'zh-cn',game_biz:'hkrpg_cn' }
},
/**
* 开拓阅历接口
*/
ys_ledger:{
url:`${host}/event/srledger/month_info`,
query:`region=${this.server}&uid=${this.uid}&month=${data.month}`
},
/** 角色详情 */
character: {
url: `${hostRecord}game_record/app/hkrpg/api/avatar/info`,
body: { role_id: this.uid, server: this.server }
},
/** 树脂 */
dailyNote: {
url: `${hostRecord}game_record/app/hkrpg/api/note`,
query: `role_id=${this.uid}&server=${this.server}`
},
}
}
if (this.server.startsWith('os')) {
urlMap.genshin.bbs_sign_info.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/info'
urlMap.genshin.bbs_sign_info.query = `act_id=e202102251931481&region=${this.server}&uid=${this.uid}`
urlMap.genshin.bbs_sign_home.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/home'
urlMap.genshin.bbs_sign_home.query = `act_id=e202102251931481&region=${this.server}&uid=${this.uid}`
urlMap.genshin.bbs_sign.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/sign'
urlMap.genshin.bbs_sign.body = { act_id: 'e202102251931481', region: this.server, uid: this.uid }
urlMap.genshin.detail.url = 'https://sg-public-api.hoyolab.com/event/calculateos/sync/avatar/detail'// 角色天赋详情
urlMap.genshin.detail.query = `lang=zh-cn&uid=${this.uid}&region=${this.server}&avatar_id=${data.avatar_id}`
urlMap.genshin.avatarSkill.url = 'https://sg-public-api.hoyolab.com/event/calculateos/avatar/skill_list'// 查询未持有的角色天赋
urlMap.genshin.avatarSkill.query = `lang=zh-cn&avatar_id=${data.avatar_id}`
urlMap.genshin.compute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/compute'// 已支持养成计算
urlMap.genshin.blueprint.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/blueprint'
urlMap.genshin.blueprint.query = `share_code=${data.share_code}&region=${this.server}&lang=zh-cn`
urlMap.genshin.blueprintCompute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/compute'
urlMap.genshin.blueprintCompute.body = { lang: 'zh-cn', ...data }
urlMap.genshin.ys_ledger.url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info'// 支持了国际服札记
urlMap.genshin.ys_ledger.query = `lang=zh-cn&month=${data.month}&uid=${this.uid}&region=${this.server}`
urlMap.genshin.useCdk.url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
urlMap.genshin.useCdk.query = `uid=${this.uid}&region=${this.server}&lang=zh-cn&cdkey=${data.cdk}&game_biz=hk4e_global`
}
return urlMap[this.game]
}
}

View File

@ -2,9 +2,8 @@ import md5 from 'md5'
import lodash from 'lodash'
import fetch from 'node-fetch'
import cfg from '../../../../lib/config/config.js'
import apiTool from './apiTool.js'
let HttpsProxyAgent = ''
export default class MysApi {
/**
* @param uid 游戏uid
@ -12,11 +11,12 @@ export default class MysApi {
* @param option 其他参数
* @param option.log 是否显示日志
*/
constructor (uid, cookie, option = {}) {
constructor(uid, cookie, option = {}, isSr = false) {
this.uid = uid
this.cookie = cookie
this.isSr = isSr
this.server = this.getServer()
this.apiTool = new apiTool(uid, this.server, isSr)
/** 5分钟缓存 */
this.cacheCd = 300
@ -26,107 +26,8 @@ export default class MysApi {
}
}
getUrl (type, data = {}) {
let host, hostRecord
if (['cn_gf01', 'cn_qd01'].includes(this.server)) {
host = 'https://api-takumi.mihoyo.com/'
hostRecord = 'https://api-takumi-record.mihoyo.com/'
} else if (['os_usa', 'os_euro', 'os_asia', 'os_cht'].includes(this.server)) {
host = 'https://api-os-takumi.mihoyo.com/'
hostRecord = 'https://bbs-api-os.mihoyo.com/'
}
let urlMap = {
/** 首页宝箱 */
index: {
url: `${hostRecord}game_record/app/genshin/api/index`,
query: `role_id=${this.uid}&server=${this.server}`
},
/** 深渊 */
spiralAbyss: {
url: `${hostRecord}game_record/app/genshin/api/spiralAbyss`,
query: `role_id=${this.uid}&schedule_type=${data.schedule_type || 1}&server=${this.server}`
},
/** 角色详情 */
character: {
url: `${hostRecord}game_record/app/genshin/api/character`,
body: { role_id: this.uid, server: this.server }
},
/** 树脂 */
dailyNote: {
url: `${hostRecord}game_record/app/genshin/api/dailyNote`,
query: `role_id=${this.uid}&server=${this.server}`
},
/** 详情 */
detail: {
url: `${host}event/e20200928calculate/v1/sync/avatar/detail`,
query: `uid=${this.uid}&region=${this.server}&avatar_id=${data.avatar_id}`
},
/** 札记 */
ys_ledger: {
url: 'https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo',
query: `month=${data.month}&bind_uid=${this.uid}&bind_region=${this.server}`
},
/** 养成计算器 */
compute: {
url: `${host}event/e20200928calculate/v2/compute`,
body: data
},
blueprintCompute: {
url: `${host}event/e20200928calculate/v1/furniture/compute`,
body: data
},
/** 养成计算器 */
blueprint: {
url: `${host}event/e20200928calculate/v1/furniture/blueprint`,
query: `share_code=${data.share_code}&region=${this.server}`
},
/** 角色技能 */
avatarSkill: {
url: `${host}event/e20200928calculate/v1/avatarSkill/list`,
query: `avatar_id=${data.avatar_id}`
},
createVerification: {
url: `${hostRecord}game_record/app/card/wapi/createVerification`,
query: 'is_high=true'
},
verifyVerification: {
url: `${hostRecord}game_record/app/card/wapi/verifyVerification`,
body: data
},
/** 七圣召唤数据 */
basicInfo: {
url: `${hostRecord}game_record/app/genshin/api/gcg/basicInfo`,
query: `role_id=${this.uid}&server=${this.server}`
},
/**使用兑换码 目前仅限国际服,来自于国服的uid请求已在myinfo.js的init方法提前拦截 */
useCdk: {
url:'PLACE_HOLDER',
query: null
}
}
if (this.server.startsWith('os')) {
urlMap.detail.url = 'https://sg-public-api.hoyolab.com/event/calculateos/sync/avatar/detail'// 角色天赋详情
urlMap.detail.query = `lang=zh-cn&uid=${this.uid}&region=${this.server}&avatar_id=${data.avatar_id}`
urlMap.avatarSkill.url = 'https://sg-public-api.hoyolab.com/event/calculateos/avatar/skill_list'// 查询未持有的角色天赋
urlMap.avatarSkill.query = `lang=zh-cn&avatar_id=${data.avatar_id}`
urlMap.compute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/compute'// 已支持养成计算
urlMap.blueprint.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/blueprint'
urlMap.blueprint.query = `share_code=${data.share_code}&region=${this.server}&lang=zh-cn`
urlMap.blueprintCompute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/compute'
urlMap.blueprintCompute.body = { lang: 'zh-cn', ...data }
urlMap.ys_ledger.url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info'// 支持了国际服札记
urlMap.ys_ledger.query = `lang=zh-cn&month=${data.month}&uid=${this.uid}&region=${this.server}`
urlMap.useCdk.url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
urlMap.useCdk.query = `uid=${this.uid}&region=${this.server}&lang=zh-cn&cdkey=${data.cdk}&game_biz=hk4e_global`
}
getUrl(type, data = {}) {
let urlMap = this.apiTool.getUrlMap(data)
if (!urlMap[type]) return false
let { url, query = '', body = '', sign = '' } = urlMap[type]
@ -139,27 +40,27 @@ export default class MysApi {
return { url, headers, body }
}
getServer () {
getServer() {
let uid = this.uid
switch (String(uid)[0]) {
case '1':
case '2':
return 'cn_gf01' // 官服
return this.isSr ? 'prod_gf_cn' : 'cn_gf01' // 官服
case '5':
return 'cn_qd01' // B服
return this.isSr ? 'prod_qd_cn' : 'cn_qd01' // B服
case '6':
return 'os_usa' // 美服
return this.isSr ? 'prod_official_usa' : 'os_usa' // 美服
case '7':
return 'os_euro' // 欧服
return this.isSr ? 'prod_official_euro' : 'os_euro' // 欧服
case '8':
return 'os_asia' // 亚服
return this.isSr ? 'prod_official_asia' : 'os_asia' // 亚服
case '9':
return 'os_cht' // 港澳台服
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服
}
return 'cn_gf01'
}
async getData (type, data = {}, cached = false) {
async getData(type, data = {}, cached = false) {
let { url, headers, body } = this.getUrl(type, data)
if (!url) return false
@ -180,7 +81,6 @@ export default class MysApi {
agent: await this.getAgent(),
timeout: 10000
}
if (body) {
param.method = 'post'
param.body = body
@ -223,8 +123,8 @@ export default class MysApi {
getHeaders (query = '', body = '') {
const cn = {
app_version: '2.37.1',
User_Agent: `Mozilla/5.0 (Linux; Android 12; ${this.device}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.37.1`,
app_version: '2.40.1',
User_Agent: `Mozilla/5.0 (Linux; Android 12; ${this.device}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.40.1`,
client_type: 5,
Origin: 'https://webstatic.mihoyo.com',
X_Requested_With: 'com.mihoyo.hyperion',
@ -253,11 +153,11 @@ export default class MysApi {
}
}
getDs (q = '', b = '') {
getDs(q = '', b = '') {
let n = ''
if (['cn_gf01', 'cn_qd01'].includes(this.server)) {
if (['cn_gf01', 'cn_qd01','prod_gf_cn','prod_qd_cn'].includes(this.server)) {
n = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
} else if (['os_usa', 'os_euro', 'os_asia', 'os_cht'].includes(this.server)) {
} else if (/os_|official/.test(this.server)) {
n = 'okr4obncj8bw5a65hbnn5oo6ixjc3l9w'
}
let t = Math.round(new Date().getTime() / 1000)
@ -274,22 +174,22 @@ export default class MysApi {
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
}
cacheKey (type, data) {
cacheKey(type, data) {
return 'Yz:genshin:mys:cache:' + md5(this.uid + type + JSON.stringify(data))
}
async cache (res, cacheKey) {
async cache(res, cacheKey) {
if (!res || res.retcode !== 0) return
redis.setEx(cacheKey, this.cacheCd, JSON.stringify(res))
}
/* eslint-disable quotes */
get device () {
get device() {
if (!this._device) this._device = `Yz-${md5(this.uid).substring(0, 5)}`
return this._device
}
async getAgent () {
async getAgent() {
let proxyAddress = cfg.bot.proxyAddress
if (!proxyAddress) return null
if (proxyAddress === 'http://0.0.0.0:0') return null

View File

@ -187,7 +187,7 @@ export default class MysInfo {
if (!mysInfo.uid || !mysInfo.ckInfo.ck) return false
e.uid = mysInfo.uid
let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option)
let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option,e.isSr)
let res
if (lodash.isObject(api)) {
@ -240,7 +240,7 @@ export default class MysInfo {
* @param onlySelfCk 是否只获取uid自己对应的ck为true则只获取uid对应ck若无则返回为空
* @returns {Promise<string|string|*>} 查询ck获取失败则返回空
*/
async getCookie (onlySelfCk = false) {
async getCookie(onlySelfCk = false) {
if (this.ckInfo.ck) return this.ckInfo.ck
let mysUser = await MysUser.getByQueryUid(this.uid, onlySelfCk)
@ -263,7 +263,7 @@ export default class MysInfo {
* 初始化公共CK
* @returns {Promise<void>}
*/
static async initPubCk () {
static async initPubCk() {
// 初始化公共CK
let pubCount = 0
let pubCks = GsCfg.getConfig('mys', 'pubCk') || []
@ -287,7 +287,7 @@ export default class MysInfo {
* 默认会将用户CK加入查询池
* @returns {Promise<void>}
*/
static async initUserCk () {
static async initUserCk() {
// 初始化用户缓存
let userCount = 0
await NoteUser.forEach(async function (user) {
@ -302,7 +302,7 @@ export default class MysInfo {
* @param clearData 强制初始化时是否清除已有数据 (刷新/重置)
* @returns {Promise<boolean>}
*/
static async initCache (force = false, clearData = false) {
static async initCache(force = false, clearData = false) {
// 检查缓存标记
let cache = DailyCache.create()
if (!force && await cache.get('cache-ready')) {
@ -325,7 +325,7 @@ export default class MysInfo {
return true
}
async checkCode (res, type) {
async checkCode(res, type) {
if (!res) {
this.e.reply('米游社接口请求失败,暂时无法查询')
return false
@ -337,6 +337,7 @@ export default class MysInfo {
res.retcode = 0
}
}
switch (res.retcode) {
case 0:
break
@ -372,7 +373,7 @@ export default class MysInfo {
this.e.reply(`uid:${this.uid},请先去米游社绑定角色`)
}
break
// 伙伴不存在~
// 伙伴不存在~
case -1002:
if (res.api === 'detail') res.retcode = 0
break
@ -393,7 +394,7 @@ export default class MysInfo {
}
/** 删除失效ck */
async delCk () {
async delCk() {
if (!this.ckUser) {
return false
}
@ -403,18 +404,18 @@ export default class MysInfo {
}
/** 查询次数满,今日内标记失效 */
async disableToday () {
async disableToday() {
/** 统计次数设为超限 */
await this.ckUser.disable()
}
static async getBingCkUid () {
static async getBingCkUid() {
let res = await GsCfg.getBingCk()
return { ...res.ck }
}
// 获取uid绑定的ck信息
static async checkUidBing (uid) {
static async checkUidBing(uid) {
let ckUser = await MysUser.getByQueryUid(uid, true)
if (ckUser && ckUser.ckData) {
return ckUser.ckData
@ -422,7 +423,7 @@ export default class MysInfo {
return false
}
static async delDisable () {
static async delDisable() {
return await MysUser.delDisable()
}
}

View File

@ -1,110 +1,175 @@
import moment from 'moment'
import lodash from 'lodash'
import base from './base.js'
import MysInfo from './mys/mysInfo.js'
import moment from "moment";
import lodash from "lodash";
import base from "./base.js";
import MysInfo from "./mys/mysInfo.js";
export default class Note extends base {
constructor (e) {
super(e)
this.model = 'dailyNote'
constructor(e) {
super(e);
this.model = "dailyNote";
}
/** 生成体力图片 */
static async get (e) {
let note = new Note(e)
return await note.getData()
static async get(e) {
let note = new Note(e);
return await note.getData();
}
async getData () {
let res = await MysInfo.get(this.e, 'dailyNote')
if (!res || res.retcode !== 0) return false
async getData() {
let res = await MysInfo.get(this.e, "dailyNote");
let resUser;
if (!res || res.retcode !== 0) return false;
/** 截图数据 */
let data = this.e.isSr ? this.noteSr(res) : this.noteData(res);
let screenData = this.screenData;
if (this.e.isSr) {
screenData.tplFile = "./plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.html";
resUser = await MysInfo.get(this.e,'UserGame')
if (!resUser || resUser.retcode !== 0) return false;
}
return {
name: this.e.sender.card,
quality: 80,
...this.screenData,
...this.noteData(res)
}
...screenData,
...data,...resUser?.data
};
}
noteSr(res) {
let { data } = res;
let nowDay = moment().date();
let nowUnix = Number(moment().format("X"));
/** 树脂 */
let resinMaxTime;
if (data.stamina_recover_time > 0) {
let d = moment.duration(data.stamina_recover_time, 'seconds');
let day= Math.floor(d.asDays());
let hours =d.hours()
let minutes =d.minutes()
let seconds =d.seconds()
resinMaxTime = hours+'小时'+minutes+'分钟'+seconds+'秒'
if(day>0){
resinMaxTime =day+'天'+hours+'小时'+minutes+'分钟'+seconds+'秒'
}
}
data.bfStamina = data.current_stamina / data.max_stamina * data.max_stamina +'%';
/** 派遣 */
for(let item of data.expeditions){
let d = moment.duration(item.remaining_time, 'seconds');
let day= Math.floor(d.asDays());
let hours =d.hours()
let minutes =d.minutes()
item.dateTime=([day+'天',hours+'时',minutes+'分'].filter(v => !['0天','0时','0分'].includes(v))).join('')
item.bfTime=(72000-item.remaining_time)/72000 *100 +'%'
if(item.avatars.length==1){
item.avatars.push('派遣头像')
}
}
// 标识属性图标~
let icon = lodash.sample(['希儿','白露','艾丝妲','布洛妮娅','姬子','卡芙卡','克拉拉','停云','佩拉','黑塔','希露瓦','银狼'])
let week = [
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六",
];
let day = `${week[moment().day()]}`;
return {
uid: this.e.uid,
saveId: this.e.uid,icon,day,
resinMaxTime,nowDay:moment(new Date()).format('YYYY年MM月DD日'),
...data,
};
}
noteData(res) {
let { data } = res;
noteData (res) {
let { data } = res
let nowDay = moment().date()
let nowUnix = Number(moment().format('X'))
let nowDay = moment().date();
let nowUnix = Number(moment().format("X"));
/** 树脂 */
let resinMaxTime
let resinMaxTime;
if (data.resin_recovery_time > 0) {
resinMaxTime = nowUnix + Number(data.resin_recovery_time)
resinMaxTime = nowUnix + Number(data.resin_recovery_time);
let maxDate = moment.unix(resinMaxTime)
resinMaxTime = maxDate.format('HH:mm')
let maxDate = moment.unix(resinMaxTime);
resinMaxTime = maxDate.format("HH:mm");
if (maxDate.date() != nowDay) {
resinMaxTime = `明天 ${resinMaxTime}`
resinMaxTime = `明天 ${resinMaxTime}`;
} else {
resinMaxTime = ` ${resinMaxTime}`
resinMaxTime = ` ${resinMaxTime}`;
}
}
/** 派遣 */
let remainedTime = ''
let remainedTime = "";
if (data.expeditions && data.expeditions.length >= 1) {
remainedTime = lodash.map(data.expeditions, 'remained_time')
remainedTime = lodash.min(remainedTime)
remainedTime = lodash.map(data.expeditions, "remained_time");
remainedTime = lodash.min(remainedTime);
if (remainedTime > 0) {
remainedTime = nowUnix + Number(remainedTime)
let remainedDate = moment.unix(remainedTime)
remainedTime = remainedDate.format('HH:mm')
remainedTime = nowUnix + Number(remainedTime);
let remainedDate = moment.unix(remainedTime);
remainedTime = remainedDate.format("HH:mm");
if (remainedDate.date() != nowDay) {
remainedTime = `明天 ${remainedTime}`
remainedTime = `明天 ${remainedTime}`;
} else {
remainedTime = ` ${remainedTime}`
remainedTime = ` ${remainedTime}`;
}
}
}
/** 宝钱 */
let coinTime = ''
let coinTime = "";
if (data.home_coin_recovery_time > 0) {
let coinDay = Math.floor(data.home_coin_recovery_time / 3600 / 24)
let coinHour = Math.floor((data.home_coin_recovery_time / 3600) % 24)
let coinMin = Math.floor((data.home_coin_recovery_time / 60) % 60)
let coinDay = Math.floor(data.home_coin_recovery_time / 3600 / 24);
let coinHour = Math.floor((data.home_coin_recovery_time / 3600) % 24);
let coinMin = Math.floor((data.home_coin_recovery_time / 60) % 60);
if (coinDay > 0) {
coinTime = `${coinDay}${coinHour}小时${coinMin}分钟`
coinTime = `${coinDay}${coinHour}小时${coinMin}分钟`;
} else {
let coinDate = moment.unix(nowUnix + Number(data.home_coin_recovery_time))
let coinDate = moment.unix(
nowUnix + Number(data.home_coin_recovery_time)
);
if (coinDate.date() != nowDay) {
coinTime = `明天 ${coinDate.format('HH:mm')}`
coinTime = `明天 ${coinDate.format("HH:mm")}`;
} else {
coinTime = coinDate.format('HH:mm')
coinTime = coinDate.format("HH:mm");
}
}
}
let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let day = `${moment().format('MM-DD HH:mm')} ${week[moment().day()]}`
let week = [
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六",
];
let day = `${moment().format("MM-DD HH:mm")} ${week[moment().day()]}`;
/** 参量质变仪 */
if (data?.transformer?.obtained) {
data.transformer.reached = data.transformer.recovery_time.reached
let recoveryTime = ''
data.transformer.reached = data.transformer.recovery_time.reached;
let recoveryTime = "";
if (data.transformer.recovery_time.Day > 0) {
recoveryTime += `${data.transformer.recovery_time.Day}`
recoveryTime += `${data.transformer.recovery_time.Day}`;
}
if (data.transformer.recovery_time.Hour > 0) {
recoveryTime += `${data.transformer.recovery_time.Hour}小时`
recoveryTime += `${data.transformer.recovery_time.Hour}小时`;
}
if (data.transformer.recovery_time.Minute > 0) {
recoveryTime += `${data.transformer.recovery_time.Minute}分钟`
recoveryTime += `${data.transformer.recovery_time.Minute}分钟`;
}
data.transformer.recovery_time = recoveryTime
data.transformer.recovery_time = recoveryTime;
}
return {
@ -114,7 +179,7 @@ export default class Note extends base {
remainedTime,
coinTime,
day,
...data
}
...data,
};
}
}

View File

@ -103,7 +103,7 @@ export default class User extends base {
await this.e.reply(uidMsg.join('\n'))
let msg = ''
this.region_name += lodash.map(this.allUid, 'region_name').join(',')
if (/天空岛|世界树/.test(this.region_name)) {
if (/天空岛|世界树|America Server|Europe Server|Asia Server/.test(this.region_name)) {
msg += '原神模块支持:\n【#体力】查询当前树脂'
msg += '\n【#签到】米游社原神自动签到'
msg += '\n【#关闭签到】开启或关闭原神自动签到'
@ -148,6 +148,8 @@ export default class User extends base {
if (!res.data.list || res.data.list.length <= 0) {
this.checkMsg = '该账号尚未绑定原神或星穹角色!'
return false
} else {
res.data.list = res.data.list.filter(v => ['hk4e_cn', 'hkrpg_cn', 'hk4e_global'].includes(v.game_biz))
}
/** 米游社默认展示的角色 */
@ -250,7 +252,7 @@ export default class User extends base {
region_name.push(ckData[v].region_name)
}
});
let count = 0;
let count = 0;
for (let n of region_name) {
msg.push(n)
for (let i in uids) {

View File

@ -0,0 +1,270 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
/* 不让上传字体如需要请修改路径或者自行添加 部分插件有
@font-face {
font-family: "MiSans-Bold";
src: url("../../../../../../resources/font/MiSans-Bold.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "MiSans-Demibold";
src: url("../../../../../../resources/font/MiSans-Demibold.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "MiSans-Medium";
src: url("../../../../../../resources/font/MiSans-Medium.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "MiSans-Semibold";
src: url("../../../../../../resources/font/MiSans-Semibold.ttf");
font-weight: normal;
font-style: normal;
} */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
/* 如使用字体请把下面代码放出来,并注释或者删除 font-weight: bold; 属性 */
/* font-family: MiSans-Demibold; */
font-weight: bold;
}
body {
font-size: 18px;
color: #1e1f20;
font-family: PingFangSC-Medium, PingFang SC, sans-serif;
transform: scale(1.5);
transform-origin: 0 0;
width: 1200px;
}
.container {
width: 1200px;
height: 1835px;
background-color: #f5f6fb;
background-image: url("../../img/note/bg.png");
}
.uid {
border-radius: 0 25px 25px 0px;
display: flex;
width: 621px;
height: 200px;
justify-content: center;
flex-direction: column;
background-color: #b47f4c;
margin-top: 195px;
margin-left: 50px;
}
.uid_item {
background-color: #302b25;
color: #fff;
margin-left: 50px;
align-items: center;
justify-content: left;
display: flex;
padding: 8px 10px;
font-size: 45px;
height: 100px;
border-radius: 0 12px 0 0px;
font-family: MiSans-Demibold;
}
.uid_span {
text-indent: 1em;
font-size: 48px;
}
.uid_item:nth-child(2) {
background-color: #595045;
border-radius: 0 0 12px 0px;
font-size: 40px;
font-family: MiSans-Medium;
}
.uid_text {
width: 150px;
text-align: right;
}
.title {
display: flex;
position: relative;
}
.title_date {
width: 370px;
height: 530px;
position: absolute;
right: 70px;
top: 27px;
padding: 10px;
transform: rotate(4deg);
background-color: #fff;
border-bottom: 10px solid #b47f4c;
}
.icon {
width: 350px;
height: 350px;
}
.title_date_text {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-size: 30px;
color: #808080;
height: 160px;
font-family: MiSans-Semibold !important;
}
.title_date_text span{
font-family: MiSans-Semibold !important;
}
img {
width: 100%;
height: 100%;
}
.subject {
width: 1000px;
margin: 0 auto;
margin-top: 60px;
height: 320px;
background-color: #e5e5e5;
padding-left: 60px;
}
.subject_note {
font-size: 48px;
margin-top: 49px;
color: #000000;
font-family: MiSans-Demibold;
}
.subject_note span:nth-child(1) {
font-size: 82px;
color: #b47f4c;
font-family: MiSans-Bold;
}
.subject_solid {
display: flex;
width: 880px;
border-radius: 10px;
background-color: #a1a1a1;
height: 20px;
margin-top: 44px;
}
.subject_solid span {
background-color: #b47f4c;
width: 50%;
border-radius: 10px;
}
.subject_date {
margin-top: 43px;
font-size: 48px;
color: #000000;
}
.title_wt {
margin: 30px 0;
background-color: #b47f4c;
display: flex;
height: 80px;
width: 330px;
margin-left: 100px;
justify-content: center;
align-items: center;
}
.title_wt div {
font-size: 38px;
color: #fff;
background-color: #302b25;
height: 80px;
display: flex;
margin-left: 30px;
padding-left: 30px;
justify-content: left;
align-items: center;
width: calc(100% - 30px);
}
.bottom {
margin-left: 100px;
background-color: #e5e5e5;
height: 550px;
width: 1000px;
padding: 30px;
}
.bottom_item {
width: 100%;
height: 100px;
background-color: #d6d6d6;
flex-direction: column;
margin-bottom: 30px;
}
.bottom_list {
display: flex;
flex: 3;
height: 100px;
padding: 0 30px;
align-items: center;
}
.bottom_icon {
display: flex;
}
.bottom_icon div {
margin-left: 20px;
width: 70px;
height: 70px;
}
.bottom_icon img {
border-radius: 50%;
}
.bottom_list div:nth-child(1) {
font-size: 39px;
color: #000000;
}
.bottom_list div:nth-child(2) {
font-size: 30px;
color: #000000;
}
.bottom_solid {
width: 100%;
height: 10px;
background-color: #b47f4c;
position: relative;
top: -10px;
}
.logo {
position: absolute;
bottom: 90px;
left: 130px;
color: #fff;
}

View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{pluResPath}}StarRail/html/dailyNote/dailyNote.css"/>
<link rel="preload" href="{{resPath}}font/tttgbnumber.ttf" as="font">
</head>
<body id="container">
<div class="container">
<div class="title">
<div class="uid">
<div class="uid_item"><span class="uid_text">UID:</span><span class="uid_span">{{uid}}</span>
</div>
<div class="uid_item"><span class="uid_text">昵称:</span><span class="uid_span">{{nickname}}|{{level}}级</span></div>
</div>
<div class="title_date">
<div class="icon">
<img src="{{pluResPath}}StarRail/img/role/{{icon}}.webp" />
</div>
<div class="title_date_text">
<div>{{nowDay}}</div>
<div>{{day}}</div>
</div>
</div>
</div>
<div class="subject">
<div class="subject_note">开拓力:<span>{{current_stamina}}</span>/<span>{{max_stamina}}</span></div>
<div class="subject_solid"><span style="width: {{bfStamina}};"></span></div>
<div class="subject_date">
剩余回复时间:<span style="margin-left: 25px;">{{resinMaxTime}}</span>
</div>
</div>
<div class="title_wt">
<div>
委托执行({{accepted_epedition_num}}/{{total_expedition_num}})
</div>
</div>
<div class="bottom">
{{each expeditions ex}}
<div class="bottom_item">
<div class="bottom_list">
<div style="flex-grow: 1; width: 240px;">{{ex.name}}</div>
<div style="flex-grow: 1">{{ex.remaining_time==0?'已完成':ex.dateTime}}</div>
<div class="bottom_icon">
{{each ex.avatars avatars}}
{{if avatars=='派遣头像'}}
<div><img src="{{pluResPath}}StarRail/img/role/{{avatars}}.png" alt=""></div>
{{else}}
<div><img src="{{avatars}}" alt=""></div>
{{/if}}
{{/each}}
</div>
</div>
<div class="bottom_solid" style="width:{{ex.bfTime}}">
<span></span>
</div>
</div>
{{/each}}
</div>
<div class="logo"> Created By MiaoYunzai-Bot</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB