Browse Source

add sasl

master
Agastya 9 months ago
parent
commit
40ef8ceb28
Signed by: acagastya GPG Key ID: 4BAD2B5468D346C9
2 changed files with 23 additions and 8 deletions
  1. +3
    -2
      config.js
  2. +20
    -6
      index.js

+ 3
- 2
config.js View File

@ -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",
};

+ 20
- 6
index.js View File

@ -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);
}

Loading…
Cancel
Save