Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def snd_dev_msg(update,context):
    '''
        Function to send message to all users
    '''
    if context.user_data['stdDevUsrOpt'] == 'Students':
        usrlst = db.getallstduid()
    elif context.user_data['stdDevUsrOpt'] == 'Teachers':
        usrlst = db.getalltchuid()
    else:
        usrlst = db.getallstduid() + db.getalltchuid()
    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)))
    std_devmenu_msg(update,context)
    return cs.END
Ejemplo n.º 3
0
def dev_no_usr(update,context):
    '''
        Developer's function - No of Users
    '''
    stdcnt = len(db.getallstduid())
    tchcnt = len(db.getalltchuid())
    text = '''Total no of Students = {}\nTotal no of Teachers = {}\nTotal no of devs = {}\n Total no of users = {}'''.format(stdcnt,tchcnt,len(cs.devjson['devChat_id']),stdcnt+tchcnt)
    update.message.reply_text(text = text)
    return DEV_MENU_KEY
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def callback_daily(context):
    '''
        Jobqueue's callback_daily function
    '''
    tchlst = db.getalltchuid()
    tchcnt = len(tchlst)

    for i in tchlst:
        day = datetime.datetime.now(tz=timezone('Asia/Kolkata')).strftime("%A")
        text = "Today's Timetable\n" + tch_tt(i, day)
        context.bot.send_message(chat_id=i, text=text)
        time.sleep(.2)
    text = "Total no of Professor using CR_ALT = {}".format((tchcnt))
    for i in cs.devjson['devChat_id']:
        context.bot.send_message(chat_id=i, text=text)
Ejemplo n.º 6
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