mardi 10 octobre 2017

Telegram Bot Random Images (How to send random images with Telegram-Bot)

const TeleBot = require('telebot');


const bot = new TeleBot({
token: 'i9NhrhCQGq7rxaA' // Telegram Bot API token.
});

bot.on(/^([Hh]ey|[Hh]oi|[Hh]a*i)$/, function (msg) {
return bot.sendMessage(msg.from.id, "Hello Commander");
});

var Historiepics = ['Schoolfotos/grr.jpg', 'Schoolfotos/boe.jpg', 
'Schoolfotos/tobinsexy.jpg'];


console.log('Historiepics')
console.log(Math.floor(Math.random() * Historiepics.length));
var foto = Historiepics[(Math.floor(Math.random() * Historiepics.length))];

bot.on(/aap/, (msg) => {
return bot.sendPhoto(msg.from.id, foto);
});



bot.start();

The result I'm getting from this is just one picture everytime, but if I ask for another random picture it keeps showing me the same one without change.




Aucun commentaire:

Enregistrer un commentaire