Created
June 13, 2017 08:05
-
-
Save erayarslan/548f8f81dbbe2259882bacbd85cdcf41 to your computer and use it in GitHub Desktop.
yesim bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bot = require('node-telegram-bot-api'); | |
var job = require('cron').CronJob; | |
var env = process.env; | |
var token = env['YESIM_TOKEN']; | |
var target = env['YESIM_USER']; | |
$bot = new bot(token, { | |
polling: true | |
}); | |
$bot.send = function (id, message, next) { | |
$bot['sendMessage'](id, message) | |
.then(function () { | |
next ? next(true) : void 0; | |
}) | |
.catch(function () { | |
next ? next(false) : void 0; | |
}); | |
}; | |
$bot.on("message", function (data) { | |
if (target === data.from['id']) { | |
console.log('[RESPONSE]', data); | |
} | |
}); | |
$job = new job('00 00 7-23/2 * * *', | |
function () { | |
$bot.send(target, 'suyunu iç suyunu zombi olcan', function (res) { | |
console.log('[' + new Date() + ']', res); | |
}); | |
}, function () { | |
}, | |
true, | |
'Europe/Istanbul' | |
); | |
console.log('[APP]', 'running!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment