Fix incoming telegram bot issues
It seems that some emojis from telegram throw an error in the bot script in the incoming webhook integration for the faircoop-assemblies channel https://fairchat.net/admin/integrations/incoming/52xC7gTbv7nnjPLjQ (which people want use on fairchat for translations).
[34mI20180215-20:51:18.194(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error [Stack:]
[34mI20180215-20:51:18.198(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error script.js:1 function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Script=function(){function Script(){_classCallCheck(this,Script)}Script.prototype.process_incoming_request=function process_incoming_request(_ref){var request=_ref.request;if("edited_message"in request.content){request.content.message=request.content.edited_message}var who=request.content.message.from.username;var icon_url="/avatar/"+request.content.message.from.username+".jpg";if(!who){who=request.content.message.from.first_name+" "+request.content.message.from.last_name;icon_url="/avatar/"+request.content.message.from.first_name+".jpg"}var body=request.content.message.text;if(!body){if(request.content.message.sticker.emoji){body=request.content.message.sticker.emoji}else{return{}}}return{content:{username:who,icon_url:icon_url,text:body}}};return Script}(); TypeError: Cannot read property 'emoji' of undefined at Script.process_incoming_request (script.js:1:776) at evalmachine.<anonymous>:1:8 at ContextifyScript.Script.runInContext (vm.js:59:29) at ContextifyScript.Script.runInNewContext (vm.js:65:15) at Object.runInNewContext (vm.js:135:38) at Object.executeIntegrationRest [as action] (meteor://💻app/packages/rocketchat_integrations.js:2377:22) at Route.share.Route.Route._callEndpoint (meteor://💻app/packages/nimble_restivus.js:358:32) at meteor://💻app/packages/nimble_restivus.js:247:33 at packages/simple_json-routes.js:98:9
[34mI20180215-20:51:18.630(1) rocketchat_logger.js:278 [34mIntegrations ➔ Incoming WebHook.info Invalid integration id pXdjbxNnw5bf42Liy or token nvwFhaYNZDZp37aejgPZLrEpwJdG3sy92T5xgv5FNCRp5MQQ
[34mI20180215-20:51:22.806(1) rocketchat_logger.js:278 [34mIntegrations ➔ Incoming WebHook.info Post integration: ask-faircoop-welcome
[34mI20180215-20:51:22.808(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error [Error running Script in Trigger ask-faircoop-welcome :]
[34mI20180215-20:51:22.809(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Script=function(){function Script(){_classCallCheck(this,Script)}Script.prototype.process_incoming_request=function process_incoming_request(_ref){var request=_ref.request;if("edited_message"in request.content){request.content.message=request.content.edited_message}var who=request.content.message.from.username;var icon_url="/avatar/"+request.content.message.from.username+".jpg";if(!who){who=request.content.message.from.first_name+" "+request.content.message.from.last_name;icon_url="/avatar/"+request.content.message.from.first_name+".jpg"}var body=request.content.message.text;if(!body){if(request.content.message.sticker.emoji){body=request.content.message.sticker.emoji}else{return{}}}return{content:{username:who,icon_url:icon_url,text:body}}};return Script}();
[34mI20180215-20:51:22.810(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error [Stack:]
[34mI20180215-20:51:22.816(1) rocketchat_logger rocketchat_logger.js:278 [31mIntegrations ➔ Incoming WebHook.error script.js:1 function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Script=function(){function Script(){_classCallCheck(this,Script)}Script.prototype.process_incoming_request=function process_incoming_request(_ref){var request=_ref.request;if("edited_message"in request.content){request.content.message=request.content.edited_message}var who=request.content.message.from.username;var icon_url="/avatar/"+request.content.message.from.username+".jpg";if(!who){who=request.content.message.from.first_name+" "+request.content.message.from.last_name;icon_url="/avatar/"+request.content.message.from.first_name+".jpg"}var body=request.content.message.text;if(!body){if(request.content.message.sticker.emoji){body=request.content.message.sticker.emoji}else{return{}}}return{content:{username:who,icon_url:icon_url,text:body}}};return Script}();