Anonymous avatar Anonymous committed 44478df

Server now sends empty MOTD message, some clients require it. Server now sends ERR_UNKNOWNCOMMAND on unknown command.

git-svn-id: https://svn.electricmonk.nl/svn/hircd/trunk@20 73c2b06a-06ba-454a-85af-d11de2e08ddc

Comments (0)

Files changed (1)

 ERR_NOSUCHNICK       = '401'
 ERR_NOSUCHCHANNEL    = '403'
 ERR_CANNOTSENDTOCHAN = '404'
+ERR_UNKNOWNCOMMAND   = '421'
 ERR_ERRONEUSNICKNAME = '432'
 ERR_NICKNAMEINUSE    = '433'
 ERR_NEEDMOREPARAMS   = '461'
                                 params = ''
                             handler = getattr(self, 'handle_%s' % (command.lower()), None)
                             if not handler:
+                                logging.info('No handler for command: %s' % (line))
+                                raise IRCError(ERR_UNKNOWNCOMMAND, '%s :Unknown command' % (command))
                                 # FIXME: Raise an error here and send it to the client.
-                                logging.info('No handler for command: %s' % (line))
                                 break
                             response = handler(params)
                         except AttributeError, e:
                 # Someone else is using the nick
                 raise IRCError(ERR_NICKNAMEINUSE, 'NICK :%s' % (nick))
             else:
-                # Nick is available, register and send welcome
+                # Nick is available, register, send welcome and MOTD.
                 self.nick = nick
                 self.server.clients[nick] = self
                 response = ':%s %s %s :%s' % (self.server.servername, RPL_WELCOME, self.nick, SRV_WELCOME)
-                return(response)
+                self.send_queue.append(response)
+                response = ':%s 376 %s :End of MOTD command.' % (self.server.servername, self.nick)
+                self.send_queue.append(response)
+                return()
         else:
             if self.server.clients.get(nick, None) == self:
                 # Already registered to user
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.