diff --git a/config.ini.dist b/config.ini.dist index b274dc7..6a81efc 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -19,6 +19,10 @@ gotify_message = gotify_priority = gotify_title = gotify_url = +irc_channel = +irc_nick = +irc_sendto = +irc_server = mastodon_key = mastodon_toot = mastodon_url = diff --git a/index.js b/index.js index 6a1efee..4c7e958 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ +// Dependency requirements const chalk = require('chalk'); const d2d = require('degrees-to-direction'); 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'); @@ -11,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; @@ -33,6 +36,10 @@ 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; const mastodon_token = config.mastodon_token; const mastodon_toot = config.mastodon_toot; const mastodon_url = config.mastodon_url; @@ -48,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); @@ -55,7 +64,23 @@ 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], + 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 xmpp.on('online', function(data, to) { console.log('Connected with JID: ' + data.jid.user); @@ -64,6 +89,7 @@ xmpp.on('online', function(data, to) { 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) { 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",