def set_deadline(message): class_id = wait_deadline[message.chat.id] db = SQLighter(config.database_name) #try: date = message.text[:16] + ':00.000' text = message.text[16:] if db.set_deadline(class_id, message.chat.id, text, time): wait_deadline.pop(message.chat.id, None) bot.send_message(message.chat.id, "Успешно", reply_markup=operator_markup) return else: markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='Отмена', callback_data='reset_deadl')) bot.send_message(message.chat.id, "Проверьте правильность или напишите", reply_markup=markup) #except: # markup = types.InlineKeyboardMarkup() # markup.add(types.InlineKeyboardButton(text='Отмена', callback_data='reset_deadl')) # bot.send_message(message.chat.id, "Проверьте правильность или напишите", reply_markup=markup) # markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='Отмена', callback_data='reset_deadl'))
def abort_confirm(message): if message.chat.id in wait_response_operator: wait_response_operator.remove(message.chat.id) db = SQLighter(config.database_name) db.abort_confirm(message.chat.id) bot.send_message(message.chat.id, "Успешно", reply_markup=operator_markup) print(db.get_all_queries(message.chat.id, 7))
def check_user(chat_id): with shelve.open(shelve_name) as storage: if str(chat_id) in storage: return storage[str(chat_id)] db = SQLighter(database_name) status = db.check(chat_id) storage[str(chat_id)] = status return status
def student_timetable(message): try: days = message.text.split(' ')[1] except: bot.send_message(message.chat.id, "bad argument") return db = SQLighter(config.database_name) classes = db.stud_tmt(message.chat.id, int(days)) for c in classes: bot.send_message(message.chat.id, c[0] + '\n' + c[1] + '\n' + c[2][:-7])
def commit_query(message): if message.text == 'Буду снимать': res = SQLighter(config.database_name).commit(message.chat.id, '1') if res: query = SQLighter(config.database_name).get_query(message.chat.id) if query[0][0] is not None: markup = types.ReplyKeyboardMarkup() markup.row('Буду снимать') markup.row('Не буду снимать') bot.send_message(message.chat.id, query[0][1] + '\n' + query[0][2] + '\n' + query[0][3], reply_markup=markup) wait_response_operator.add(message.chat.id) else: wait_response_operator.remove(message.chat.id) bot.send_message(message.chat.id, 'Похоже, что ничего не запланирвано.', reply_markup=operator_markup) else: wait_response_operator.remove(message.chat.id) bot.send_message(message.chat.id, 'Похоже, что ничего не запланирвано.', reply_markup=operator_markup) elif message.text == 'Не буду снимать': res = SQLighter(config.database_name).commit(message.chat.id, '-1') if res: query = SQLighter(config.database_name).get_query(message.chat.id) if query[0][0] is not None: markup = types.ReplyKeyboardMarkup() markup.row('Буду снимать') markup.row('Не буду снимать') bot.send_message(message.chat.id, query[0][1] + '\n' + query[0][2] + '\n' + query[0][3], reply_markup=markup) wait_response_operator.add(message.chat.id) else: wait_response_operator.remove(message.chat.id) bot.send_message(message.chat.id, 'Похоже, что ничего не запланирвано.', reply_markup=operator_markup) else: wait_response_operator.remove(message.chat.id) bot.send_message(message.chat.id, 'Похоже, что ничего не запланирвано.', reply_markup=operator_markup)
def student_deadlines(message): try: days = message.text.split(' ')[1] except: bot.send_message(message.chat.id, "bad argument") return db = SQLighter(config.database_name) deadlines = db.stud_deadl(message.chat.id, int(days)) if len(deadlines): for d in deadlines: bot.send_message(message.chat.id, d[0] + '\n' + d[1][:-7] + '\n' + d[2], reply_markup=stud_markup) else: bot.send_message(message.chat.id, 'Кажется нет активны дедалйнов', reply_markup=stud_markup)
def choose_deadl(message): db = SQLighter(config.database_name) classes = db.get_all_queries(message.chat.id, 7) markup = types.InlineKeyboardMarkup() for c in classes: id_class = c[0] text = c[1] + ' ' + c[2] + ' ' + c[3][:-7] markup.add( types.InlineKeyboardButton(text=text, callback_data='d ' + str(id_class))) markup.add( types.InlineKeyboardButton(text='Отмена', callback_data='reset_deadl')) bot.send_message(message.chat.id, "Выберите занятие, на которое хотите установить дедлайн", reply_markup=markup)
def reg_student(chat_id, name, lastname, group): db = SQLighter(database_name) res = db.register_stud(chat_id, name + ' ' + lastname, group) print(res) with shelve.open(shelve_name) as storage: if len(res) and res[0][0] == str(chat_id): if str(chat_id) in storage: old_status = storage[str(chat_id)] if old_status == 'op' or old_status == 's/o': storage[str(chat_id)] = 's/o' else: storage[str(chat_id)] = 'stud' return True else: storage[str(chat_id)] = 'stud' return True else: return False
def reg_operator(chat_id, name, lastname, email): db = SQLighter(database_name) res = db.register_op(chat_id, name + ' ' + lastname, email) with shelve.open(shelve_name) as storage: #if registration is done print(res) if len(res) and res[0][0] == str(chat_id): if str(chat_id) in storage: old_status = storage[str(chat_id)] if old_status == 'stud' or old_status == 's/o': storage[str(chat_id)] = 's/o' else: storage[str(chat_id)] = 'op' return True else: storage[str(chat_id)] = 'op' return True else: return False
def student_timetable(message): try: days = message.text.split(' ')[1] except: bot.send_message(message.chat.id, "bad argument") return db = SQLighter(config.database_name) classes = db.get_all_queries(message.chat.id, days) for c in classes: status = c[4] if status == '0' or status == 0: status = 'Не подтверждено' elif status == '1' or status == 1: status = 'Подтверждено' elif status == '-1' or status == -1: status = 'Отказ' bot.send_message( message.chat.id, c[1] + '\n' + c[2] + '\n' + c[3] + '\nСтатус: ' + status)
def send_confirm(message): status = utils.check_user(message.chat.id) if status == 'op' or status == 's/o': query = SQLighter(config.database_name).get_query(message.chat.id) if query[0][0] is not None: markup = types.ReplyKeyboardMarkup() markup.row('Буду снимать') markup.row('Не буду снимать') bot.send_message(message.chat.id, query[0][1] + '\n' + query[0][2] + '\n' + query[0][3], reply_markup=markup) wait_response_operator.add(message.chat.id) else: bot.send_message(message.chat.id, 'Похоже, что ничего не запланирвано.', reply_markup=operator_markup)
from data_handler import SQLighter import shelve from telebot import types #with shelve.open('shelve.db') as storage: # print(storage['80271002']) db = SQLighter('lector.db') print(db.stud_tmt(80271002, 7)) # #print(db.commit(80271002, '1')) #print(db.get_query(80271002)) #print(db.commit(80271002, '1')) #print(db.get_query(80271002)) #
from data_handler import SQLighter import shelve from telebot import types #with shelve.open('shelve.db') as storage: # print(storage['80271002']) db = SQLighter('lector.db') print(db.abort_confirm(80271002)) print(db.get_query(80271002)) #print(db.commit(80271002, '1')) #print(db.get_query(80271002)) #print(db.commit(80271002, '1')) #print(db.get_query(80271002)) #
def student_timetable(message): db = SQLighter(config.database_name) classes = db.get_stud_tmt(message.chat.id, 7) for c in classes: print(c) bot.send_message(message.chat.id, c[0] + '\n' + c[1] + '\n' + c[2])