forked from vxmppb/vxmppb
Prepping for 0.1.2
This commit is contained in:
parent
2964a1e4c1
commit
08851d3a6b
6
.vs/VSWorkspaceState.json
Executable file
6
.vs/VSWorkspaceState.json
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"ExpandedNodes": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"PreviewInSolutionExplorer": false
|
||||||
|
}
|
BIN
.vs/nodejs/v16/.suo
Executable file
BIN
.vs/nodejs/v16/.suo
Executable file
Binary file not shown.
BIN
.vs/slnx.sqlite
Executable file
BIN
.vs/slnx.sqlite
Executable file
Binary file not shown.
|
@ -11,8 +11,6 @@ Vanderwarker Family XMPP Bot.
|
||||||
|
|
||||||
![npm](https://img.shields.io/npm/dt/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/)
|
|
||||||
|
|
||||||
### :book: How To Install
|
### :book: How To Install
|
||||||
You can install using:
|
You can install using:
|
||||||
- [npm](https://npmjs.com/package/vxmppb)
|
- [npm](https://npmjs.com/package/vxmppb)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
api_pass =
|
api_pass =
|
||||||
api_url =
|
api_url =
|
||||||
api_user =
|
api_user =
|
||||||
app_port =
|
app_port =
|
||||||
asterisk_callfrom =
|
asterisk_callfrom =
|
||||||
|
asterisk_callto =
|
||||||
asterisk_callerID =
|
asterisk_callerID =
|
||||||
asterisk_context =
|
asterisk_context =
|
||||||
asterisk_host =
|
asterisk_host =
|
||||||
|
@ -16,10 +17,10 @@ city_code =
|
||||||
city_name =
|
city_name =
|
||||||
gotify_api_key =
|
gotify_api_key =
|
||||||
gotify_message =
|
gotify_message =
|
||||||
gotify_priority =
|
gotify_priority =
|
||||||
gotify_title =
|
gotify_title =
|
||||||
gotify_url =
|
gotify_url =
|
||||||
mastodon_key =
|
mastodon_token =
|
||||||
mastodon_toot =
|
mastodon_toot =
|
||||||
mastodon_url =
|
mastodon_url =
|
||||||
mqtt_message =
|
mqtt_message =
|
||||||
|
@ -30,5 +31,6 @@ mqtt_user =
|
||||||
rss_url =
|
rss_url =
|
||||||
user_jid =
|
user_jid =
|
||||||
user_name =
|
user_name =
|
||||||
|
vfc_url =
|
||||||
weather_api_key =
|
weather_api_key =
|
||||||
weather_units =
|
weather_units =
|
32
index.js
Normal file → Executable file
32
index.js
Normal file → Executable file
|
@ -17,6 +17,7 @@ const api_url = config.api_url;
|
||||||
const api_user = config.api_user;
|
const api_user = config.api_user;
|
||||||
const app_port = config.app_port;
|
const app_port = config.app_port;
|
||||||
const asterisk_callfrom = config.asterisk_callfrom;
|
const asterisk_callfrom = config.asterisk_callfrom;
|
||||||
|
const asterisk_callto = config.asterisk_callerto;
|
||||||
const asterisk_callerID = config.asterisk_callerID;
|
const asterisk_callerID = config.asterisk_callerID;
|
||||||
const asterisk_context = config.asterisk_context;
|
const asterisk_context = config.asterisk_context;
|
||||||
const asterisk_host = config.asterisk_host;
|
const asterisk_host = config.asterisk_host;
|
||||||
|
@ -26,6 +27,7 @@ const asterisk_user = config.asterisk_user;
|
||||||
const bot_hostname = config.bot_hostname;
|
const bot_hostname = config.bot_hostname;
|
||||||
const bot_jid = config.bot_jid;
|
const bot_jid = config.bot_jid;
|
||||||
const bot_password = config.bot_password;
|
const bot_password = config.bot_password;
|
||||||
|
const bot_port = config.bot_port;
|
||||||
const city_code = config.city_code;
|
const city_code = config.city_code;
|
||||||
const city_name = config.city_name;
|
const city_name = config.city_name;
|
||||||
const gotify_api_key = config.gotify_api_key;
|
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_topic = config.mqtt_topic;
|
||||||
const mqtt_user = config.mqtt_user;
|
const mqtt_user = config.mqtt_user;
|
||||||
const rpc_url = config.rpc_url;
|
const rpc_url = config.rpc_url;
|
||||||
|
const rss_url = config.rss_url;
|
||||||
const user_jid = config.user_jid;
|
const user_jid = config.user_jid;
|
||||||
const user_name = config.user_name;
|
const user_name = config.user_name;
|
||||||
const vfc_url = config.vfc_url;
|
const vfc_url = config.vfc_url;
|
||||||
|
@ -70,7 +73,7 @@ xmpp.on('chat', function(from, message) {
|
||||||
|
|
||||||
// HELP
|
// HELP
|
||||||
if (message === 'help' || 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'));
|
console.log(chalk.blue('help'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,14 +118,14 @@ xmpp.on('chat', function(from, message) {
|
||||||
console.log(chalk.blue('unlocks'));
|
console.log(chalk.blue('unlocks'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send VFC from coinbase to Pixel2 (Metamask)
|
// Check VFC balance
|
||||||
else if (message === "vfc" || message === "Vfc") {
|
else if (message === "vfc" || message === "Vfc") {
|
||||||
ami.action({
|
ami.action({
|
||||||
'action':'originate',
|
'action':'originate',
|
||||||
'channel':'SIP/' + asterisk_callfrom,
|
'channel':'SIP/' + asterisk_callfrom,
|
||||||
'context': asterisk_context,
|
'context': asterisk_context,
|
||||||
'callerID' : asterisk_callerID,
|
'callerID' : asterisk_callerID,
|
||||||
'exten' : '832',
|
'exten' : asterisk_callto,
|
||||||
'priority' : '1',
|
'priority' : '1',
|
||||||
});
|
});
|
||||||
request(vfc_url, (error, res, body) => {
|
request(vfc_url, (error, res, body) => {
|
||||||
|
@ -139,7 +142,7 @@ xmpp.on('chat', function(from, message) {
|
||||||
console.log(chalk.blue('vfc'));
|
console.log(chalk.blue('vfc'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get latest toots (RSS)
|
// Get latest RSS item from feed
|
||||||
else if (message === "rss" || message === "Rss") {
|
else if (message === "rss" || message === "Rss") {
|
||||||
(async () => {
|
(async () => {
|
||||||
let feed = await parser.parseURL(rss_url);
|
let feed = await parser.parseURL(rss_url);
|
||||||
|
@ -148,10 +151,11 @@ xmpp.on('chat', function(from, message) {
|
||||||
console.log(item.title + ':' + item.link)
|
console.log(item.title + ':' + item.link)
|
||||||
xmpp.send(from, item.title)
|
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') {
|
else if (message === "ping" || message === 'Ping') {
|
||||||
xmpp.send(from, "Pinging " + user_name + "! Please stand by.");
|
xmpp.send(from, "Pinging " + user_name + "! Please stand by.");
|
||||||
xmpp.send(user_jid, from + " has pinged you!");
|
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') {
|
else if (message === "weather" || message === 'Weather') {
|
||||||
xmpp.send(from, "Checking weather. Please hold...\r\n \r\n");
|
xmpp.send(from, "Checking weather. Please hold...\r\n \r\n");
|
||||||
request(weather_url, function (err, response, body) {
|
request(weather_url, function (err, response, body) {
|
||||||
|
@ -219,7 +223,7 @@ xmpp.on('chat', function(from, message) {
|
||||||
console.log(chalk.blue('bye'));
|
console.log(chalk.blue('bye'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// VCARD (WIP)
|
// Get users vCard (WIP)
|
||||||
else if (message === 'vcard' && from === user_jid){
|
else if (message === 'vcard' && from === user_jid){
|
||||||
xmpp.getVCard(from, function (vcard) {
|
xmpp.getVCard(from, function (vcard) {
|
||||||
xmpp.send(from, vcard);
|
xmpp.send(from, vcard);
|
||||||
|
@ -227,19 +231,17 @@ xmpp.on('chat', function(from, message) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AUTO REPLY (ALL OTHER MESSAGES)
|
// If the user sends something we don't have logic for, send them info about the project
|
||||||
else {
|
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");
|
||||||
xmpp.send(from, "This is an auto replying bot. Reply \"help\" for more info.");
|
|
||||||
console.log(chalk.blue('autoreply'));
|
console.log(chalk.blue('autoreply'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// CATCH XMPP ERRORS
|
// Catch and log XMPP errors
|
||||||
xmpp.on('error', function(err) {
|
xmpp.on('error', function(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// EXTENDING XEPS (WIP)
|
// EXTENDING XEPS (WIP)
|
||||||
/*
|
/*
|
||||||
xmpp.on('chatstate', function(from, state) {
|
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({
|
xmpp.connect({
|
||||||
jid: bot_jid,
|
jid: bot_jid,
|
||||||
password: bot_password,
|
password: bot_password,
|
||||||
host: bot_hostname,
|
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()));
|
console.log(chalk.yellow(xmpp.getRoster()));
|
||||||
|
|
Reference in New Issue
Block a user