enwnbot

Converts MediaWiki [[links]] and {{templates}} to links on IRC
git clone http://git.hanabi.in/repos/enwnbot.git
Log | Files | Refs | README | LICENSE

commit 66da489988d9ab526d7e91506b2ce9e2b9132b5d
parent 4cf77430d5ddcf4548fd34dfd083c921d28f5544
Author: Agastya Chandrakant <acagastya@outlook.com>
Date:   Sun, 31 May 2020 08:56:27 +0530

say titles of submitted articles

Diffstat:
Mirc.js | 25++++++++++++++++++-------
MpromUrlShortener.js | 2+-
2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/irc.js b/irc.js @@ -64,11 +64,17 @@ async function announceRQ(sender, channel) { } } -async function sayShortUrls(urlList, channel) { +async function sayShortUrls(urlList, channel, titles = []) { const shortUrls = await Promise.all(urlList.map(short)); - shortUrls.forEach(({ url, err }) => { - if (!err) client.say(channel, url); - }); + if (titles.length == 0) { + shortUrls.forEach(({ url, err }) => { + if (!err) client.say(channel, url); + }); + } else { + shortUrls.forEach(({ url, err }, idx) => { + if (!err) client.say(channel, `${url} -- ${titles[idx]}`); + }); + } } function groupChat(sender, channel, msg) { @@ -112,11 +118,16 @@ async function announceSubmitted() { const prepped = yetToAnnounce.map(fullUrl); if (prepped.length) { channels.forEach((channel) => client.say(channel, 'Submitted for review:')); - channels.forEach((channel) => sayShortUrls(prepped, channel)); + channels.forEach((channel) => + sayShortUrls(prepped, channel, yetToAnnounce) + ); } } -setInterval(announceSubmitted, 5 * 60 * 1000); +const submittedPeriod = 5 * 60 * 1000; +const cacheClearPeriod = 6 * 60 * 60 * 1000; + +setInterval(announceSubmitted, submittedPeriod); setInterval(() => { submittedState.announced = []; -}, 6 * 60 * 60 * 1000); +}, cacheClearPeriod); diff --git a/promUrlShortener.js b/promUrlShortener.js @@ -113,7 +113,7 @@ async function main() { main(); async function short(URI) { - console.log(globalState, botAccount, botPass); + console.log(globalState); if (!globalState.mainExecuted) main(); if (!URI) URI =