Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
yesim bot
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