mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 12:52:50 +03:00
add telegram to callmebot (#5480)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
c6ebcc6e8e
commit
b52da08c84
@ -158,6 +158,7 @@ Once enabled, users see the new "CallMeBot" option when trying to enable messagi
|
||||
- [Signal Messenger](https://www.callmebot.com/blog/free-api-signal-send-messages/)
|
||||
- [Whatsapp](https://www.callmebot.com/blog/free-api-whatsapp-messages/)
|
||||
- [Facebook Messenger](https://www.callmebot.com/blog/free-api-facebook-messenger/)
|
||||
- [Telegram](https://www.callmebot.com/blog/telegram-text-messages/)
|
||||
|
||||
Once the user has enabled their account, they can cut & paste the CallMeBot URI into MeshCentral to validate their account.
|
||||
|
||||
|
@ -328,6 +328,9 @@ module.exports.CreateServer = function (parent) {
|
||||
} else if ((toData[0] == 'facebook') && (toData.length == 2)) {
|
||||
var url = 'https://api.callmebot.com/facebook/send.php?apikey=' + encodeURIComponent(toData[1]) + '&text=' + encodeURIComponent(msg);
|
||||
require('https').get(url, function (r) { if (func != null) { func(r.statusCode == 200); } });
|
||||
} else if ((toData[0] == 'telegram') && (toData.length == 2)) {
|
||||
var url = 'https://api.callmebot.com/text.php?user=' + encodeURIComponent(toData[1]) + '&text=' + encodeURIComponent(msg);
|
||||
require('https').get(url, function (r) { if (func != null) { func(r.statusCode == 200); } });
|
||||
}
|
||||
} else if ((to.startsWith('pushover:')) && (obj.pushoverClient != null)) { // Pushover
|
||||
const Pushover = require('node-pushover');
|
||||
@ -357,15 +360,17 @@ module.exports.CreateServer = function (parent) {
|
||||
obj.callmebotUrlToHandle = function (xurl) {
|
||||
var url = null;
|
||||
try { url = require('url').parse(xurl); } catch (ex) { return; }
|
||||
if ((url == null) || (url.host != 'api.callmebot.com') || (url.protocol != 'https:') || (url.query == null)) return;
|
||||
if ((url == null) || (url.host != 'api.callmebot.com') || (url.query == null)) return;
|
||||
var urlArgs = {}, urlArgs2 = url.query.split('&');
|
||||
for (var i in urlArgs2) { var j = urlArgs2[i].indexOf('='); if (j > 0) { urlArgs[urlArgs2[i].substring(0, j)] = urlArgs2[i].substring(j + 1); } }
|
||||
if ((urlArgs['phone'] != null) && (urlArgs['phone'].indexOf('|') >= 0)) return;
|
||||
if ((urlArgs['apikey'] != null) && (urlArgs['apikey'].indexOf('|') >= 0)) return;
|
||||
// Signal Messenger, Whatapp and Facebook
|
||||
if ((urlArgs['user'] != null) && (urlArgs['user'].indexOf('|') >= 0)) return;
|
||||
// Signal Messenger, Whatapp, Facebook and Telegram
|
||||
if (url.path.startsWith('/signal') && (urlArgs['phone'] != null) && (urlArgs['apikey'] != null)) { return 'callmebot:signal|' + urlArgs['phone'] + '|' + urlArgs['apikey']; }
|
||||
if (url.path.startsWith('/whatsapp') && (urlArgs['phone'] != null) && (urlArgs['apikey'] != null)) { return 'callmebot:whatsapp|' + urlArgs['phone'] + '|' + urlArgs['apikey']; }
|
||||
if (url.path.startsWith('/facebook') && (urlArgs['apikey'] != null)) { return 'callmebot:facebook|' + urlArgs['apikey']; }
|
||||
if (url.path.startsWith('/text') && (urlArgs['user'] != null)) { return 'callmebot:telegram|' + urlArgs['user']; }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if ((command.consent != null) && (typeof command.consent == 'number')) { if (command.consent == 0) { delete chguser.consent; } else { chguser.consent = command.consent; } change = 1; }
|
||||
if ((command.phone != null) && (typeof command.phone == 'string') && ((command.phone == '') || isPhoneNumber(command.phone))) { if (command.phone == '') { delete chguser.phone; } else { chguser.phone = command.phone; } change = 1; }
|
||||
if ((command.msghandle != null) && (typeof command.msghandle == 'string')) {
|
||||
if (command.msghandle.startsWith('callmebot:https://')) { const h = parent.parent.msgserver.callmebotUrlToHandle(command.msghandle.substring(10)); if (h) { command.msghandle = h; } else { command.msghandle = ''; } }
|
||||
if (command.msghandle.startsWith('callmebot:http')) { const h = parent.parent.msgserver.callmebotUrlToHandle(command.msghandle.substring(10)); if (h) { command.msghandle = h; } else { command.msghandle = ''; } }
|
||||
if (command.msghandle == '') { delete chguser.msghandle; } else { chguser.msghandle = command.msghandle; }
|
||||
change = 1;
|
||||
}
|
||||
|
@ -12172,7 +12172,7 @@
|
||||
x += '<tr><td>' + "Handle" + '<td><input maxlength=1024 style=width:160px;margin-left:8px id=d2handleinput onKeyUp=account_manageMessagingValidate() onkeypress="if (event.key==\'Enter\') account_manageMessagingValidate(1)">';
|
||||
x += '</table>';
|
||||
if (serverinfo.discordUrl) { x += '<div id=d2discordurl style=display:none><br /><a href=' + serverinfo.discordUrl + ' target="_discord">' + "Join this Discord server to receive notifications." + '</a></div>'; }
|
||||
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a></div>';
|
||||
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a>, <a href=https://www.callmebot.com/blog/telegram-text-messages/ target="_callmebot">' + "Telegram" + '</a></div>';
|
||||
x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
|
||||
console.log(serverinfo.userMsgNftyUrl);
|
||||
x += '<div id=d2ntfyinfo style=display:none><br /><a href="' + (serverinfo.userMsgNftyUrl ? serverinfo.userMsgNftyUrl : 'https://ntfy.sh/') + '" target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
|
||||
@ -16081,7 +16081,7 @@
|
||||
x += '<tr><td>' + "Handle" + '<td><input maxlength=1024 style=width:160px;margin-left:8px id=d2handleinput onKeyUp=p30editMessagingValidate() onkeypress="if (event.key==\'Enter\') p30editMessagingValidate(1)">';
|
||||
x += '</table>';
|
||||
if (serverinfo.discordUrl) { x += '<div id=d2discordurl style=display:none><br /><a href=' + serverinfo.discordUrl + ' target="_discord">' + "Join this Discord server to receive notifications." + '</a></div>' }
|
||||
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a></div>';
|
||||
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a>, <a href=https://www.callmebot.com/blog/telegram-text-messages/ target="_callmebot">' + "Telegram" + '</a></div>';
|
||||
x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
|
||||
x += '<div id=d2ntfyinfo style=display:none><br /><a href="' + (serverinfo.userMsgNftyUrl ? serverinfo.userMsgNftyUrl : 'https://ntfy.sh/') + '" target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
|
||||
setDialogMode(2, "Messaging Notifications", 3, p30editMessagingEx, x, 'verifyMessaging');
|
||||
|
Loading…
Reference in New Issue
Block a user