telebot
telebot copied to clipboard
Cron or timer event and autopost
Hi,
Is possible to make a function that executes at some hours (for ejemple, 17:00:00) to some group? Without previous event, like chat or something.
Thank you!
Well, maybe it's useful for anyone, i have made it with node schedule
var schedule = require('/***/node_modules/node-schedule/lib/schedule.js');
var j = schedule.scheduleJob('10 * * * *', function(){
var data;
var data2;
var rawData;
rawData = fs.readFileSync('/home/***.txt', 'utf8');
if(rawData==null) {
return console.log(err);
}
data = rawData.split('\n');
function randomInt (low, high) {
return Math.floor(Math.random() * (high - low) + low);
}
data2 = data[randomInt(0,data.length -1)];
bot.sendMessage('-XXXXX (group id)', 'Text: '+ data2);
});
Great idea for a new plugin (:
@CarlosLopezES did you had any issues with Telegram limitations on sending messagess ?
Not at all, but our bot send maybe less tan 100 messages by day
Got it - thanks!