def runTest(self):
     s = TestData.data["session"]
     
     item = ItemDatabase.getItemFromName("olive")
     r = ItemDescriptionRequest(s, item["descId"])
     itemData = r.doRequest()
     self.assertEquals(itemData["isCookingIngredient"], True)
     self.assertEquals(itemData["isCocktailcraftingIngredient"], True)
     self.assertEquals(itemData["image"], "olive.gif")
     self.assertEquals(itemData["autosell"], 35)
     self.assertEquals(itemData["type"], "food")
     
     item = ItemDatabase.getItemFromName("furry fur")
     r = ItemDescriptionRequest(s, item["descId"])
     itemData = r.doRequest()
     self.assertEquals(itemData["isMeatsmithingComponent"], True)
     self.assertEquals(itemData["image"], "furfur.gif")
     self.assertEquals(itemData["autosell"], 129)
     
     item = ItemDatabase.getItemFromName("baconstone")
     r = ItemDescriptionRequest(s, item["descId"])
     itemData = r.doRequest()
     self.assertEquals(itemData["isJewelrymakingComponent"], True)
     self.assertEquals(itemData["image"], "baconstone.gif")
     self.assertEquals(itemData["autosell"], 500)
     
     # Test a haiku item -- these description pages are formatted differently.
     r = ItemDescriptionRequest(s, 435365663)
     itemData = r.doRequest()
     self.assertEquals(itemData["name"], "little round pebble")
     self.assertEquals(itemData["autosell"], 45)
     self.assertEquals(itemData["type"], "off-hand item")
Exemple #2
0
def botProcessKmail(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    message = kwargs["kmail"]
    bot = kwargs["bot"]
    cmd = BotUtils.getKmailCommand(message)

    if cmd == "uneffect":
        arr = message["text"].split()
        items = message["items"]

        # Get the effect ID.
        if len(arr) < 2:
            raise Error.Error(
                "You must specify the ID of the effect to remove.",
                Error.BOT_REQUEST)
        try:
            effectId = int(arr[1])
        except ValueError:
            raise Error.Error("Unable to remove effect. Invalid effect ID.",
                              Error.BOT_REQUEST)

        # Ensure the user sent a SGEEA.
        if len(items) != 1:
            raise Error.Error("Please include just a SGEEA in your kmail.",
                              Error.BOT_REQUEST)
        sgeea = ItemDatabase.getItemFromName(
            "soft green echo eyedrop antidote")
        if items[0]["id"] != sgeea["id"] or items[0]["quantity"] != 1:
            raise Error.Error(
                "Please include just a single SGEEA in your kmail.",
                Error.BOT_REQUEST)

        # Perform the request.
        m = {}
        m["userId"] = message["userId"]
        Report.info("bot", "Attempting to remove effect %s..." % effectId)
        r = UneffectRequest(bot.session, effectId)
        try:
            r.doRequest()
            m["text"] = "Effect successfully removed!"
        except Error.Error, inst:
            if inst.code == Error.EFFECT_NOT_FOUND:
                m["text"] = "I do not currently have that effect."
                m["items"] = items
            else:
                m["text"] = "Unable to remove effect for unknown reason."
                m["items"] = items

        bot.sendKmail(m)
        returnCode = FilterManager.FINISHED
Exemple #3
0
def botProcessKmail(context, **kwargs):
    returnCode = FilterManager.CONTINUE
    message = kwargs["kmail"]
    bot = kwargs["bot"]
    cmd = BotUtils.getKmailCommand(message)

    if cmd == "uneffect":
        arr = message["text"].split()
        items = message["items"]

        # Get the effect ID.
        if len(arr) < 2:
            raise Error.Error("You must specify the ID of the effect to remove.", Error.BOT_REQUEST)
        try:
            effectId = int(arr[1])
        except ValueError:
            raise Error.Error("Unable to remove effect. Invalid effect ID.", Error.BOT_REQUEST)

        # Ensure the user sent a SGEEA.
        if len(items) != 1:
            raise Error.Error("Please include just a SGEEA in your kmail.", Error.BOT_REQUEST)
        sgeea = ItemDatabase.getItemFromName("soft green echo eyedrop antidote")
        if items[0]["id"] != sgeea["id"] or items[0]["quantity"] != 1:
            raise Error.Error("Please include just a single SGEEA in your kmail.", Error.BOT_REQUEST)

        # Perform the request.
        m = {}
        m["userId"] = message["userId"]
        Report.info("bot", "Attempting to remove effect %s..." % effectId)
        r = UneffectRequest(bot.session, effectId)
        try:
            r.doRequest()
            m["text"] = "Effect successfully removed!"
        except Error.Error, inst:
            if inst.code == Error.EFFECT_NOT_FOUND:
                m["text"] = "I do not currently have that effect."
                m["items"] = items
            else:
                m["text"] = "Unable to remove effect for unknown reason."
                m["items"] = items

        bot.sendKmail(m)
        returnCode = FilterManager.FINISHED
Exemple #4
0
def makeItRain():
    for term in searchTerms:
        m = MallItemSearchRequest(s, pad(term))
        res = m.doRequest()["results"][0]
        curResult = [res["price"], res["quantity"], res["id"]]
        result[term] = curResult
        print "Booze: {0}, price: {1}, quantity: {2}".format(
            res["name"], res["price"], res["quantity"])
        curRecipe = recipe[term]
        total = 0
        recipeData = []
        for ingredient in curRecipe:
            m = MallItemSearchRequest(s, pad(ingredient))
            searchData = m.doRequest()
            recipeData.append(searchData["results"][0])
            price = searchData["results"][0]["price"]
            total += price
        if res["price"] > total:
            print "{0} should be crafted for profit. {0} has a total ingredient cost of {1}, but is selling for {2}".format(
                term, total, res["price"])
            if "limit" in recipeData[0] or "limit" in recipeData[1]:
                if "limit" in recipeData[0] and "limit" not in recipeData[1]:
                    if min(recipeData[0]["quantity"],
                           recipeData[1]["quantity"]) > recipeData[0]["limit"]:
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(
                            term)
                        quantityOfEach = min(int(meatLimit / total),
                                             recipeData[0]["limit"])
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(
                            int(meatLimit / total),
                            min(recipeData[0]["quantity"],
                                recipeData[1]["quantity"]))
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
                elif "limit" in recipeData[1] and "limit" not in recipeData[0]:
                    if min(recipeData[0]["quantity"],
                           recipeData[1]["quantity"]) > recipeData[1]["limit"]:
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(
                            term)
                        quantityOfEach = min(int(meatLimit / total),
                                             recipeData[1]["limit"])
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(
                            int(meatLimit / total),
                            min(recipeData[0]["quantity"],
                                recipeData[1]["quantity"]))
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
                elif "limit" in recipeData[1] and "limit" in recipeData[0]:
                    if min(recipeData[0]["quantity"],
                           recipeData[1]["quantity"]) > min(
                               recipeData[1]["limit"], recipeData[0]["limit"]):
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(
                            term)
                        quantityOfEach = min(
                            int(meatLimit / total),
                            min(recipeData[1]["limit"],
                                recipeData[0]["limit"]))
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(
                            int(meatLimit / total),
                            min(recipeData[0]["quantity"],
                                recipeData[1]["quantity"]))
                        buyItem(
                            recipeData[0]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"], quantityOfEach,
                            recipeData[0]["price"])
                        buyItem(
                            recipeData[1]["storeId"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach,
                            recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), res["price"],
                                quantityOfEach)
                        else:
                            sellItem(
                                craftItem(
                                    ItemDatabase.getItemFromName(
                                        recipeData[0]["name"])["id"],
                                    ItemDatabase.getItemFromName(
                                        recipeData[1]["name"])["id"],
                                    quantityOfEach), (res["price"] - underCut),
                                quantityOfEach)
            else:
                print "Ingredients not limited for {0}".format(term)
                quantityOfEach = min(
                    int(meatLimit / total),
                    min(recipeData[0]["quantity"], recipeData[1]["quantity"]))
                buyItem(
                    recipeData[0]["storeId"],
                    ItemDatabase.getItemFromName(recipeData[0]["name"])["id"],
                    quantityOfEach, recipeData[0]["price"])
                buyItem(
                    recipeData[1]["storeId"],
                    ItemDatabase.getItemFromName(recipeData[1]["name"])["id"],
                    quantityOfEach, recipeData[1]["price"])
                if res["storeId"] == myStoreId:
                    sellItem(
                        craftItem(
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach),
                        res["price"], quantityOfEach)
                else:
                    sellItem(
                        craftItem(
                            ItemDatabase.getItemFromName(
                                recipeData[0]["name"])["id"],
                            ItemDatabase.getItemFromName(
                                recipeData[1]["name"])["id"], quantityOfEach),
                        (res["price"] - underCut), quantityOfEach)
        else:
            print "{0} should NOT be crafted for profit. {0} has a total ingredient cost of {1}, but is selling for {2}".format(
                term, total, res["price"])
Exemple #5
0
def makeItRain():
    for term in searchTerms:
        m = MallItemSearchRequest(s, pad(term))
        res = m.doRequest()["results"][0]
        curResult = [res["price"], res["quantity"], res["id"]]
        result[term] = curResult
        print "Booze: {0}, price: {1}, quantity: {2}".format(res["name"], res["price"], res["quantity"])
        curRecipe = recipe[term]
        total = 0
        recipeData = []
        for ingredient in curRecipe:
            m = MallItemSearchRequest(s, pad(ingredient))
            searchData = m.doRequest()
            recipeData.append(searchData["results"][0])
            price = searchData["results"][0]["price"]
            total += price
        if res["price"] > total:
            print "{0} should be crafted for profit. {0} has a total ingredient cost of {1}, but is selling for {2}".format(term, total, res["price"])
            if "limit" in recipeData[0] or "limit" in recipeData[1]:
                if "limit" in recipeData[0] and "limit" not in recipeData[1]:
                    if min(recipeData[0]["quantity"], recipeData[1]["quantity"]) > recipeData[0]["limit"]:
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), recipeData[0]["limit"])
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), min(recipeData[0]["quantity"], recipeData[1]["quantity"]))
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
                elif "limit" in recipeData[1] and "limit" not in recipeData[0]:
                    if min(recipeData[0]["quantity"], recipeData[1]["quantity"]) > recipeData[1]["limit"]:
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), recipeData[1]["limit"])
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), min(recipeData[0]["quantity"], recipeData[1]["quantity"]))
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
                elif "limit" in recipeData[1] and "limit" in recipeData[0]:
                    if min(recipeData[0]["quantity"], recipeData[1]["quantity"]) > min(recipeData[1]["limit"], recipeData[0]["limit"]):
                        print "minimum is greater than limit, must limit how much we buy for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), min(recipeData[1]["limit"], recipeData[0]["limit"]))
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
                    else:
                        print "Minimum less than limit for {0}".format(term)
                        quantityOfEach = min(int(meatLimit / total), min(recipeData[0]["quantity"], recipeData[1]["quantity"]))
                        buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                        buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                        if res["storeId"] == myStoreId:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                        else:
                            sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
            else:
                print "Ingredients not limited for {0}".format(term)
                quantityOfEach = min(int(meatLimit / total), min(recipeData[0]["quantity"], recipeData[1]["quantity"]))
                buyItem(recipeData[0]["storeId"], ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], quantityOfEach, recipeData[0]["price"])
                buyItem(recipeData[1]["storeId"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach, recipeData[1]["price"])
                if res["storeId"] == myStoreId:
                    sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), res["price"], quantityOfEach)
                else:
                    sellItem(craftItem(ItemDatabase.getItemFromName(recipeData[0]["name"])["id"], ItemDatabase.getItemFromName(recipeData[1]["name"])["id"], quantityOfEach), (res["price"] - underCut), quantityOfEach)
        else:
            print "{0} should NOT be crafted for profit. {0} has a total ingredient cost of {1}, but is selling for {2}".format(term, total, res["price"])