timebot

Convert live time across time-zones on IRC
git clone http://git.hanabi.in/repos/timebot.git
Log | Files | Refs | LICENSE

commit 40ef8ceb28466b838635cb0f6b8d07bf41c1082b
parent c4f93c4836cd4d4b613436186ae9530a799ef113
Author: Agastya Chandrakant <me@hanabi.in>
Date:   Wed, 24 Feb 2021 09:26:38 +0530

add sasl

Diffstat:
Mconfig.js | 5+++--
Mindex.js | 26++++++++++++++++++++------
2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/config.js b/config.js @@ -1,6 +1,7 @@ module.exports = { channels: ["##nie"], - server: "irc.freenode.net", maintainers: ["acagastya"], - nick: "timebot" + nick: "timebot", + password: "bots-irc-password", + server: "irc.freenode.net", }; diff --git a/index.js b/index.js @@ -6,13 +6,27 @@ const moment = require("moment-timezone"); const irc = require("irc"); // local imports -const { channels, server, nick, maintainers } = require("./config.js"); +const { + channels, + maintainers, + nick, + password, + server, +} = require("./config.js"); // constants const FILE = "./alias.json"; let alias = JSON.parse(fs.readFileSync(FILE)); -const ircClient = new irc.Client(server, nick, { channels }); +const ircClient = new irc.Client(server, nick, { + channels, + userName: "timebot", + realName: "timebot", + sasl: true, + password, + floodProtection: true, + floodProtectionDelay: 1000, +}); // irc event-listeners ircClient.addListener("error", errorHandler); @@ -60,7 +74,7 @@ function addAlias(sender, channel, msg) { fs.writeFileSync( FILE, JSON.stringify(Object.assign({}, alias), null, 2) + "\n", - err => { + (err) => { if (err) { ircClient.say(channel, `Error occurred: ${err}`); delete alias[key]; @@ -85,7 +99,7 @@ function deleteAlias(sender, channel, msg) { fs.writeFileSync( FILE, JSON.stringify(Object.assign({}, alias), null, 2) + "\n", - err => { + (err) => { if (err) { ircClient.say(channel, `Error occurred: ${err}`); if (val) alias[key] = val; @@ -125,9 +139,9 @@ function showHelp(channel) { function showList(sender, msg) { const reg = new RegExp(`${nick}:? ls (.*)`); const zone = msg.match(reg)[1].toLowerCase(); - const allZones = moment.tz.names().map(el => el.replace(/_/g, " ")); + const allZones = moment.tz.names().map((el) => el.replace(/_/g, " ")); const res = allZones - .filter(el => el.toLowerCase().includes(zone)) + .filter((el) => el.toLowerCase().includes(zone)) .join(", "); ircClient.say(sender, res); }