ЙажаСценарий / Говнокод #28845 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
bot.onText(/\/now/, (message) => {
    const DayOfTheWeek = new Date().toLocaleString('en-GB', { weekday: 'long' });
    const currentTime = new Date();
    let timeLeft = null;
    let currentLesson = "";

    for (let LessonId of Object.keys(lessons.v1[DayOfTheWeek])) {
        const lesson = lessons.v1[DayOfTheWeek][LessonId];
        const date = `${currentTime.getFullYear()}-${(currentTime.getMonth()+1).toString().padStart(2, '0')}-${currentTime.getDate().toString().padStart(2, '0')}`;
        const startLessonTime = new Date(`${date}T${lesson.start}:00.001Z`);
        const endLessonTime = new Date(`${date}T${lesson.end}:00.001Z`);

        if (currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) >= startLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'}) && currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) <= endLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'})) {
            currentLesson = lesson.name;timeLeft = (endLessonTime-currentTime) / 1000;
            timeLeft=timeLeft-10800+2;
            break;
        };
    };

    if (currentLesson && timeLeft) {
        const minutes = Math.floor(timeLeft / 60);
        const seconds = Math.floor(timeLeft % 60);
        bot.sendMessage(message.chat.id, `щяс урок: ${currentLesson}\nдо конца осталось ${minutes} минут ${seconds} секунд`);
    } else {
        bot.sendMessage(message.chat.id, 'Сейчас нет уроков');
    };
});

это я ночью говнокодил, ВАХхфВАХХВхаххвАХАВхаВХАХАХахвх

Запостил: qwkz1 qwkz1, (Updated )

Комментарии (0) RSS

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8