diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100755 index 0000000..9568b22 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/nodejs/v16/.suo b/.vs/nodejs/v16/.suo new file mode 100755 index 0000000..54a1b45 Binary files /dev/null and b/.vs/nodejs/v16/.suo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100755 index 0000000..27c7855 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/README.md b/README.md index f055d15..c945d05 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,7 @@ Vanderwarker Family XMPP Bot. [![Known Vulnerabilities](https://snyk.io/test/npm/vxmppb/badge.svg)](https://snyk.io/test/npm/vxmppb) -![npm](https://img.shields.io/npm/dt/vxmppb) - -[![Build Status](https://build.vanderwarker.dev/buildStatus/icon?job=vxmppb)](https://build.vanderwarker.dev/job/vxmppb/) +![npm](https://img.shields.io/npm/dt/vxmppb) ### :book: How To Install You can install using: diff --git a/config.ini.dist b/config.ini.dist index b274dc7..f1e127e 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -1,34 +1,36 @@ -api_pass = -api_url = -api_user = -app_port = -asterisk_callfrom = -asterisk_callerID = -asterisk_context = -asterisk_host = -asterisk_password = +api_pass = +api_url = +api_user = +app_port = +asterisk_callfrom = +asterisk_callto = +asterisk_callerID = +asterisk_context = +asterisk_host = +asterisk_password = asterisk_port = -asterisk_user = -bot_hostname = -bot_jid = -bot_password = -city_code = -city_name = -gotify_api_key = -gotify_message = -gotify_priority = -gotify_title = -gotify_url = -mastodon_key = -mastodon_toot = -mastodon_url = -mqtt_message = -mqtt_password = -mqtt_server = -mqtt_topic = -mqtt_user = -rss_url = -user_jid = -user_name = -weather_api_key = -weather_units = +asterisk_user = +bot_hostname = +bot_jid = +bot_password = +city_code = +city_name = +gotify_api_key = +gotify_message = +gotify_priority = +gotify_title = +gotify_url = +mastodon_token = +mastodon_toot = +mastodon_url = +mqtt_message = +mqtt_password = +mqtt_server = +mqtt_topic = +mqtt_user = +rss_url = +user_jid = +user_name = +vfc_url = +weather_api_key = +weather_units = \ No newline at end of file diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 6a1efee..6dd9b55 --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ const api_url = config.api_url; const api_user = config.api_user; const app_port = config.app_port; const asterisk_callfrom = config.asterisk_callfrom; +const asterisk_callto = config.asterisk_callerto; const asterisk_callerID = config.asterisk_callerID; const asterisk_context = config.asterisk_context; const asterisk_host = config.asterisk_host; @@ -26,6 +27,7 @@ const asterisk_user = config.asterisk_user; const bot_hostname = config.bot_hostname; const bot_jid = config.bot_jid; const bot_password = config.bot_password; +const bot_port = config.bot_port; const city_code = config.city_code; const city_name = config.city_name; const gotify_api_key = config.gotify_api_key; @@ -42,6 +44,7 @@ const mqtt_server = config.mqtt_server; const mqtt_topic = config.mqtt_topic; const mqtt_user = config.mqtt_user; const rpc_url = config.rpc_url; +const rss_url = config.rss_url; const user_jid = config.user_jid; const user_name = config.user_name; const vfc_url = config.vfc_url; @@ -70,7 +73,7 @@ xmpp.on('chat', function(from, message) { // HELP if (message === 'help' || message === 'Help') { - xmpp.send(from, 'https://vanderwarker.family/help/xmpp#chatbot'); + xmpp.send(from, 'https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:commands'); console.log(chalk.blue('help')); } @@ -115,14 +118,14 @@ xmpp.on('chat', function(from, message) { console.log(chalk.blue('unlocks')); } - // Send VFC from coinbase to Pixel2 (Metamask) + // Check VFC balance else if (message === "vfc" || message === "Vfc") { ami.action({ 'action':'originate', 'channel':'SIP/' + asterisk_callfrom, 'context': asterisk_context, 'callerID' : asterisk_callerID, - 'exten' : '832', + 'exten' : asterisk_callto, 'priority' : '1', }); request(vfc_url, (error, res, body) => { @@ -139,7 +142,7 @@ xmpp.on('chat', function(from, message) { console.log(chalk.blue('vfc')); } - // Get latest toots (RSS) + // Get latest RSS item from feed else if (message === "rss" || message === "Rss") { (async () => { let feed = await parser.parseURL(rss_url); @@ -148,10 +151,11 @@ xmpp.on('chat', function(from, message) { console.log(item.title + ':' + item.link) xmpp.send(from, item.title) }); + xmpp.send(from, 'See https://vanderwarker.social/@stephen for full entries.') })(); } - // PING + // Ping a user to let them know you would like to communitcate else if (message === "ping" || message === 'Ping') { xmpp.send(from, "Pinging " + user_name + "! Please stand by."); xmpp.send(user_jid, from + " has pinged you!"); @@ -174,7 +178,7 @@ xmpp.on('chat', function(from, message) { }); } - // WEATHER + // Check the weather using weatherunderground API else if (message === "weather" || message === 'Weather') { xmpp.send(from, "Checking weather. Please hold...\r\n \r\n"); request(weather_url, function (err, response, body) { @@ -219,7 +223,7 @@ xmpp.on('chat', function(from, message) { console.log(chalk.blue('bye')); } - // VCARD (WIP) + // Get users vCard (WIP) else if (message === 'vcard' && from === user_jid){ xmpp.getVCard(from, function (vcard) { xmpp.send(from, vcard); @@ -227,19 +231,17 @@ xmpp.on('chat', function(from, message) { }) } - // AUTO REPLY (ALL OTHER MESSAGES) - else { - xmpp.send(from, "This is an auto replying bot. Reply \"help\" for more info."); + // If the user sends something we don't have logic for, send them info about the project + else { xmpp.send(from, "This is an auto replying bot. Reply \"help\" for more info, or https://wiki.vanderwarker.family/doku.php?id=code:vxmppb:start"); console.log(chalk.blue('autoreply')); } }); -// CATCH XMPP ERRORS +// Catch and log XMPP errors xmpp.on('error', function(err) { console.error(err); }); - // EXTENDING XEPS (WIP) /* xmpp.on('chatstate', function(from, state) { @@ -251,13 +253,13 @@ console.log(chalk.yellow(state + statusText + resource)); }); */ -// CONNECT TO XMPP! +// Alas, we connect to XMPP! xmpp.connect({ jid: bot_jid, password: bot_password, host: bot_hostname, - port: 5222 + port: bot_port }); -// CHECK FOR NEW INCOMING REQUESTS +// Checks the XMPP server for new 'friend' requests console.log(chalk.yellow(xmpp.getRoster()));