예제 #1
0
	def __setitem__(self,key,values):
		del self[key] #delete the old values
		if type(values) is str:
			#probably a mistake, just one value is wanted
			values=(values,)
		for value in values:
			database.query('INSERT INTO `users` VALUES (%s,%s,%s)', (self.username,key,value))
예제 #2
0
	def search(self,names):
		if type(names) is str:
			#probably a mistake, only one is wanted
			return (self[names],)
		string = ' OR '.join(map(lambda name: '`id` = "%s"' % name,names))
		database.query('SELECT * FROM `bans` WHERE %s ORDER BY `bans`.`expires` DESC' % (string))
		return tuple(database.cursor.fetchall())
예제 #3
0
	def __getitem__(self,name):
		database.query('SELECT * FROM `bans` WHERE `id` = "%s" ORDER BY `bans`.`expires` DESC LIMIT 1' % (name))
		
		if database.cursor.rowcount==0:
			raise KeyError("No such ban: %s" % (name))
		
		return database.cursor.fetchone()
예제 #4
0
	def search(self,key,value):
		database.query('SELECT `user` FROM `users` WHERE `key` = %s and `value` = %s', (key, value))
		result=database.cursor.fetchone()
		if result is not None:
			return self[result[0]]
		else:
			return None
예제 #5
0
	def __getitem__(self,username):
		database.query('SELECT `user` FROM `users` WHERE `user` = %s AND `key` = "privileges"', (username,))
		
		if database.cursor.rowcount==0:
			raise KeyError("No such user: %s" % (username,))
		
		return User(username)
예제 #6
0
 def __setitem__(self, name, values):
     try:
         del self[name]
     except:
         pass
     database.query("INSERT INTO `bans` VALUES (%s,%s,%s)", (name, values[0], values[1]))
예제 #7
0
	def cleargbans(self):
		database.query('DELETE FROM `bans` WHERE `reason` = "gban"')
예제 #8
0
	def __delitem__(self,name):
		database.query('DELETE FROM `bans` WHERE `id` = "%s"' % (name))
예제 #9
0
	def __setitem__(self,name,values):
		try:
			del self[name]
		except:
			pass
		database.query('INSERT INTO `bans` VALUES ("%s","%s","%s")' % (name,values[0],values[1]))
예제 #10
0
	def items(self):
		database.query('SELECT * FROM `bans` ORDER BY `bans`.`expires` DESC')
		return tuple(database.cursor.fetchall())
예제 #11
0
	def items(self):
		database.query('SELECT * FROM `users` where `key` = "privileges"')
		return tuple(database.cursor.fetchall())
예제 #12
0
	def __delitem__(self, key):
		database.query('DELETE FROM `users` WHERE `user` = %s AND `key` = %s', (self.username,key))
예제 #13
0
 def __delitem__(self, name):
     database.query("DELETE FROM `bans` WHERE `id` = %s", (name))
예제 #14
0
	def __getitem__(self,key):
		database.query('SELECT value FROM `users` WHERE `user` = %s AND `key` = %s', (self.username,key))
		return tuple(row[0] for row in database.cursor.fetchall())
예제 #15
0
	def items(self):
		database.query('SELECT `key`,`value` FROM `users` WHERE `user` = %s', (self.username,))
		return (("username",self.username),)+tuple(database.cursor.fetchall())
예제 #16
0
	def __delitem__(self,username):
		database.query('DELETE FROM `users` WHERE `user` = %s', (username,))
예제 #17
0
	def __delitem__(self,username):
		database.query('DELETE FROM `users` WHERE `user` = "%s"' % (username))
예제 #18
0
 def clearbans(self):
     database.query(
         "DELETE FROM `bans` WHERE `expires` < DATE_ADD(UTC_TIMESTAMP(),interval 60 minute) AND `expires` NOT LIKE '0000-00-00 00:00:00'"
     )