Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum 883f701359 1.1.1 2022-06-27 01:43:22 +02:00
ThePendulum 88266e5b03 Centralized logging. 2022-06-27 01:43:17 +02:00
3 changed files with 11 additions and 5 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "kanbanmod",
"version": "1.1.0",
"version": "1.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "kanbanmod",
"version": "1.1.0",
"version": "1.1.1",
"license": "ISC",
"dependencies": {
"bhttp": "^1.2.8",

View File

@ -1,6 +1,6 @@
{
"name": "kanbanmod",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -6,6 +6,10 @@ const bhttp = require('bhttp');
const reddit = new snoowrap(config.reddit);
function log(msg) {
console.log(`${new Date().toISOString()} ${msg}`);
}
async function getWekanActorNames() {
const wekanLoginRes = await bhttp.post(`${config.wekan.url}/users/login`, {
username: config.wekan.username,
@ -37,6 +41,8 @@ async function getWekanActorNames() {
}
async function init() {
log(`Retrieving current configuration from ${config.subreddit}`);
const automodConfig = await reddit.getSubreddit(config.subreddit).getWikiPage('config/automoderator').fetch();
const automodLines = automodConfig.content_md.split('\n');
const actorLineIndex = automodLines.findIndex((line) => line.includes(config.actorCommentKey)) + 1;
@ -55,14 +61,14 @@ async function init() {
reason: 'Synced kanban actor names',
});
console.log(`${new Date().toISOString()} Sync complete, resyncing in ${config.interval} minutes, set ${newActorLine}`);
log(`Sync complete, resyncing in ${config.interval} minutes, set ${newActorLine}`);
setTimeout(() => init(), config.interval * 60 * 1000);
return;
}
console.log(`${new Date().toISOString()} Sync complete, set ${newActorLine}`);
log(`Sync complete, set ${newActorLine}`);
}
init();