Beispiel #1
0
	def craftItem( self, event, canal ):
		msg = event.msg.split(" ", 1)[1]
		if len(msg.split("#", 1)) == 2:
			user = User.getUserByNick(event.nick)
			if user:
				if user["money"] >= 1:
					User.addMoney(event.nick, -1)
					msg = event.msg.split(" ", 1)[1]
					itemTitle = msg.split("#")[0]
					itemDescription = msg.split("#")[1]
					item = Item.craftItem(itemTitle, itemDescription, event.nick)
					if item:
						message = "You" if canal else event.nick
						message += " have crafted [" + item["title"] + "] for 1 botcoin"
						self.bot.send(message, canal)
				else:
					message = "You" if canal else event.nick
					message += " dont' have enough money"
					message += ", you need at least 1 botcoin" if canal else ""
					message += " to do that"
					self.bot.send(message, canal)
			else:
				self.bot.send("Something went wrong... Sorry", canal)
		else:
			self.bot.send("Use like this : \"botcoin.craftItem <title>#<description>\"", canal)
Beispiel #2
0
from time import time
from botcoin import database, User, Item, commands
from random import random
import math

cursorExecute = database.cursorExecute

database.init()
User.init(cursorExecute)
Item.init(cursorExecute)


def secondsToTime( seconds ):
	result = ""
	atLeastOneMinute = False
	arLeastOneHour = False
	if math.floor(seconds / 3600)>0:
		arLeastOneHour = True
		result += str(math.floor(seconds / 3600)) + " hour"
		if math.floor(seconds / 3600)>=2: result += "s"
		seconds = math.floor(seconds % 3600)
	if math.floor(seconds / 60)>0:
		atLeastOneMinute = True
		if arLeastOneHour:
			result += ", "
		result += str(math.floor(seconds / 60)) + " minute"
		if math.floor(seconds / 60)>=2: result += "s"
		seconds = math.floor(seconds % 60)
	if atLeastOneMinute:
		result += " and "
	result += str(seconds) + " second"