예제 #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 devRmvUsr(update, context):
    '''
        Function to remove account of the user with the given chat id or roll no or emp id to remove account
    '''
    usrid = None
    if update.message.text.lower() in db.getalltchempid():
        usrid = db.getTchChatId(update.message.text.lower())
        db.rmvtch(usrid)
    elif update.message.text.upper() in db.getallstdrollno():
        usrid = db.getStdChatId(update.message.text.upper())
        db.rmvstd(usrid)
    elif update.message.text in db.getalltchuid():
        usrid = update.message.text
        db.rmvtch(update.message.text)
    elif update.message.text in db.getalltchuid():
        usrid = update.message.text
        db.rmvstd(update.message.text)
    if usrid == None:
        update.message.reply_text(
            text="There was no such user with given data - {}".format(
                update.message.text))
    else:
        context.bot.send_message(
            chat_id=usrid,
            text=
            "We got a complaint that you are using another user's account.\nSo,We are removing your account.\
                                                        Please contact the developer for any query\nPlease send /start to start the bot",
            reply_markup=telegram.ReplyKeyboardRemove())
        update.message.reply_text(text="Account of {} removed successfully.".
                                  format(update.message.text))
    return bkDRAC(update, context)
예제 #3
0
def snd_dev_msg(update,context):
    '''
        Function to send message to all users
    '''
    if context.user_data['DevUsrOpt'] == 'Students':
        usrlst = db.getallstduid()
    elif context.user_data['DevUsrOpt'] == 'Teachers':
        usrlst = db.getalltchuid()
    elif context.user_data['DevUsrOpt'] == 'All Users':
        usrlst = db.getallstduid() + db.getalltchuid()
    elif context.user_data['DevUsrOpt'] in db.getalltchempid():
        usrlst = [db.getTchChatId(context.user_data['DevUsrOpt'])]
    elif context.user_data['DevUsrOpt'] in db.getallstdrollno():
        usrlst = [db.getStdChatId(context.user_data['DevUsrOpt'])]
    else:
        usrlst = [context.user_data['DevUsrOpt']]
    cs.FwdMsgTolst(update = update,context = context, usrlst = usrlst, is_dev = True)
    update.message.reply_text(text="I had forwarded your message to {} Users".format(len(usrlst)))
    devmenu_msg(update,context)
    return cs.END
예제 #4
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