Example #1
0
def discoveredNewItem(context, **kwargs):
    if "item" in kwargs:
        item = kwargs["item"]

        if "type" in item:
            itemType = item["type"]
        else:
            itemType = ""
        if "image" in item:
            image = item["image"]
        else:
            image = ""
        if "autosell" in item:
            autosell = item["autosell"]
        else:
            autosell = 0

        db = MySQLDatabaseManager.getDatabase("system")
        c = db.cursor()
        c.execute("INSERT INTO item (item_id, desc_id, name, image, autosell, type) values (%s, %s, %s, %s, %s, %s)", \
            (item["id"], item["descId"], item["name"], image, autosell, itemType))
        c.close()
        db.commit()

    return FilterManager.CONTINUE
def discoveredNewItem(context, **kwargs):
    if "item" in kwargs:
        item = kwargs["item"]

        if "type" in item:
            itemType = item["type"]
        else:
            itemType = ""
        if "image" in item:
            image = item["image"]
        else:
            image = ""
        if "autosell" in item:
            autosell = item["autosell"]
        else:
            autosell = 0

        db = MySQLDatabaseManager.getDatabase("system")
        c = db.cursor()
        c.execute("INSERT INTO item (item_id, desc_id, name, image, autosell, type) values (%s, %s, %s, %s, %s, %s)", \
            (item["id"], item["descId"], item["name"], image, autosell, itemType))
        c.close()
        db.commit()

    return FilterManager.CONTINUE
Example #3
0
def preInitializeItemDatabase(context, **kwargs):
    db = MySQLDatabaseManager.getDatabase("system")
    c = db.cursor()
    c.execute("SELECT * FROM item")
    row = c.fetchone()
    while row != None:
        item = {}
        item["id"] = row["item_id"]
        item["descId"] = row["desc_id"]
        item["name"] = row["name"]
        item["image"] = row["image"]
        item["autosell"] = row["autosell"]
        item["type"] = row["type"]
        ItemDatabase.addItem(item)
        row = c.fetchone()
    c.close()
    return FilterManager.FINISHED
Example #4
0
def preInitializeItemDatabase(context, **kwargs):
    db = MySQLDatabaseManager.getDatabase("system")
    c = db.cursor()
    c.execute("SELECT * FROM item")
    row = c.fetchone()
    while row != None:
        item = {}
        item["id"] = row["item_id"]
        item["descId"] = row["desc_id"]
        item["name"] = row["name"]
        item["image"] = row["image"]
        item["autosell"] = row["autosell"]
        item["type"] = row["type"]
        ItemDatabase.addItem(item)
        row = c.fetchone()
    c.close()
    context["returnCode"] = FilterManager.FINISHED
Example #5
0
def receivedDonation(context, **kwargs):
	bot = kwargs["bot"]
	meat = kwargs["meat"]
	items = kwargs["items"]
	message = kwargs["kmail"]
	state = bot.states["job"]
	
	# Get the full information about the current user.
	currentUser = state["currentUser"]
	
	# Update the user's rating.
	if "updatedUserRatingForDonation" not in state:
		db = MySQLDatabaseManager.getDatabase("system")
		c = db.cursor()
		
		newRating = currentUser["user_rating"] + meat
		c = db.cursor()
		setUserRatingTo(newRating, currentUser["user_id"], c)
		c.close()
		db.commit()
		
		state["updatedUserRatingForDonation"] = 1
		state["newUserRating"] = newRating
		bot.writeState("job")
	else:
		newRating = state["newUserRating"]
	
	# Send confirmation to the user.
	if "sentDonationThankYou" not in state:
		txt = "Thank you for the kind donation! Your user rating has increased by %s points. Your new user rating is %s." \
			% (NumberUtils.formatNumberWithCommas(meat), NumberUtils.formatNumberWithCommas(newRating))
		bot.quoteKmail(message, txt)
		state["sentDonationThankYou"] = 1
		bot.writeState("job")
	
	return FilterManager.CONTINUE