import config
import telebot
import json
from telebot import types
bot = telebot.TeleBot(config.token)
json_data = json.load(open('bd.json'))
@bot.message_handler(commands=['start'])
def first(message):
key = telebot.types.ReplyKeyboardMarkup(True,False)
key.row("Преподаватели")
key.row("Расписание звонков")
key.row("Расписание")
bot.send_message(message.chat.id, "Выберите пункт", reply_markup=key)
@bot.message_handler(content_types=['text'])
def main(message):
if message.text == "Расписание звонков":
bot.send_photo(message.chat.id, open('/home/frag0s/Рабочий стол/bbot/rasp.jpg', 'rb'))
elif message.text == "Расписание":
for user in json_data:
bot.send_message(message.chat.id,
str(user['is541']['name_day'])+":\n"
+str(user['is541']['lesson1']['time'])+"\t"+str(user['is541']['lesson1']['name_lesson'])+"\n"
+str(user['is541']['lesson2']['time'])+"\t"+str(user['is541']['lesson2']['name_lesson'])+"\n"
+str(user['is541']['lesson3']['time'])+"\t"+str(user['is541']['lesson3']['name_lesson'])+"\n"
+str(user['is541']['lesson4']['time'])+"\t"+str(user['is541']['lesson4']['name_lesson'])+"\n"
+str(user['is541']['lesson5']['time'])+"\t"+str(user['is541']['lesson5']['name_lesson']))
elif message.text == "Преподаватели":
key = telebot.types.ReplyKeyboardMarkup(True,False)
second(message)
def second(message):
if message.text == "Преподаватели":
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=False)
keyboard.row("ИВТ","ГФ")
keyboard.row("Вернуться к списку")
send = bot.send_message(message.from_user.id, "Выберите факультет", reply_markup=keyboard)
bot.register_next_step_handler(send, third)
def third(message):
if message.text == "ИВТ":
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=False)
keyboard.row("Назад")
send = bot.send_message(message.from_user.id, "name1", reply_markup=keyboard)
bot.register_next_step_handler(send, fin)
elif message.text == "ГФ":
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=False)
keyboard.row("Назад")
send = bot.send_message(message.from_user.id, "name2", reply_markup=keyboard)
bot.register_next_step_handler(send, fin)
elif message.text == "Вернуться к списку":
first(message)
def six(message):
if message.text == "Вернуться к списку":
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=False)
keyboard.row("Преподаватели")
keyboard.row("Расписание звонков")
keyboard.row("Расписание")
send = bot.send_message(message.from_user.id, "Выберите пункт")
bot.register_next_step_handler(send, second)
def fin(message):
if message.text == "Назад":
keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=False)
keyboard.row("ИВТ", "ГФ")
keyboard.row("Вернуться к списку")
send = bot.send_message(message.from_user.id, "Выберите факультет", reply_markup=keyboard)
bot.register_next_step_handler(send, third)
if __name__ == '__main__':
bot.polling(none_stop=True)