def addadmin(message): chat_id = message.chat.id if chat_id in alice_vars.superuser: msg = bot.reply_to(message, "What's the ID you want to add to Admins?") bot.register_next_step_handler(msg, bot_functions.add_admin) else: bot.send_message(chat_id, "oops! you're not a superuser. Only a superuser can add new admins.")
def docs(message): chat_id = message.chat.id msg = bot.send_message(chat_id, "Select the department:", reply_markup=bot_functions.create_keyboard( alice_vars.depts)) bot.register_next_step_handler(msg, bot_functions.dept)
def welcome(message): chat_type = message.chat.type chat_id = message.chat.id f_name = message.from_user.first_name l_name = message.from_user.last_name name = f_name+" "+l_name if chat_type == "private": print(f_name,"with id",chat_id,"is a user.") user_exist = sql_functions.check_user(alice_vars.db_name, 'Users', chat_id) admin_exist = sql_functions.check_user(alice_vars.db_name, 'Admins', chat_id) if user_exist == True: print("User already exists in db.") if admin_exist == True: bot.send_message(chat_id, "Hi, Welcome back. If you want any help, just send /help", reply_markup=alice_vars.keyboard_admin) else: bot.send_message(chat_id, "Hi, Welcome back. If you want any help, just send /help", reply_markup=alice_vars.keyboard_default) else: print("Adding",f_name,"to db.") msg = bot.send_message(chat_id, "Hi, "+ f_name +" May I know your class?", reply_markup=alice_vars.keyboard_classes) bot.register_next_step_handler(msg, bot_functions.add_user) elif (chat_type == "group") | (chat_type == "supergroup"): print(chat_id,"is a group\n") bot.send_message(chat_id, 'This is a group, and I hate crowd. PM me for a better bot experience.')
def dept(message): docs['dept'] = message.text msg = bot.send_message(message.chat.id, "Select a subject:", reply_markup=create_keyboard( alice_vars.subjects[docs['dept']])) bot.register_next_step_handler(msg, subject)
def adddocs(message): chat_id = message.chat.id user_exist = sql_functions.check_user(alice_vars.db_name, 'Admins', chat_id) if user_exist == False: bot.send_message(chat_id, "Oops! You're not a bot Admin.", markup=alice_vars.keyboard_default) print(message.from_user.first_name, "thinks he's an admin.") else: msg = bot.send_message(chat_id, "Select the Department: ", reply_markup=bot_functions.create_keyboard(alice_vars.depts)) bot.register_next_step_handler(msg, bot_functions.docs_dept)
def addremind(message): chat_id = message.chat.id user_exist = sql_functions.check_user(alice_vars.db_name, 'Admins', chat_id) if user_exist == False: bot.send_message(chat_id, "Oops! You're not a bot Admin.", markup=alice_vars.keyboard_default) print(message.from_user.first_name, "thinks he's an admin.") else: msg = send_message(message.chat_id, "Enter Reminder Title") bot.register_next_step_handler(msg, bot_functions.createReminder) print("Adding new reminder.")
def sendfeedback(message): chat_id = message.chat.id if chat_id in alice_vars.superuser: result = sql_functions.read_feedback(alice_vars.db_name, 'Feedback') if result == False: bot.send_message(chat_id, "No feedbacks recorded yet!", reply_markup = alice_vars.keyboard_admin) else: feedback_msg = "" for entry in result: feedback_msg = feedback_msg+"\n"+str(entry)+": "+sql_functions.feedback_fetch(alice_vars.db_name+"\n\n", 'Feedback', entry) bot.send_message(chat_id, feedback_msg, reply_markup = alice_vars.keyboard_admin) else: msg = bot.send_message(chat_id, "So, What do you think about me ?") bot.register_next_step_handler(msg, bot_functions.feedback)
def docs_module(message): adddocs['module'] = int(message.text) msg = bot.send_message(message.chat.id, "send me the document(pdf)") bot.register_next_step_handler(msg, docs_upload)
def docs_subject(message): adddocs['subject'] = message.text msg = bot.send_message(message.chat.id, "Select a module(0 to upload the syllabus)", reply_markup=alice_vars.keyboard_modules) bot.register_next_step_handler(msg, docs_module)