Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var TelegramBot = require('node-telegram-bot-api');
- var exec = require('child_process').exec;
- var BOT_TOKEN = 'token';
- var bot = new TelegramBot(BOT_TOKEN, {polling: true});
- var i = 1;
- bot.onText(/\/photo/, function (msg) {
- console.log('photo');
- takePhoto(msg);
- });
- function takePhoto(msg) { // create a loop function
- setTimeout(function() { // call a 3s setTimeout when the loop is called
- console.log('taking photos');
- exec('raspistill -o /home/pi/pi-camera-bot/photos/$(date +%Y-%m-%d:%k:%M:%S).jpg'); // your code here
- i++; // increment the counter
- if (i < 4) { // if the counter < 10, call the loop function
- takePhoto(msg);// .. again which will trigger another
- } // .. setTimeout()
- }, 9000)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement