def feedbackStats(bot, update): if update.message.from_user.id in getAdminID(): update.message.reply_text("Good day, admin.\nTotal replies: {}".format( rList.llen('Feedback'))) logger.info("Admin initiates stats report.\nTotal replies: {}".format( rList.llen('Feedback'))) else: update.message.reply_text("You are not recognised!")
def removeAdmin(bot, update, args): if not args: update.message.reply_text( "Please provide a name. e.g. /removeAdmin John") return searchName = args[0] # there should be no space in the first name removed = False if update.message.from_user.id in utils.getAdminID(): for i in range(rList.llen('Admin List')): current = rList.lindex('Admin List', i).decode('utf-8') logger.info(current) if searchName.lower() in current.lower(): # if the name is found removed = current if searchName != "JunYou": rList.lrem( 'Admin List', 1, current ) # remove one object with same name, searching from head break if not removed: update.message.reply_text("Admin {} not found".format(searchName)) else: removedName, removedPhone = removed.split("|")[1:] logger.info("Admin {} (p/h: {}) has been removed.".format( removedName, removedPhone)) update.message.reply_text("Admin {} (p/h: {}) has been removed".format( removedName, removedPhone))
def createFile_fb(): logger.info( 'Feedback file requested. Loading excel file into memory and updating...' ) main_workbook = Workbook() worksheet = main_workbook.active rowNumber = 1 cell1, cell2, cell3 = 'A' + str(row_number), 'B' + str( row_number), 'C' + str(row_number) feedbackArray = [] for index in range(0, rList.llen('Feedback')): feedbackArray = [ rList.lindex('Feedback', index - 1).decode('utf-8').split('||||') ] rowNumber += 1 cellList = [] for columnNum in range(len(feedbackArray)): columnLetter = chr(columnNum + 65) cellList.append(columnLetter + str(rowNumber)) for cellIndex in range(len(cellList)): worksheet[cellList[cellIndex]] = feedbackArray[cellIndex] logger.info('Updating complete, saving excel file') main_workbook.save('Feedback.xlsx') logger.info("File creation complete")
def getAdminID(): adminList = [] for i in range(rList.llen('Admin List')): adminInfo = rList.lindex('Admin List', i).decode('utf-8').split("|") adminID = adminInfo[0] adminList.append(int(adminID)) return adminList
def getFeedbackQuestions(): questionsList = {} for i in range(rList.llen('Feedback Questions')): question = rList.lindex('Feedback Questions', i).decode('utf-8') questionID = "QN" + str(i + 1) questionsList[questionID] = question logger.info('Question ID: {}, Question: {}'.format( questionID, question)) if questionsList == {}: return False return questionsList
def listAllAdmins(bot, update): adminList = "" if update.message.from_user.id in utils.getAdminID(): for i in range(rList.llen('Admin List')): adminInfo = rList.lindex('Admin List', i).decode('utf-8').split("|") logger.info(": ".join(adminInfo[1:])) adminList += ": ".join( adminInfo[1:] ) + "\n" # search, decode, split, slice, join, and concatenate if adminList != "": logger.info(adminList) update.message.reply_text(adminList) # send the complete list else: update.message.reply_text("There are no admins") else: update.message.reply_text("You are not recognised!")
def getQuestions(): questionList = [] for index in range(rList.llen('Feedback Questions')): questionList.append( rList.lindex('Feedback Questions', index).decode('utf-8')) return questionList