-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: 二枣子 <[email protected]>
- Loading branch information
Showing
70 changed files
with
488 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import plugin from '../../../lib/plugins/plugin.js' | ||
import WeightCalculator from '../utils/Calculate.js' | ||
import Waves from "../components/Code.js"; | ||
import Config from "../components/Config.js"; | ||
import Render from '../model/render.js' | ||
|
||
export class Training extends plugin { | ||
constructor() { | ||
super({ | ||
name: "鸣潮-练度统计", | ||
event: "message", | ||
priority: 1009, | ||
rule: [ | ||
{ | ||
reg: "^(~|~|鸣潮)练度(统计)?(\\d{9})?$", | ||
fnc: "training" | ||
} | ||
] | ||
}) | ||
} | ||
|
||
async training(e) { | ||
|
||
if (e.at) e.user_id = e.at; | ||
let accountList = JSON.parse(await redis.get(`Yunzai:waves:users:${e.user_id}`)) || await Config.getUserConfig(e.user_id); | ||
const waves = new Waves(); | ||
|
||
const match = e.msg.match(/\d{9}$/); | ||
|
||
if (!accountList.length) { | ||
if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { | ||
let publicCookie = await waves.pubCookie(); | ||
if (!publicCookie) { | ||
return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行登录'); | ||
} else { | ||
if (match) { | ||
publicCookie.roleId = match[0]; | ||
await redis.set(`Yunzai:waves:bind:${e.user_id}`, publicCookie.roleId); | ||
} else if (await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { | ||
publicCookie.roleId = await redis.get(`Yunzai:waves:bind:${e.user_id}`); | ||
} | ||
accountList.push(publicCookie); | ||
} | ||
} else { | ||
return await e.reply('当前没有登录任何账号,请使用[~登录]进行登录'); | ||
} | ||
} | ||
|
||
let data = []; | ||
let deleteroleId = []; | ||
|
||
await Promise.all(accountList.map(async (account) => { | ||
const usability = await waves.isAvailable(account.token); | ||
|
||
if (!usability) { | ||
data.push({ message: `账号 ${account.roleId} 的Token已失效\n请重新登录Token` }); | ||
deleteroleId.push(account.roleId); | ||
return; | ||
} | ||
|
||
if (match) { | ||
account.roleId = match[0]; | ||
await redis.set(`Yunzai:waves:bind:${e.user_id}`, account.roleId); | ||
} | ||
|
||
const [baseData, roleData] = await Promise.all([ | ||
waves.getBaseData(account.serverId, account.roleId, account.token), | ||
waves.getRoleData(account.serverId, account.roleId, account.token) | ||
]); | ||
|
||
if (!baseData.status || !roleData.status) { | ||
data.push({ message: baseData.msg || roleData.msg }); | ||
return; | ||
} | ||
|
||
const Promises = roleData.data.roleList.map(role => | ||
waves.getRoleDetail(account.serverId, account.roleId, role.roleId, account.token).then(data => | ||
data.status && data.data.role ? { ...role, ...data.data } : null | ||
) | ||
); | ||
|
||
const roleList = (await Promise.all(Promises)).filter(Boolean).map(role => { | ||
const calculatedRole = new WeightCalculator(role).calculate(); | ||
calculatedRole.chainCount = calculatedRole.chainList.filter(chain => chain.unlocked).length; | ||
return calculatedRole; | ||
}); | ||
|
||
roleList.sort((a, b) => b.starLevel - a.starLevel || b.phantomData.statistic.totalScore - a.phantomData.statistic.totalScore); | ||
|
||
const imageCard = await Render.Training(baseData.data, roleList); | ||
data.push({ message: imageCard }); | ||
})); | ||
|
||
if (deleteroleId.length) { | ||
let newAccountList = accountList.filter(account => !deleteroleId.includes(account.roleId)); | ||
Config.setUserConfig(e.user_id, newAccountList); | ||
} | ||
|
||
if (data.length === 1) { | ||
await e.reply(data[0].message); | ||
return true; | ||
} | ||
|
||
await e.reply(Bot.makeForwardMsg([{ message: `用户 ${e.user_id}` }, ...data])); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,7 +185,6 @@ li>div>img { | |
} | ||
|
||
.progress-bar { | ||
background: #cdb56b; | ||
height: 100%; | ||
width: var(--width); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.