Merge stephen/vxmppb #25

Merged
stephen merged 22 commits from stephen/vxmppb:main into main 2022-06-02 20:52:32 -04:00
1 changed files with 137 additions and 137 deletions
Showing only changes of commit 2462dce4f8 - Show all commits

View File

@ -17,7 +17,7 @@ try {
// check if user debugging is enabled
const debugging = config.debug;
// check if user wants phone calls with commands are run
const callme = config.calls;
const calls_enabled = config.calls;
// Asterisk config
const asterisk_callfrom = config.asterisk.callfrom;
@ -130,6 +130,19 @@ try {
// wait for incoming messages
xmpp.on('chat', function (from, message) {
// check for debugging
function call(call_data) {
if (calls_enabled === '1') {
ami.action({
'action': 'originate',
'channel': 'SIP/' + asterisk_callfrom,
'context': asterisk_context,
'callerID': asterisk_callerID,
'data': 'googletts.agi,' + call_data,
'application': 'agi'
});
}
}
function debug() {
if (debugging === '1') {
console.log('[DEBUG]');
@ -137,6 +150,7 @@ try {
console.log(from);
};
}
function resError(error, res) {
if (!error && res.statusCode == 401) {
console.log('Invalid credentials');
@ -186,6 +200,7 @@ try {
var unlockBodyMatch = body.match(unlockBody);
const unlockFinalMessage = user_name + " has " + unlockBodyMatch[1] + " unlocks for " + n;
xmpp.send(from, unlockFinalMessage);
call(unlockFinalMessage);
}
resError(error, res);
});
@ -376,14 +391,8 @@ try {
}
});
// call admin alerting of authors ping
ami.action({
'action': 'originate',
'channel': 'SIP/' + asterisk_callfrom,
'context': asterisk_context,
'callerID': asterisk_callerID,
'data': 'googletts.agi, \"hello. ' + from + ' has pinged you!\"',
'application': 'agi'
});
call_data = "hello. " + from + " has pinged you!"
call(call_data);
debug();
}
@ -409,15 +418,7 @@ try {
// send weather to xmpp admin
xmpp.send(from, wm);
// call admin with latest weather report
ami.action({
'action':'originate',
'channel':'SIP/' + asterisk_callfrom,
'context': asterisk_context,
'callerID' : asterisk_callerID,
'data': 'googletts.agi,' + wm,
'application': 'agi'
});
call(wm);
}
});
debug();
@ -436,7 +437,6 @@ try {
// secion from config.ini
// Please note this section requires you to have an Ejabberd server.
// I am welcome to pull requests for other servers (maybe set type in config.ini)
else if (message === '!meet') {
if (from != user_jid) {
xmpp.send(from, pc);