def addMediaCategory(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if len(mediaInfo) > 4 and len(mediaInfo) < 20: sqlResult = adapter.insert_MediaCategory(mediaInfo) if not sqlResult: slackUtils.inChannelResponse( client, channel, """I'll add "{}" to the types of media carried by the backs of our enemies!""" .format(mediaInfo)) return slackUtils.inChannelResponse(client, channel, comments.notEnough) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def removeFact(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() someID = text[len(args[0]) + 1:].strip() if someID: exists = adapter.getFactByID(someID) if exists != -1 and exists: if not adapter.remove_Facts(someID): slackUtils.inChannelResponse( client, channel, comments.removeItem.format(exists) ) ## TODO format this properly to remove Fact return slackUtils.inChannelResponse(client, channel, comments.notFound3) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def checkin(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() someID = text[len(args[0]) + 1:].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sqlResult = adapter.Media_adminCheckIN(someID) if not sqlResult: slackUtils.inChannelResponse( client, channel, comments.adminCheckIN.format(exists)) return slackUtils.inChannelResponse(client, channel, comments.notFound3) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def putBack(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() someID = text[len(args[0]) + 1:].strip() if someID: sanitary = slackUtils.sanitizeID(someID) try: borrowed = adapater.getMyStuff(sanitary) exists = adapter.returnAll(sanitary) formatted = slackUtils.parseOtherStuff(borrowed) if not exists: returnMsg = comments.allback.format( slackUtils.reconstitueID(sanitary) ) + formatted + "It needs to be put back.\n" + comments.returnItem slackUtils.inChannelResponse( client, channel, returnMsg) return except: slackUtils.inChannelResponse(client, channel, comments.what3) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def updateMediaType(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if mediaInfo: mediaID, typeID = slackUtils.parseMediaType_update( mediaInfo) sqlResult = adapter.update_MediaType(mediaID, typeID) if not sqlResult: mName = adapter.getMediaNameByID(typeID) cName = adapter.getMediaTypeByID(typeID) slackUtils.inChannelResponse( client, channel, comments.updateMediaType.format(mName, cName)) return slackUtils.inChannelResponse(client, channel, comments.notFound3) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def checkout(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if mediaInfo: mID, sID = slackUtils.parseAdminCheckout(mediaInfo) exists = adapter.getMediaNameByID(mID) if exists: sanitary = slackUtils.sanitizeID(sID) sqlResult = adapter.Media_adminCheckOUT(mID, sanitary) if sqlResult == 5: slackUtils.inChannelResponse( client, channel, comments.checkedOUT.format(exists)) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.notEnough) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def addInsult(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if len(mediaInfo) > 10: sqlResult = adapter.insert_Fact(mediaInfo) if not sqlResult: slackUtils.inChannelResponse( client, channel, """That's a good one! I'll make sure to remember to hurl this at those who displease me:\n{}""" .format(mediaInfo)) return slackUtils.inChannelResponse(client, channel, comments.notEnough) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def addFact(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if len(mediaInfo) > 10: sqlResult = adapter.insert_Fact(mediaInfo) if not sqlResult: slackUtils.inChannelResponse( client, channel, """I had forgotten about that! I'll begin telling this tale when asked for more:\n{}""" .format(mediaInfo)) return slackUtils.inChannelResponse(client, channel, comments.notEnough) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def getAvailable(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] if adapter.isDirect(client, channel): allMedia = adapter.format_Media_Available() parsed = slackUtils.parseMedia_select(allMedia) slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def tellAll(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] if adapter.isDirect(client, channel): allCategory = adapter.selectAll_MediaCategory() parsed = slackUtils.parseMediaCategory_select(allCategory) slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def getMyStuff(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] aUser = payLoad['data']['user'] if adapter.isDirect(client, channel): allMedia = adapter.getMyStuff(aUser) parsed = slackUtils.parseMyStuff(allMedia) slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def getAllFacts(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): parsed = slackUtils.parseFact_select() slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def templateFunction(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] #text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): #doStuff return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def getWhoTookIt(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] #text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): allMedia = adapter.format_Media_WhosGotIt() parsed = slackUtils.parseMedia_WhosGotIt(allMedia) slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def getByType(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] if adapter.isDirect(client, channel): args = text.split() if len(args) < 2: slackUtils.inChannelResponse(client, channel, comments.badCommand) return mediaInfo = args[1].strip().title() sqlResult = adapter.getAvalableByCategory(mediaInfo) if sqlResult: parsed = slackUtils.parseViewMediaByCategory(sqlResult) parsed = comments.viewCategoryInfo.format(mediaInfo) + parsed slackUtils.inChannelResponse(client, channel, parsed) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def doLookup(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isDirect(client, channel): args = text.split() if len(args) < 2: slackUtils.inChannelResponse(client, channel, comments.badCommand) return medium = args[1].strip() if medium: exists = adapter.returnMedium(medium) if exists != -1 and exists: sqlResult = adapter.returnMedium(medium) if sqlResult == 3: slackUtils.inChannelResponse( client, channel, comments.notYou.format(exists)) return if sqlResult == 5: slackUtils.inChannelResponse( client, channel, comments.checkedOUT.format(exists)) return if not sqlResult: slackUtils.inChannelResponse( client, channel, comments.bringIt.format(exists)) return slackUtils.inChannelResponse( client, channel, comments.notFound2.format(exists)) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.correctCheckOUT) return slackUtils.inChannelResponse(client, channel, comments.notDirect) #Keeping disabled until testing completed #published.append(SearchMedium())
def doCheckout(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.getSlackName(aUser) == 'No ID': adapter.addUser(client.users_info(user=aUser)['user']) if adapter.isDirect(client, channel): args = text.split() if len(args) < 2: slackUtils.inChannelResponse(client, channel, comments.badCommand) return someID = args[1].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sqlResult = adapter.Media_CheckOUT(someID, aUser) if sqlResult == 5: slackUtils.inChannelResponse( client, channel, comments.checkedOUT.format(exists)) return if sqlResult == 4: slackUtils.inChannelResponse(client, channel, comments.noGreed) return if not sqlResult: slackUtils.inChannelResponse( client, channel, comments.takeIt.format(exists)) return slackUtils.inChannelResponse( client, channel, comments.checkedOUT.format(exists)) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.correctCheckOUT) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def doCheckIn(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isDirect(client, channel): args = text.split() if len(args) < 2: slackUtils.inChannelResponse(client, channel, comments.badCommand) return someID = args[1].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sanatary = slackUtils.sanitizeID(aUser) sqlResult = adapter.Media_CheckIN(someID, sanatary) if sqlResult == 3: slackUtils.inChannelResponse( client, channel, comments.notYou.format(exists)) return if sqlResult == 5: slackUtils.inChannelResponse( client, channel, comments.checkedOUT.format(exists)) return if not sqlResult: slackUtils.inChannelResponse( client, channel, comments.bringIt.format(exists)) return slackUtils.inChannelResponse( client, channel, comments.notTaken.format(exists)) return slackUtils.inChannelResponse(client, channel, comments.doesntExist) return slackUtils.inChannelResponse(client, channel, comments.correctCheckOUT) return slackUtils.inChannelResponse(client, channel, comments.notDirect)
def addMedia(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] text = payLoad['data']['text'] aUser = payLoad['data']['user'] if adapter.isAdmin(aUser): if adapter.isDirect(client, channel): args = text.split() mediaInfo = text[len(args[0]) + 1:].strip().capitalize() if mediaInfo: parsed, mediaName = slackUtils.parseMedia_insert(mediaInfo) sqlResult = adapter.insert_Media(parsed) if not sqlResult: slackUtils.inChannelResponse( client, channel, comments.adding.format(mediaName)) return slackUtils.inChannelResponse(client, channel, comments.notEnough) return slackUtils.inChannelResponse(client, channel, comments.what) return slackUtils.inChannelResponse(client, channel, comments.notDirect) return slackUtils.inChannelResponse(client, channel, comments.notAdmin)
def handle_command(command, channel, aUser, tStamp): command = command.lower() response = None ########################### ### PUBLIC commands ### ########################### ################# ### !fact ### ################# if command == "!fact": # TODO generate a random Conan fact return ################### ### !insult ### ################### if command == "!insult": # TODO generate a random Conan insult return ################# ### !help ### ################# if command == "!help".lower(): inChannelResponse(channel, cromHelp) if adapter.isAdmin(aUser): directResponse(aUser, adminHelp) return directResponse(aUser, publicHelp) return ################ ### !who ### ################ if command == "!who": inChannelResponse(channel, conanTells) directResponse(aUser, aboutConan) return ########################### ### DIRECT commands ### ########################### ############################### ### !allMediaCategories ### ############################### if command == "!allMediaCategories".lower(): if adapter.isDirect(channel): allCategory = adapter.selectAll_MediaCategory() parsed = parseMediaCategory_select(allCategory) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return ########################## ### !allMediaTypes ### ########################## if command == "!allMediaTypes".lower(): if adapter.isDirect(channel): allCategory = adapter.selectAll_MediaType() parsed = parseMediaType_select(allCategory) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return ####################### ### !everything ### ####################### if command == "!everything".lower(): if adapter.isDirect(channel): allMedia = adapter.format_Media() parsed = parseMedia_select(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return ###################### ### !available ### ###################### if command == "!available".lower(): if adapter.isDirect(channel): allMedia = adapter.format_Media_Available() parsed = parseMedia_select(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return ######################### ### !viewCategory ### ######################### if command.startswith("!viewCategory".lower()): if adapter.isDirect(channel): mediaInfo = command[len("!viewCategory") + 1:].strip().title() sqlResult = adapter.getAvalableByCategory(mediaInfo) if sqlResult: parsed = parseViewMediaByCategory(sqlResult) parsed = viewCategoryInfo.format(mediaInfo) + parsed inChannelResponse(channel, parsed) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return ##################### ### !viewType ### ##################### if command.startswith("!viewType".lower()): if adapter.isDirect(channel): mediaInfo = command[len("!viewType") + 1:].strip().title() sqlResult = adapter.getAvalableByType(mediaInfo) if sqlResult: parsed = parseViewMediaByType(sqlResult) parsed = viewTypeInfo.format(mediaInfo) + parsed inChannelResponse(channel, parsed) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return ####################### ### !myStuff ### ####################### if command == "!myStuff".lower(): if adapter.isDirect(channel): allMedia = adapter.getMyStuff(aUser) parsed = parseMyStuff(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return ##################### ### !checkOut ### ##################### if command.startswith("!checkOut".lower()): if adapter.isDirect(channel): someID = command[len("!checkOut") + 1:].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sqlResult = adapter.Media_CheckOUT(someID, aUser) if sqlResult == 5: inChannelResponse(channel, checkedOUT.format(exists)) return if sqlResult == 4: inChannelResponse(channel, noGreed) return if not sqlResult: inChannelResponse(channel, takeIt.format(exists)) return inChannelResponse(channel, checkedOUT.format(exists)) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, correctCheckOUT) return inChannelResponse(channel, notDirect) return #################### ### !checkIn ### #################### if command.startswith("!checkIn".lower()): if adapter.isDirect(channel): someID = command[len("!checkIn") + 1:].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sanatary = sanitizeID(aUser) sqlResult = adapter.Media_CheckIN(someID, sanatary) if sqlResult == 3: inChannelResponse(channel, notYou.format(exists)) return if sqlResult == 5: inChannelResponse(channel, checkedOUT.format(exists)) return if not sqlResult: inChannelResponse(channel, bringIt.format(exists)) return inChannelResponse(channel, notTaken.format(exists)) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, correctCheckIN) return inChannelResponse(channel, notDirect) return ############################### ### END PUBLIC commands ### ############################### ########################## ### ADMIN commands ### ########################## ##################### ### !allFacts ### ##################### if command == "!allFacts".lower(): if adapter.isAdmin(aUser): if adapter.isDirect(channel): allMedia = adapter.selectAll_Facts() parsed = parseFact_select(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return #################### ### !addFact ### #################### if command.startswith("!addFact".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!addFact") + 1:].strip().capitalize() if len(mediaInfo) > 10: sqlResult = adapter.insert_Fact(mediaInfo) if not sqlResult: inChannelResponse( channel, """I had forgotten about that! I'll begin telling this tale when asked for more:\n{}""" .format(mediaInfo)) return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ####################### ### !removeFact ### ####################### if command.startswith("!removeFact".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): someID = command[len("!removeFact") + 1:].strip() if someID: exists = adapter.getFactByID(someID) if exists != -1 and exists: sqlResult = adapter.remove_Facts(someID) if not sqlResult: inChannelResponse( channel, removeItem.format(exists) ) ## TODO format this properly to remove Fact return inChannelResponse(channel, notFound3) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ####################### ### !allInsults ### ####################### if command == "!allInsults".lower(): if adapter.isAdmin(aUser): if adapter.isDirect(channel): allMedia = adapter.selectAll_Insults() parsed = parseInsult_select(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ###################### ### !addInsult ### ###################### if command.startswith("!addInsult".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!addInsult") + 1:].strip().capitalize() if len(mediaInfo) > 10: sqlResult = adapter.insert_Insult(mediaInfo) if not sqlResult: inChannelResponse( channel, """That's a good one! I'll make sure to remember to hurl this at those who displease me:\n{}""" .format(mediaInfo)) # TODO set up add an insult return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ######################### ### !removeInsult ### ######################### if command.startswith("!removeInsult".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): someID = command[len("!removeInsult") + 1:].strip() if someID: exists = adapter.getInsultByID(someID) if exists != -1 and exists: sqlResult = adapter.remove_Insults(someID) if not sqlResult: inChannelResponse( channel, removeItem.format(exists) ) ## TODO format this properly to reomve Insult return inChannelResponse(channel, notFound3) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ######################### ### !addMediaType ### ######################### # Video Games, Card Games, Books, etc. if command.startswith("!addMediaType".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!addMediaType") + 1:].strip().title() if len(mediaInfo) > 4 and len(mediaInfo) < 20: sqlResult = adapter.insert_MediaType(mediaInfo) if not sqlResult: inChannelResponse( channel, """I'll add "{}" to the types of media carried by the backs of our enemies!""" .format(mediaInfo)) return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ############################# ### !addMediaCategory ### ############################# # Horror, Anime, Family, etc. if command.startswith("!addMediaCategory".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!addMediaCategory") + 1:].strip().title() if len(mediaInfo) > 4 and len(mediaInfo) < 20: sqlResult = adapter.insert_MediaCategory(mediaInfo) if not sqlResult: inChannelResponse( channel, """I'll add "{}" to the categories of media!""". format(mediaInfo)) return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ##################### ### !addMedia ### ##################### if command.startswith("!addMedia".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!addMedia") + 1:].strip().title() if mediaInfo: parsed, mediaName = parseMedia_insert(mediaInfo) sqlResult = adapter.insert_Media(parsed) if not sqlResult: inChannelResponse(channel, adding.format(mediaName)) return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ######################## ### !removeMedia ### ######################## if command.startswith("!removeMedia".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): someID = command[len("!removeMedia") + 1:].strip() if someID: exists = adapter.select_MediaID(someID) if exists != -1 and exists: sqlResult = adapter.remove_Media(someID) if not sqlResult: inChannelResponse(channel, removeItem.format(exists[0][4])) return inChannelResponse(channel, notFound3) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ################################ ### !updateMediacategory ### ################################ if command.startswith("!updateMediaCategory".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!updateMediacategory") + 1:].strip() if mediaInfo: mediaID, categoryID = parseMediaCategory_update(mediaInfo) sqlResult = adapter.update_MediaCategory( mediaID, categoryID) if not sqlResult: mName = adapter.getMediaNameByID(mediaID) cName = adapter.getMediaCategoryByID(categoryID) inChannelResponse( channel, updateMediaCategory.format(mName, cName)) return inChannelResponse(channel, notFound3) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ############################ ### !updateMediaType ### ############################ if command.startswith("!updateMediaType".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!updateMediaType") + 1:].strip().title() if mediaInfo: mediaID, typeID = parseMediaType_update(mediaInfo) sqlResult = adapter.update_MediaType(mediaID, typeID) if not sqlResult: mName = adapter.getMediaNameByID(mediaID) tName = adapter.getMediaTypeByID(typeID) inChannelResponse(channel, updateMediaType.format(mName, tName)) return inChannelResponse(channel, notFound3) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ########################## ### !adminCheckOut ### ########################## if command.startswith("!adminCheckOut".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): mediaInfo = command[len("!adminCheckOut") + 1:].strip() if mediaInfo: mID, sID = parseAdminCheckout(mediaInfo) exists = adapter.getMediaNameByID(mID) if exists: sanatary = sanitizeID(sID) sqlResult = adapter.Media_adminCheckOUT(mID, sanatary) if sqlResult == 5: inChannelResponse(channel, checkedOUT.format(exists)) return if not sqlResult: inChannelResponse( channel, adminCheckOut.format(sID.upper(), exists)) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, notEnough) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ######################### ### !adminCheckIn ### ######################### if command.startswith("!adminCheckIn".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): someID = command[len("!adminCheckIn") + 1:].strip() if someID: exists = adapter.getMediaNameByID(someID) if exists != -1 and exists: sqlResult = adapter.Media_adminCheckIN(someID) if not sqlResult: inChannelResponse(channel, adminCheckIN.format(exists)) return inChannelResponse(channel, notFound3) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ################### ### !return ### ################### if command.startswith("!return".lower()): if adapter.isAdmin(aUser): if adapter.isDirect(channel): someID = command[len("!return") + 1:].strip() if someID: sanatary = sanitizeID(someID) try: borrowed = adapter.getMyStuff(sanatary) exists = adapter.returnAll(sanatary) formatted = parseOtherStuff(borrowed) returnMsg = allback.format( reconstitueID(sanatary) ) + formatted + "It needs to be put back.\n" + returnItem if not exists: inChannelResponse(channel, returnMsg) return except: inChannelResponse(channel, what3) return inChannelResponse(channel, doesntExist) return inChannelResponse(channel, what) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ###################### ### !whoTookIt ### ###################### if command == "!whoTookIt".lower(): if adapter.isAdmin(aUser): if adapter.isDirect(channel): allMedia = adapter.format_Media_WhosGotIt() parsed = parseMedia_WhosGotIt(allMedia) inChannelResponse(channel, parsed) return inChannelResponse(channel, notDirect) return inChannelResponse(channel, notAdmin) return ############################## ### END ADMIN commands ### ############################## ####################################### return ### END handle_command ###