# Things which will never be supported:
+# - Parting doesn't work properly.
+# - Return erro 421 ERR_UNKNOWNCOMMAND on invalid command.
+# - Delete channel if last user leaves.
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
+SRV_WELCOME = "Welcome to %s v%s, the ugliest IRC server in the world." % (SRV_NAME, SRV_VERSION)
ERR_NOSUCHCHANNEL = '403'
+ERR_CANNOTSENDTOCHAN = '404'
ERR_ERRONEUSNICKNAME = '432'
ERR_NICKNAMEINUSE = '433'
ERR_NEEDMOREPARAMS = '461'
# Nick is available, register and send welcome
self.server.clients[nick] = self
- response = ':%s %s %s :
Welcome to the ugliest IRC server in the world.' % (self.server.servername, RPL_WELCOME, self.nick)
+ response = ':%s %s %s :' % (self.server.servername, RPL_WELCOME, self.nick)
if self.server.clients.get(nick, None) == self:
# FIXME: Do not allow msg to channel if user isn't in it.
channel = self.server.channels.get(target)
+ if not channel.name in self.channels:
+ raise IRCError(ERR_CANNOTSENDTOCHAN, '%s :Cannot send to channel' % (channel.name))
for client in channel.clients:
response = ':%s 403 %s :%s' % (self.server.servername, pchannel, pchannel)
+ def handle_dump(self, params):
+ Dump internal server information for debugging purposes.
+ print "Clients:", self.server.clients
+ for client in self.server.clients.values():
+ for channel in client.channels.values():
+ print " ", channel.name
+ print "Channels:", self.server.channels
+ for channel in self.server.channels.values():
+ print " ", channel.name, channel
+ for client in channel.clients:
+ print " ", client.nick, client
Return the client identifier as included in many command replies.