Prepping for 0.1.2

This commit is contained in:
Stephen Vanderwarker 2021-12-07 16:17:31 -05:00
parent 2964a1e4c1
commit 08851d3a6b
6 changed files with 59 additions and 51 deletions

6
.vs/VSWorkspaceState.json Executable file
View File

@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}

BIN
.vs/nodejs/v16/.suo Executable file

Binary file not shown.

BIN
.vs/slnx.sqlite Executable file

Binary file not shown.

View File

@ -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:

View File

@ -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 =

32
index.js Normal file → Executable file
View File

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