コード例 #1
0
def period_CCPC(update, context):
    '''
        Function to send KeyBoard of Periods to the user in Teacher_Announcements/Create_Class path
    '''
    context.user_data['CR8ClsDay'] = (update.message.text)
    availableperlst = list()
    stdperiodlst = [
        i[0]
        for i in db.getStdtt((context.user_data['CR8ClsGrdSub']
                              ).split(':')[0], context.user_data['CR8ClsDay'])
    ]
    tchperiodlst = [
        i[0] for i in db.getTeachtt((
            update.effective_chat.id), context.user_data['CR8ClsDay'])
    ]
    for i in cs.datajson['periodlst']:

        if (i not in stdperiodlst) and (i not in tchperiodlst):
            availableperlst.append(i)
    context.user_data['availableperlst'] = availableperlst
    update.message.reply_text(
        text='''Which period of {} do you want ?'''.format(
            (update.message.text)),
        reply_markup=telegram.ReplyKeyboardMarkup(
            cs.build_menu(context.user_data['availableperlst'] + ['Back'])))
    return CR8CLS_PERD_KEY
コード例 #2
0
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
コード例 #3
0
def std_tt(chat_id,day):
    '''
        Function to Return student Timetable as a string
    '''
    perlst  =   db.getStdtt(db.getusrgrd(chat_id),day)
    text    =   "____Time___ : Subject \n"
    no_cls  =   True 
    for i in perlst:
        no_cls  =   False
        text    =   text + i[0] + " : " + i[1]+"\n"
    if no_cls:
        return "No Classes"
    else:
        return text
コード例 #4
0
def day_grd_tch_tt(update, context):
    '''
        Function to send given grade's timetable to the user
    '''
    perlst = db.getStdtt(context.user_data['GetGradeTTGrade'],
                         (update.message.text).capitalize())
    text = "Timetable of {} on {}:\n".format(
        context.user_data['GetGradeTTGrade'],
        (update.message.text).capitalize())
    text = text + "___Time___ : Subject\n"
    no_cls = True
    for i in perlst:
        no_cls = False
        text = text + i[0] + " : " + i[1] + "\n"
    if no_cls:
        text = "No Classes"
    update.message.reply_text(text=text)
    return GRADE_TT_DAY_KEY
コード例 #5
0
def class_Remindar(context):
    '''
        Jobqueue's callback_daily function to send Class_ATD_reminder to user 
    '''
    for i in db.getallstduid():
        try:
            day = datetime.datetime.now(tz= timezone('Asia/Kolkata')).strftime("%A")
            periodlst = db.getStdtt(db.getusrgrd(i),day)
            perlst = [j[0] for j in periodlst]
            if str(context.job.context) in perlst:
                subject = periodlst[perlst.index(context.job.context)][1]
                keyboard = [
                    InlineKeyboardButton("Yes",callback_data= str('1'+subject)),
                    InlineKeyboardButton("No",callback_data= str('0'+subject)),
                    InlineKeyboardButton("Cancel",callback_data= str('2'+subject))
                ]
                reply_markup = InlineKeyboardMarkup(cs.build_menu(keyboard))
                context.bot.send_message(chat_id=i, text= "Did you attend the class of subject {} @ {}".format(subject,context.job.context),
                            reply_markup=reply_markup)
                time.sleep(.2)
        except:
            pass