-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
49 lines (39 loc) · 1.97 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import telebot
from diary import *
from profile import *
import datetime
token = ''
bot = telebot.TeleBot(token)
login = ''
password = ''
profile = Profile({'main_login': login, 'main_password': password})
markup = telebot.types.ReplyKeyboardMarkup()
markup.add(telebot.types.KeyboardButton('Расписание на сегодня'), telebot.types.KeyboardButton('Расписание на завтра'))
markup.add(telebot.types.KeyboardButton('Табель'))
@bot.message_handler(commands=['start'])
def start(message):
usid = message.from_user.id
if usid not in admins:
return
bot.send_message(message.chat.id, '*Выбери действие с помощью кнопок снизу =)*', parse_mode="Markdown", reply_markup=markup)
@bot.message_handler(content_types=['text'])
def deauth_user(message):
if "Расписание" in message.text:
bot.send_chat_action(message.chat.id, 'typing')
if "завтра" in message.text:
diary = profile.diary_day((datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%d.%m.%Y'))
else:
diary = profile.diary_day(datetime.datetime.now().strftime('%d.%m.%Y'))
weekdays = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье']
subs = ""
for sub in diary.subjects:
subs += sub.get_str() + '\n'
if diary.weekday != 6:
bot.send_message(message.chat.id, '*🔸 ' + weekdays[diary.weekday] + ':*\n' + subs, parse_mode="Markdown")
else:
bot.send_message(message.chat.id, '*🔸 Воскресенье*:\n\nСвободный день!', parse_mode="Markdown")
elif message.text == "Табель":
bot.send_chat_action(message.chat.id, 'upload_photo')
profile.diary_term(draw=True)
bot.send_photo(message.chat.id, photo=open('grades.png', 'rb').read())
bot.polling(none_stop=True, timeout=123)