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 = '\\';
- var bot = new TelegramBot(BOT_TOKEN, {polling: true});
- const testFolder = '/home/pi/pi-camera-bot/photos/';
- const fs = require('fs');
- var i = 1;
- bot.onText(/\/photo/, function (msg) {
- console.log('photo');
- takePhoto(msg);
- });
- bot.onText(/\/list/, function(msg){ //тут я вывожу список файлов в консоль
- fs.readdirSync(testFolder).forEach(file => {
- console.log(file);
- })
- })
- function takePhoto(msg) {
- setTimeout(function() {
- console.log('taking photos');
- exec('raspistill -o /home/pi/pi-camera-bot/photos/$(date +%Y-%m-%d:%k:%M:%S).jpg');
- i++;
- if (i < 4) {
- takePhoto(msg);
- }
- }, 9000)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement