예제 #1
0
def devMngCR(update, context):
    '''
        Function to Add and Remove CR from DB 
    '''
    roll_no = update.message.text.upper()
    if roll_no in db.getCR():
        db.delCR(roll_no)
        if db.getStdChatId(roll_no):
            context.bot.send_message(
                chat_id=db.getStdChatId(roll_no),
                text=
                'You are No longer a CR now.\nContact Dev if you want to be a CR'
            )
        update.message.reply_text(
            text='''{} removed from CR list successfully'''.format(roll_no))
        return bkDRAC(update, context)
    else:
        rn = db.addCR(roll_no)
        if roll_no == rn:
            if db.getStdChatId(roll_no):
                context.bot.send_message(
                    chat_id=db.getStdChatId(roll_no),
                    text=
                    'Congrats! You are A CR Now.You can Find CR Menu in Main Menu(/menu)'
                )
            update.message.reply_text(text='''CR Added successfully''')
            return bkDRAC(update, context)
        else:
            update.message.reply_text(
                text='''CR Already exists for {} with Roll no {}'''.format(
                    roll_no.split('U')[0], roll_no))
            return DEV_MNG_CR_KEY
예제 #2
0
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
예제 #3
0
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
예제 #4
0
def devgetCRRoll(update,context):
    '''
        Function to Ask Roll no of CR 
    '''
    text = ''
    roll_no = db.getCR()
    for i in roll_no:
        text = text + '\n {} - {}'.format(i.split('U')[0],i)
    if text == '':
        text = 'Empty'
    update.message.reply_text(text='''List of CR Roll No :\n{}\n\nPlease Enter The Roll no of the CR.\nIf the roll no is already in the above list then I will delete it else i will add it\nNote : one grade can have only one CR'''.format(text),
                                        reply_markup=telegram.ReplyKeyboardMarkup([['Back']]))
    return DEV_MNG_CR_KEY
예제 #5
0
def update_Day_tt(context):
    '''
        Jobqueue's Updaytt function
        it will up date day timetable on working days after 04:30 pm
    '''
    cs.jsonupd()
    day = datetime.datetime.now(tz=timezone('Asia/Kolkata')).strftime("%A")
    db.upddaytt(day)
    tchlst = db.getalltchuid()
    for i in tchlst:
        text = "Professor, Next {}\ntimetable was updated.\nYou can make changes in the timetable now".format(
            day)
        context.bot.send_message(chat_id=i, text=text)
        time.sleep(.2)
    for i in db.getCR():
        text = "CR, Next {}\ntimetable was updated.\nYou can make changes in the timetable now".format(
            day)
        chat_id = db.getStdChatId(i)
        if chat_id:
            context.bot.send_message(chat_id=i, text=text)
        time.sleep(.2)
    del day