25 lines
895 B
Python
25 lines
895 B
Python
from telebot.types import Message, CallbackQuery
|
|
|
|
from models.bot import bot, send
|
|
from models.user import validate
|
|
|
|
#! Buttons editing
|
|
from models.bot import Markup
|
|
Markup.notifications()
|
|
|
|
|
|
@bot.message_handler(content_types = ['text'], func = lambda m: validate(m).state == 'notifications')
|
|
def notifications(message: Message):
|
|
u = validate(message)
|
|
|
|
target = ({
|
|
'Перед парой ⌛': 'lesson',
|
|
'Вечером 🌆': 'evening',
|
|
'Файлом на неделю 📅': 'week_file', #! INDEV
|
|
}).get(message.text, False) # type: ignore
|
|
if not target: return
|
|
|
|
u.notifications.append(target) if target not in u.notifications else u.notifications.remove(target)
|
|
u.save()
|
|
|
|
send(message, f'<b>{message.text}</b> — теперь уведомления <i>{"включены" if target in u.notifications else "выключены"}</i>')
|