salien-script-js
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "salien-script-js", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Scripting the Steam Salien Sale minigame, the proper way.", | ||
@@ -53,3 +53,4 @@ "keywords": [ | ||
"fetch-retry": "^1.2.1", | ||
"meow": "^5.0.0" | ||
"meow": "^5.0.0", | ||
"update-check": "^1.5.2" | ||
}, | ||
@@ -56,0 +57,0 @@ "devDependencies": { |
@@ -18,2 +18,3 @@ # salien-script-js | ||
* Easy to install, run and update 🎉 | ||
* Update checker and log notifications ✉️ | ||
* Same logic as the [PHP version](https://github.com/SteamDatabase/SalienCheat) (we almost have parity) 👽 | ||
@@ -20,0 +21,0 @@ * Pick your own steam group 👌 |
@@ -29,4 +29,5 @@ /** | ||
const fetch = require('fetch-retry'); | ||
const checkForUpdate = require('update-check'); | ||
const { version: pkgVersion } = require('../package.json'); | ||
const pkg = require('../package.json'); | ||
@@ -89,2 +90,22 @@ const logger = (name, ...messages) => { | ||
const updateCheck = async (name, pauseLog) => { | ||
let hasUpdate = null; | ||
try { | ||
hasUpdate = await checkForUpdate(pkg); | ||
this.isUpdateChecked = true; | ||
} catch (err) { | ||
logger(name, ` ${chalk.bgRed(' UpdateCheck ')}`, chalk.red(`Failed to check for updates: ${err}`)); | ||
} | ||
if (hasUpdate) { | ||
logger(name, ` ${chalk.bgMagenta(' UpdateCheck ')}`, `The latest version is ${hasUpdate.latest}. Please update.`); | ||
} | ||
if (pauseLog) { | ||
// pause for 3 seconds after update check | ||
await delay(3000); | ||
} | ||
}; | ||
class SalienScriptException { | ||
@@ -117,2 +138,3 @@ constructor(message) { | ||
this.hasJoinedClan = false; | ||
this.isUpdateChecked = false; | ||
@@ -284,3 +306,3 @@ this.currentPlanetId = null; | ||
if (clanCheckInfo.clan_info) { | ||
logger(this.name, ` ${chalk.bgCyan(`Joined group: ${clanCheckInfo.clan_info.name}`)}`); | ||
logger(this.name, ` ${chalk.bgCyan(` Joined group: ${clanCheckInfo.clan_info.name} `)}`); | ||
logger( | ||
@@ -596,2 +618,4 @@ this.name, | ||
await updateCheck(this.name); | ||
// Scan planets every 10 minutes | ||
@@ -614,3 +638,3 @@ if (new Date().getTime() - this.startTime > 600000) { | ||
const { hardZones, mediumZones, planetCaptured, planetPlayers } = zone; | ||
const { hardZones, mediumZones, easyZones, planetCaptured, planetPlayers } = zone; | ||
@@ -654,2 +678,3 @@ if (!hardZones) { | ||
planetLogMsg += ` - Hard: ${chalk.yellow(hardZones)} - Medium: ${chalk.yellow(mediumZones)}`; | ||
planetLogMsg += ` - Easy: ${chalk.yellow(easyZones)}`; | ||
planetLogMsg += ` - Players: ${chalk.yellow(planetPlayers.toLocaleString())} (${chalk.green(planetName)})`; | ||
@@ -674,3 +699,3 @@ | ||
logger(this.name, ` ${chalk.bgMagenta(`Waiting ${this.waitTime} seconds for round to finish...`)}`); | ||
logger(this.name, ` ${chalk.bgMagenta(` Waiting ${this.waitTime} seconds for round to finish... `)}`); | ||
@@ -687,3 +712,3 @@ await delay(this.waitTime * 1000); | ||
currentLevelMsg += ` (${chalk.yellow(report.old_score.toLocaleString())} XP`; | ||
currentLevelMsg += `=> ${chalk.green(report.new_score.toLocaleString())} XP)`; | ||
currentLevelMsg += ` => ${chalk.green(report.new_score.toLocaleString())} XP)`; | ||
currentLevelMsg += ` - Current Level: ${chalk.green(report.new_level)} (${nextLevelPercent}% to next)`; | ||
@@ -702,3 +727,3 @@ | ||
let nextLevelMsg = `>> Next Level: ${chalk.yellow(report.next_level_score.toLocaleString())} XP`; | ||
nextLevelMsg += `- Remaining: ${chalk.yellow(remainingXp.toLocaleString())} XP - ETA: ${chalk.green(levelEta)}`; | ||
nextLevelMsg += ` - Remaining: ${chalk.yellow(remainingXp.toLocaleString())} XP - ETA: ${chalk.green(levelEta)}`; | ||
@@ -730,3 +755,7 @@ logger(this.name, nextLevelMsg); | ||
try { | ||
logger(this.name, ` ${chalk.bgGreen(` Started SalienScript | Version: ${pkgVersion} `)}`); | ||
logger(this.name, ` ${chalk.bgGreen(` Started SalienScript | Version: ${pkg.version} `)}`); | ||
logger( | ||
this.name, | ||
` ${chalk.bgCyan(` If you appreciate the script, please remember to leave a ⭐ star ⭐ on the project! `)}`, | ||
); | ||
@@ -746,3 +775,3 @@ await this.setupGame(); | ||
logger(this.name, ` ${chalk.bgMagenta(`Script will restart in ${this.defaultDelaySec} seconds...`)}\n\n`); | ||
logger(this.name, ` ${chalk.bgMagenta(` Script will restart in ${this.defaultDelaySec} seconds... `)}\n\n`); | ||
@@ -749,0 +778,0 @@ await delay(this.defaultDelayMs); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28630
648
94
6
+ Addedupdate-check@^1.5.2
+ Addeddeep-extend@0.6.0(transitive)
+ Addedini@1.3.8(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedregistry-auth-token@3.3.2(transitive)
+ Addedregistry-url@3.1.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedupdate-check@1.5.4(transitive)