diff --git a/docs/docs/messaging/index.md b/docs/docs/messaging/index.md index faf6da1f..f10b58d1 100644 --- a/docs/docs/messaging/index.md +++ b/docs/docs/messaging/index.md @@ -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. diff --git a/meshmessaging.js b/meshmessaging.js index 5d6c08cb..751814e3 100644 --- a/meshmessaging.js +++ b/meshmessaging.js @@ -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; } diff --git a/meshuser.js b/meshuser.js index 82d921cf..f389435f 100644 --- a/meshuser.js +++ b/meshuser.js @@ -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; } diff --git a/views/default.handlebars b/views/default.handlebars index b5919666..a8c3cd96 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -12172,7 +12172,7 @@ x += '