reqs
This commit is contained in:
parent
0bfc217b78
commit
4083714739
@ -1,14 +1,12 @@
|
||||
import datetime
|
||||
|
||||
import croniter
|
||||
import pytz
|
||||
from telebot.types import Message
|
||||
|
||||
from daemons.bot import bot
|
||||
from daemons.fetch import fetch_schedule_for_user
|
||||
from helpers import now
|
||||
from helpers.keyboards import main_keyboard, notify_keyboard, yes_no_keyboard, again_keyboard, groups_keyboard, \
|
||||
no_daily_notify
|
||||
from helpers.keyboards import main_keyboard, notify_keyboard, yes_no_keyboard, again_keyboard, groups_keyboard
|
||||
from helpers.models import UserSchema, User
|
||||
from helpers.mongo import mongo
|
||||
from helpers.ruz import ruz
|
||||
@ -18,21 +16,9 @@ class BaseAnswer:
|
||||
def process(self, message: Message):
|
||||
user = mongo.users_collection.find_one({"chat_id": message.chat.id})
|
||||
if user is None:
|
||||
cron = croniter.croniter("0 9 * * *", now())
|
||||
next_date = cron.get_next(datetime.datetime)
|
||||
next_date = next_date.replace(tzinfo=pytz.timezone('Europe/Moscow'))
|
||||
user = User(chat_id=message.chat.id, next_notify_time=next_date)
|
||||
user = User(chat_id=message.chat.id)
|
||||
mongo.users_collection.insert_one(UserSchema().dump(user))
|
||||
else:
|
||||
if "next_notify_time" not in user:
|
||||
cron = croniter.croniter("0 9 * * *", now())
|
||||
next_date = cron.get_next(datetime.datetime)
|
||||
next_date = next_date.replace(tzinfo=pytz.timezone('Europe/Moscow'))
|
||||
user["next_notify_time"] = next_date
|
||||
mongo.users_collection.update_one(
|
||||
{"chat_id": message.chat.id},
|
||||
{"$set": {"next_notify_time": next_date}}
|
||||
)
|
||||
user = UserSchema().load(user)
|
||||
attr = getattr(self, "handle_state_" + user.state, None)
|
||||
if attr is None:
|
||||
|
@ -8,7 +8,10 @@ packaging==21.3
|
||||
pymongo==4.2.0
|
||||
pyparsing==3.0.9
|
||||
pyTelegramBotAPI==4.1.1
|
||||
python-dateutil==2.8.2
|
||||
pytz==2022.5
|
||||
requests==2.28.1
|
||||
six==1.16.0
|
||||
typing-inspect==0.8.0
|
||||
typing_extensions==4.4.0
|
||||
urllib3==1.26.12
|
||||
|
Loading…
Reference in New Issue
Block a user