Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const TelegramBot = require('node-telegram-bot-api');
- // replace the value below with the Telegram token you receive from @BotFather
- const token = '514631367:AAEWL06i_C8lxRobeGt-SY4_AGRLqyFcVmM';
- // Create a bot that uses 'polling' to fetch new updates
- const bot = new TelegramBot(token, {polling: true});
- let notes=[]
- bot.onText(/напомни (.+) в (.+)/, function (msg, match) {
- var userId = msg.from.id;
- var text = match[1];
- var time = match[2];
- notes.push( { 'uid':userId, 'time':time, 'text':text } );
- bot.sendMessage(userId, 'Отлично! Я обязательно напомню :)');
- });
- function CheckTest(){
- console.log(notes.length)
- for (var i = 0; i < notes.length; i++){
- var curDate = new Date().getHours() + ':' + new Date().getMinutes();
- if ( notes[i]['time'] == curDate ) {
- bot.sendMessage(notes[i]['uid'], 'Напоминаю, что вы должны: '+ notes[i]['text'] + ' сейчас.');
- notes.splice(i,1);
- }
- }
- setTimeout(CheckTest, 3000);
- }
- CheckTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement