[Tutor] Hey. trying to set a data base.

Keitaro Kaoru tokyo.rook at gmail.com
Mon Sep 10 21:37:39 CEST 2012

my imports are
import json
import time
from tools import Arguments

@Arguments(mincount = 0, maxcount = 2)
def rank(mgr, room, user, msg, params):
	if mgr.isRoomLocked(room) and not user.name == "mr": return
	if len(params) < 2:
		if len(params) == 0: name = user.name
		else: name = params[0]
		tg = ch.User(name)
		tgrank = mgr.getRank(tg)
		data = shared_db.get("level:" + tg.name)
		data == json.loads(data)
		if data[1] == "level":
			mgr.sendObject(room, Html("<b><font color='#999999'>%s's</font></b>
rank is <b><font color='#FF9900'>%s</font></b> <font
color='#FF9900'>(%i)</font>, set <b><i><font
color='#009999'>%s</font></i></b> ago by <b><font
color='#0099CC'>%s</font></b>.", tg.name.title(),
mgr.getRankName(tgrank).title(), tgrank, tdelta(data[3]),
		if mgr.getRank(user) < 2: return
		name, level = params
			level = int(level)
		except ValueError:
				level = mgr.rankNames[level.lower()]
			except KeyError:
				return Error("Invalid rank name.")
		srcrank = mgr.getRank(user)
		tg = ch.User(name)
		tgrank = mgr.getRank(tg)
		if user == tg: return Error("You're not allowed to set your own
rank, silly goose. :3")
		if srcrank == level: return Error("You're not allowed to set people
to a higher or equal rank than you.")
		if tgrank == srcrank: return Error("Did you really think that would
work :|. wow people are dummer than i thought.")
		mgr.setRank(tg, level)
		shared_db.set("level:" + tg.name, json.dumps([room.name, "level",
user.name, time.time()]))
		return Html("<b>%s</b>'s rank set to <b>%s</b> (%i).",
tg.name.title(), mgr.getRankName(level).title(), level)

thats my db.. trying to set ranks for people.and make a db so i can
see how long ago i did it. and by who did it.

 Kawaii:  [mrvjj] [error] /usr/lib/python3.2/json/decoder.py: 345:
TypeError(expected string or buffer)

i get that error...


More information about the Tutor mailing list