diff --git a/index.js b/index.js index 8839b05..28951aa 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,6 @@ var evo = require('./evo-im.js'); var config = require('./config.json'); -evo.start({ - config: config, - logger: logger -}); - var chat_ids = {}; var options = { @@ -23,25 +18,6 @@ var options = { var bot = new telegram(config.token, options); bot.setWebHook(config.webhook_prefix + config.token, __dirname+'/crt.pem'); -function deleteChatId(from) { - delete chat_ids[from]; -} - -function updateChatId(from, chat_id) { - chat_ids[from.toLowerCase()] = chat_id; - logger.verbose('Chat id ' + chat_id + ' ' + from); -} - -function getChatId(partner) { - try { - return chat_ids[partner.toLowerCase()]; - } - catch(e) { - return; - } - -} - function sendMessage(destination, message, retry) { if (retry === null || retry === undefined) { retry = 10; @@ -65,6 +41,32 @@ function sendMessage(destination, message, retry) { setTimeout(sendMessage, 10000, destination, message, --retry); } } +} + + +evo.start({ + config: config, + logger: logger, + sendMessage: sendMessage +}); + + +function deleteChatId(from) { + delete chat_ids[from]; +} + +function updateChatId(from, chat_id) { + chat_ids[from.toLowerCase()] = chat_id; + logger.verbose('Chat id ' + chat_id + ' ' + from); +} + +function getChatId(partner) { + try { + return chat_ids[partner.toLowerCase()]; + } + catch(e) { + return; + } }