from util.nick import nickeq, nicklower

class User:
	def __init__(self, nick, mode=None, registered=False):
		self.nick = nicklower(nick)
		self.registered = registered
		self.mode = set(mode) if mode else set()

class NickDict(dict):
	def __setitem__(self, nick, value):
		dict.__setitem__(self, nicklower(nick), value)
	
	def __getitem__(self, nick):
		return dict.__getitem__(self, nicklower(nick))
	
	def __contains__(self, nick):
		return dict.__contains__(self, nicklower(nick))

	def pop(self, nick):
		return dict.pop(self, nicklower(nick))

class Channel:
	def __init__(self, name):
		self.name = name
		self.users = NickDict()
		self.topic = None
		self.mode = set()
	
	def __repr__(self):
		return "Channel({0})".format(self.name)
	
	def __contains__(self, nick):
		return nick in self.users

class ChannelList(dict):
	pass

@@ -544,16 +544,237 @@
 nick))%0A%0A
+%09def __getattr__(self, attr):%0A%09%09return self%5Battr%5D if attr in self else dict.__getattr__(self, attr)%0A%0A%09def __setattr__(self, attr, val):%0A%09%09if attr in self:%0A%09%09%09self%5Battr%5D = val%0A%09%09else:%0A%09%09%09dict.__setattr__(self, attr, val)%0A%0A
 class Ch
@@ -1049,9 +1049,155 @@
 ):%0A%09
-pass
+def __getattr__(self, attr):%0A%09%09return self%5Battr%5D if attr in self else None%0A%0A%09def __setattr__(self, attr, val):%0A%09%09if attr in self:%0A%09%09%09self%5Battr%5D = val%0A
 %0A

add attribute set/get methods for channels