Skip to content

Instantly share code, notes, and snippets.

@erayarslan
Created June 13, 2017 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erayarslan/548f8f81dbbe2259882bacbd85cdcf41 to your computer and use it in GitHub Desktop.
Save erayarslan/548f8f81dbbe2259882bacbd85cdcf41 to your computer and use it in GitHub Desktop.
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