From 31589297b94ac3b7ce63b3f8dbd9a90b86572e71 Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 21 Jun 2021 17:49:00 -0400 Subject: [PATCH 1/6] requiring IRC, and setting up config. --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 6a1efee..0b75b2e 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const express = require('express') const app = express(); const fs = require('fs'); const ini = require('ini'); +const irc = require('irc'); const mastodon = require('mastodon'); const mqtt = require('mqtt'); const request = require('request'); @@ -33,6 +34,8 @@ const gotify_message = config.gotify_message; const gotify_priority = config.gotify_priority; const gotify_title = config.gotify_title; const gotify_url = config.gotify_url; +const irc_nick = config.irc_nick; +const irc_server = config.irc_server; const mastodon_token = config.mastodon_token; const mastodon_toot = config.mastodon_toot; const mastodon_url = config.mastodon_url; -- 2.25.1 From 1e4a0cd29d93eb6ff1cdeb9cb21e60c861aacb2f Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 21 Jun 2021 17:51:13 -0400 Subject: [PATCH 2/6] Adding all to config.ini, and sendto to index.js --- config.ini.dist | 3 +++ index.js | 1 + 2 files changed, 4 insertions(+) diff --git a/config.ini.dist b/config.ini.dist index b274dc7..42ac44b 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -19,6 +19,9 @@ gotify_message = gotify_priority = gotify_title = gotify_url = +irc_nick = +irc_sendto = +irc_server = mastodon_key = mastodon_toot = mastodon_url = diff --git a/index.js b/index.js index 0b75b2e..66acf7b 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,7 @@ const gotify_priority = config.gotify_priority; const gotify_title = config.gotify_title; const gotify_url = config.gotify_url; const irc_nick = config.irc_nick; +const irc_sendto = config.irc_sendto; const irc_server = config.irc_server; const mastodon_token = config.mastodon_token; const mastodon_toot = config.mastodon_toot; -- 2.25.1 From 32c368da38c75591853e28d4ce52419e45f7dfac Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 21 Jun 2021 17:52:43 -0400 Subject: [PATCH 3/6] Adding irc to package.json --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 0792ba0..fea2079 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "keywords": [ "xmpp", "bot", + "irc", "sms", "autoreply", "asterisk", @@ -26,6 +27,7 @@ "degrees-to-direction": "1.1.1", "express": "4.17.1", "ini": "2.0.0", + "irc": "0.5.2", "mastodon": "1.2.2", "mqtt": "4.2.6", "request": "2.88.0", -- 2.25.1 From 8eae3b335e3df8fd004e7884b7ef1b4eb66e7e17 Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 21 Jun 2021 18:21:28 -0400 Subject: [PATCH 4/6] Adding irc_channel, and sending message on connect. --- config.ini.dist | 1 + index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config.ini.dist b/config.ini.dist index 42ac44b..6a81efc 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -19,6 +19,7 @@ gotify_message = gotify_priority = gotify_title = gotify_url = +irc_channel = irc_nick = irc_sendto = irc_server = diff --git a/index.js b/index.js index 66acf7b..c3e9a84 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +// Dependency requirements const chalk = require('chalk'); const d2d = require('degrees-to-direction'); const express = require('express') @@ -12,6 +13,7 @@ let Parser = require('rss-parser'); let parser = new Parser(); const xmpp = require('simple-xmpp'); +// Setup config.ini const config = ini.parse(fs.readFileSync('./config.ini', 'utf-8')); const api_pass = config.api_pass; const api_url = config.api_url; @@ -34,6 +36,7 @@ const gotify_message = config.gotify_message; const gotify_priority = config.gotify_priority; const gotify_title = config.gotify_title; const gotify_url = config.gotify_url; +const irc_channel = config.irc_channel; const irc_nick = config.irc_nick; const irc_sendto = config.irc_sendto; const irc_server = config.irc_server; @@ -52,6 +55,8 @@ const vfc_url = config.vfc_url; const weather_api_key = config.weather_api_key; const weather_units = config.weather_units; + +// Initial setup var ami = new require('asterisk-manager')(asterisk_port, asterisk_host, asterisk_user, asterisk_password, false); let weather_url = `https://api.openweathermap.org/data/2.5/weather?id=${city_code}&appid=${weather_api_key}&units=${weather_units}` var client = mqtt.connect('tcp://' + mqtt_user + ':' + mqtt_password + '@' + mqtt_server); @@ -59,12 +64,18 @@ var M = new mastodon({ access_token: `${mastodon_token}`, timeout_ms: 60*1000, api_url: `${mastodon_url}`, -}) +}); +var iclient = new irc.Client('${irc_server}', '${irc_nick}', { + channels: ['${irc_channel}'], +}); + // Once we're online, we'll send a message alerting admins xmpp.on('online', function(data, to) { console.log('Connected with JID: ' + data.jid.user); xmpp.send(user_jid, "[ONLINE]", false); client.publish(mqtt_topic, mqtt_message); + iclient.join('${irc_channel}'); + iclient.say('${irc_channel}', '[ONLINE]'); M.post('statuses', { status: `${mastodon_toot}` }); app.get('/', (req, res) => res.send("Bot Online!

Bot Online!

")); app.listen(app_port, () => console.log(`Listening on ${app_port}!`)); -- 2.25.1 From e2fbd57e418c7318974bd5aa4a7db7e4e6c96e44 Mon Sep 17 00:00:00 2001 From: stephen Date: Mon, 21 Jun 2021 20:24:32 -0400 Subject: [PATCH 5/6] Changed vars. See #3 --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c3e9a84..8c5a00d 100644 --- a/index.js +++ b/index.js @@ -65,8 +65,8 @@ var M = new mastodon({ timeout_ms: 60*1000, api_url: `${mastodon_url}`, }); -var iclient = new irc.Client('${irc_server}', '${irc_nick}', { - channels: ['${irc_channel}'], +var iclient = new irc.Client(irc_server, irc_nick, { + channels: [irc_channel], }); // Once we're online, we'll send a message alerting admins @@ -74,8 +74,8 @@ xmpp.on('online', function(data, to) { console.log('Connected with JID: ' + data.jid.user); xmpp.send(user_jid, "[ONLINE]", false); client.publish(mqtt_topic, mqtt_message); - iclient.join('${irc_channel}'); - iclient.say('${irc_channel}', '[ONLINE]'); + iclient.join(irc_channel); + iclient.say(irc_channel, '[ONLINE]'); M.post('statuses', { status: `${mastodon_toot}` }); app.get('/', (req, res) => res.send("Bot Online!

Bot Online!

")); app.listen(app_port, () => console.log(`Listening on ${app_port}!`)); -- 2.25.1 From f23678713ae0bfee9936a9dcfa55cae2c2047a90 Mon Sep 17 00:00:00 2001 From: stephen Date: Tue, 10 Aug 2021 20:38:45 -0400 Subject: [PATCH 6/6] Reverting to pre-irc --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8c5a00d..4c7e958 100644 --- a/index.js +++ b/index.js @@ -67,6 +67,18 @@ var M = new mastodon({ }); var iclient = new irc.Client(irc_server, irc_nick, { channels: [irc_channel], + userName: 'vxmppb', + realName: 'nodeJS IRC vXMPPb', + debug: 'true', + secure: 'true', + port: '6697', + selfSigned: true, + certExpired: true, + webirc: { + pass: '', + ip: '', + host: '' + }, }); // Once we're online, we'll send a message alerting admins @@ -74,11 +86,10 @@ xmpp.on('online', function(data, to) { console.log('Connected with JID: ' + data.jid.user); xmpp.send(user_jid, "[ONLINE]", false); client.publish(mqtt_topic, mqtt_message); - iclient.join(irc_channel); - iclient.say(irc_channel, '[ONLINE]'); M.post('statuses', { status: `${mastodon_toot}` }); app.get('/', (req, res) => res.send("Bot Online!

Bot Online!

")); app.listen(app_port, () => console.log(`Listening on ${app_port}!`)); + iclient.say(irc_sendto, '[ONLINE]'); }); xmpp.on('chat', function(from, message) { -- 2.25.1