From e3f15542b17bb5ae0c50608ed137053721a6d5df Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 16 Nov 2022 11:26:47 +0100 Subject: [PATCH] add update daemon --- src/libpoketube/init/superinit.js | 47 +++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/libpoketube/init/superinit.js b/src/libpoketube/init/superinit.js index b417d412..cbd2f854 100644 --- a/src/libpoketube/init/superinit.js +++ b/src/libpoketube/init/superinit.js @@ -1,10 +1,51 @@ -function initlog(args) { - console.log("[LIBPT INTSYS] " + args); -} +const { + 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) { initlog("Starting superinit"); + 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) { initlog("https://poketube.fun/watch?v=lpiB2wMc49g"); }