add update daemon

This commit is contained in:
Ashley 2022-11-16 11:26:47 +01:00
parent b9fba1e5a5
commit 5efce6698b

View file

@ -1,10 +1,51 @@
function initlog(args) { const {
console.log("[LIBPT INTSYS] " + args); fetcher,
} core,
wiki,
musicInfo,
modules,
version,
initlog,
} = require("../libpoketube-initsys.js");
const {
IsJsonString,
convert,
getFirstLine,
capitalizeFirstLetter,
turntomins,
getRandomInt,
getRandomArbitrary,
} = require("../ptutils/libpt-coreutils.js");
const { api } = require("../init/pages-api.js");
function init(app, config, rendertemplate) { function init(app, config, rendertemplate) {
initlog("Starting superinit"); initlog("Starting superinit");
initlog("[START] Load pages"); initlog("[START] Load pages");
/* PokeTube Update daemon - checks for updates in poketube */
(async () => {
const url = `https://poketube.fun/api/version.json`;
let f = await modules
.fetch(url)
.then((res) => res.text())
.then((json) => JSON.parse(json));
if (f.pt_version == api) {
console.log("[UPDATE DAEMON] PokeTube is up to date!");
}
if (f.pt_version != api) {
console.warn(
"[UPDATE DAEMON] PokeTube is out of date! please re-clone the poketube repo :p "
);
}
})();
if (Math.random() < 0.5) { if (Math.random() < 0.5) {
initlog("https://poketube.fun/watch?v=lpiB2wMc49g"); initlog("https://poketube.fun/watch?v=lpiB2wMc49g");
} }