def msgstd_SCMC(update,context): ''' Function to ask the user to Send message that user want to pass to students ''' grd = (db.chkusr(update.effective_chat.id)).split('U')[0] update.message.reply_text(text="Send me the message that you want me to pass to {}".format(grd), reply_markup=telegram.ReplyKeyboardMarkup([[telegram.KeyboardButton(text='Send Poll',request_poll=telegram.KeyboardButtonPollType(type=None))],['Back']])) return CR_MSG_KEY
def dayKb_CCDC(update,context): ''' Function to send KeyBoard of Days to the user in CR Menu/Create_Class path ''' text = cs.build_menu(buttons=(cs.datajson['daylst']+['Back'])) update.message.reply_text( text='''Which day do you want to Create class for {}?'''.format((db.chkusr(update.effective_chat.id)).split('U')[0]), reply_markup=telegram.ReplyKeyboardMarkup(text)) return CR8CLS_Day_KEY
def GSP_CxCGC(update,context): ''' Function to send KeyBoard of Period,Grade,Subject to the user in CR Menu/Cancel_Class path ''' grade = (db.chkusr(update.effective_chat.id)).split('U')[0] context.user_data['CRCXLClsDay'] = (update.message.text) context.user_data['avGSPlst'] = [i[0] + ":" + i[1] for i in db.getStdtt(grade,context.user_data['CRCXLClsDay'])] update.message.reply_text(text='''Which Class do you want to cancel on {} ?'''.format((update.message.text)), reply_markup=telegram.ReplyKeyboardMarkup(cs.build_menu(context.user_data['avGSPlst']+['Back'],n_cols=1))) return CXLCLS_GSP_KEY
def snd_MsgStd_msg(update,context): ''' Function to send user msg to given students in class ''' grade = (db.chkusr(update.effective_chat.id)).split('U')[0] usrlst = db.grdstdid(grade) cs.FwdMsgTolst(update = update,context = context, usrlst = usrlst, is_CR = True) update.message.reply_text(text="I had forwarded your message to {} Student(s) in {} ".format(len(usrlst), grade)) CR_Menu(update,context) return cs.END
def subkb_CCGC(update,context): ''' Function to send KeyBoard of Subject to the user in CR Menu/Create_Class path ''' if not update.message.text == 'Back': context.user_data['stdCR8Day'] = update.message.text context.user_data['stdCRsubkb'] = db.getsubgrd((db.chkusr(update.effective_chat.id)).split('U')[0]) update.message.reply_text(text='''Tell me, For which subject do you want me to create class on {} ?'''.format(context.user_data['stdCR8Day']), reply_markup=telegram.ReplyKeyboardMarkup(cs.build_menu(context.user_data['stdCRsubkb']+['Back']))) return CR8CLS_SUB_KEY
def CR_Menu (update,context): ''' Function to send CR's Announcement Menu to the user ''' if (db.chkusr(update.effective_chat.id)) in db.getCR(): menu = cs.build_menu(buttons=["Create Class","Cancel Class","Replace Class","Message Students","Back"]) update.message.reply_text(text='''what you want to Announce now?''', reply_markup=telegram.ReplyKeyboardMarkup(menu)) return CR_MENU_KEY else: update.message.reply_text(text='''You are not a CR.So I can't allow you.''') return cs.END
def Menu(update,context): ''' Function to send Student Main Menu to the user ''' menu = ["Timetable","Attendance"] if update.effective_chat.id in cs.devjson['devChat_id']: menu = menu + ['DEV Menu'] if (db.chkusr(update.effective_chat.id)) in db.getCR(): menu = menu + ['CR Menu'] menu = cs.build_menu(buttons=menu + ["More"]) update.message.reply_text( text = '''Ask me what you want to know from the Below list''',reply_markup=telegram.ReplyKeyboardMarkup(menu)) return MAIN_MENU_KEY
def Authentication(update, context): ''' Function to athenticate the user as student (sequence part) ''' updusr = False if db.chkusr(update.effective_chat.id) != None: updusr = True rollno = db.usrsetup(update.effective_chat.id,(update.message.text).upper(),updusr) if rollno : update.message.reply_text("I linked Your Rollno {},\nto your account.\nIf you want to be a CR For your class then Send your Roll no and Name to Dev.\nSelect Menu to see the list of things that you can ask me.".format(rollno),reply_markup=telegram.ReplyKeyboardMarkup([['Menu']])) return cs.STOP else: return ivrollno(update, context)
def subkb_CRSC(update,context): ''' Function to send KeyBoard of Subject to the user in CR Menu/Replace_Class path ''' if update.message.text in context.user_data['RPLavlGSPlst'] + ['back']: if not update.message.text == 'Back': context.user_data['stdRPLGSP'] = update.message.text context.user_data['stdCRsubkb'] = db.getsubgrd((db.chkusr(update.effective_chat.id)).split('U')[0]) update.message.reply_text(text='''Tell me, For which subject do you want me to Replace class on {} ?'''.format(context.user_data['stdRPLGSP']), reply_markup=telegram.ReplyKeyboardMarkup(cs.build_menu(context.user_data['stdCRsubkb']+['Back']))) return RPLCLS_SUB_KEY else: update.message.reply_text(text='''The Class you told me to Cancel does not exists''') return cs.END
def period_CCPC(update,context): ''' Function to send KeyBoard of Periods to the user in Teacher_Announcements/Create_Class path ''' context.user_data['CR8ClsSub'] = (update.message.text) availableperlst = list() grade = (db.chkusr(update.effective_chat.id)).split('U')[0] stdperiodlst = [i[0] for i in db.getStdtt(grade ,context.user_data['stdCR8Day'])] for i in cs.datajson['periodlst']: if (i not in stdperiodlst): availableperlst.append(i) context.user_data['availableperlst'] = availableperlst update.message.reply_text(text='''Which period of {} do you want to create class ?'''.format((update.message.text)), reply_markup=telegram.ReplyKeyboardMarkup(cs.build_menu(context.user_data['availableperlst']+['Back']))) return CR8CLS_PERD_KEY
def conf_CR8cls_CCPC(update,context): ''' Function to Ask conformation before class creation ''' if (update.message.text) in context.user_data['availableperlst']: inlneCBdata = (db.chkusr(update.effective_chat.id)).split('U')[0] + ":" + context.user_data['CR8ClsSub'] + ":" + update.message.text + ":" + context.user_data['stdCR8Day'] + ':' + update.message.from_user.first_name # grade:subject:period:day:Name tcdata = inlneCBdata.split(':') text='''You want me to Create Class for \nsubject {} of {} \non {} : {}'''.format(tcdata[1].upper(),tcdata[0].upper(),tcdata[3],tcdata[2]) keyboard = [ [InlineKeyboardButton("Yes",callback_data= 'CR8CLS:' + inlneCBdata), InlineKeyboardButton("No",callback_data= 'CR8CLS:No' ) ], ] reply_markup = InlineKeyboardMarkup(keyboard) update.message.reply_text(text = text, reply_markup=reply_markup) Menu(update,context) return STOPPING else: update.message.reply_text(text='''This class was already taken.\nPlease Take another class''') return CR8CLS_PERD_KEY
def conf_CXLcls_CxCGC(update,context): ''' Function to Ask conformation before class creation ''' if (update.message.text) in context.user_data['avGSPlst']: cxlClsdata = (update.message.text).split(':') grade = (db.chkusr(update.effective_chat.id)).split('U')[0] inlneCBdata = cxlClsdata[0] + ':' + grade + ':' + cxlClsdata[1] + ":" + context.user_data['CRCXLClsDay'] + ":"+ update.message.from_user.first_name # period:grade:subject:day:Name tcdata = inlneCBdata.split(':') text='''You want me to Cancel Class for \nsubject {} of {} \non {} : {}'''.format(tcdata[2].upper(),tcdata[1].upper(),tcdata[3],tcdata[0]) keyboard = [ [InlineKeyboardButton("Yes",callback_data= 'CXLCLS:' + inlneCBdata), InlineKeyboardButton("No",callback_data= 'CXLCLS:No' ) ], ] reply_markup = InlineKeyboardMarkup(keyboard) update.message.reply_text(text = text, reply_markup=reply_markup) Menu(update,context) return STOPPING else: update.message.reply_text(text='''The Class you told me to Cancel does not exists''') GSP_CxCGC(update,context) return CXLCLS_GSP_KEY
def conf_RPLcls_CRGC(update,context): ''' Function to Ask conformation before class Replacement ''' if (update.message.text) in context.user_data['stdCRsubkb']: RPLClsdata = (context.user_data['stdRPLGSP']).split(':') grade = (db.chkusr(update.effective_chat.id)).split('U')[0] RPLSub = update.message.text inlneCBdata = RPLClsdata[0] + ':' + grade + ':' + RPLClsdata[1] + ":" + context.user_data['CRRPLClsDay'] +":" + RPLSub + ":"+ update.message.from_user.first_name # period:grade:subject:day:RPLSub:Name text='''You want me to Replace Class for \nsubject {} of {} \non {} : {} with {}'''.format(RPLClsdata[1].upper(),grade.upper(),context.user_data['CRRPLClsDay'] ,RPLClsdata[0],RPLSub) keyboard = [ [InlineKeyboardButton("Yes",callback_data= 'RPLCLS:' + inlneCBdata), InlineKeyboardButton("No",callback_data= 'RPLCLS:No' ) ], ] reply_markup = InlineKeyboardMarkup(keyboard) update.message.reply_text(text = text, reply_markup=reply_markup) Menu(update,context) return STOPPING else: update.message.reply_text(text='''The Subject you told me to replace is not for your class''') subkb_CCGC(update,context) return RPLCLS_SUB_KEY