Advertisement
mistakirill

Untitled

Oct 5th, 2021
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. var TelegramBot = require('node-telegram-bot-api');
  2. var exec = require('child_process').exec;
  3. var BOT_TOKEN = 'token';
  4. var bot = new TelegramBot(BOT_TOKEN, {polling: true});
  5.  
  6. var i = 1;
  7. bot.onText(/\/photo/, function (msg) {
  8. console.log('photo');
  9. takePhoto(msg);
  10. });
  11.  
  12. function takePhoto(msg) { // create a loop function
  13. setTimeout(function() { // call a 3s setTimeout when the loop is called
  14. console.log('taking photos');
  15. exec('raspistill -o /home/pi/pi-camera-bot/photos/$(date +%Y-%m-%d:%k:%M:%S).jpg'); // your code here
  16. i++; // increment the counter
  17. if (i < 4) { // if the counter < 10, call the loop function
  18. takePhoto(msg);// .. again which will trigger another
  19. } // .. setTimeout()
  20. }, 9000)
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement