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
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
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
def callback_daily(context): ''' Jobqueue's callback_daily function to send timetable to user at night ''' usrlst = db.getallstduid() for i in usrlst: try: day = datetime.datetime.now(tz= timezone('Asia/Kolkata')).strftime("%A") text = "Today's Timetable:\n" + std_tt(i,day) context.bot.send_message(chat_id=i , text = text) time.sleep(.2) except: pass text = "Total no of STUDENTS using CR_ALT = {}".format(len(usrlst)) for i in cs.devjson['devChat_id']: context.bot.send_message(chat_id=i,text= text)
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