From ab9f15bf1574f6545f4d82fff135c34d290feaa9 Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <me@adhisimon.org> Date: Thu, 21 Jul 2016 14:50:43 +0700 Subject: [PATCH] sendMessage start --- index.js | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) 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; + } } -- 1.9.0