fix reset time

This commit is contained in:
bakatrouble 2019-12-02 11:44:13 +03:00
parent 890b8b4493
commit 257555242e

View File

@ -6,7 +6,7 @@ from uuid import uuid4
import humanize
import markovify
from django.db import models
from django.utils.timezone import localdate, now, make_aware
from django.utils.timezone import localdate, now, make_aware, localtime
from jsoneditor.forms import JSONEditor
from jsonfield import JSONField
from telegram import Update, Chat, User, InlineQueryResultArticle, InputTextMessageContent
@ -61,7 +61,7 @@ class CyberLinaBotModuleConfig(TelegramBotModuleConfig):
self.message_handler(update, ctx)
chat = self.chats.get(chat_id=update.effective_chat.id)
if chat.last_run and (chat.last_run >= localdate() or
chat.last_run + timedelta(1) == localdate() and now().hour < 6):
chat.last_run + timedelta(1) == localdate() and localtime().hour < 6):
humanize.i18n.activate('ru_RU')
time_left = make_aware(datetime.combine(chat.last_run + timedelta(1), time(6, 0))) - now()
return update.effective_message.reply_text(