コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 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)
コード例 #11
0
 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)
コード例 #12
0
 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)
コード例 #13
0
 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)
コード例 #14
0
 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)
コード例 #15
0
    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)
コード例 #16
0
 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)
コード例 #17
0
 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)
コード例 #18
0
 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)
コード例 #19
0
 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)
コード例 #20
0
    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())
コード例 #21
0
 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)