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 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 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 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 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 giveHelp(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] aUser = payLoad['data']['user'] slackUtils.inChannelResponse(client, channel, comments.cromHelp) if adapter.isAdmin(aUser): slackUtils.directResponse(client, channel, aUser, comments.adminHelp) return slackUtils.directResponse(client, channel, aUser, comments.publicHelp)
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 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 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 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 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 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 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 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 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 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 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 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 tellWho(self, payLoad): client = payLoad['web_client'] channel = payLoad['data']['channel'] aUser = payLoad['data']['user'] slackUtils.inChannelResponse(client, channel, comments.conanTells) slackUtils.directResponse(client, channel, aUser, comments.aboutConan)