Fix crash when providing bad command line argument
[clinton/bobotpp.git] / source / DCCParser.C
index 6604197..f04c0f6 100644 (file)
@@ -1,6 +1,6 @@
 // DCCParser.C  -*- C++ -*-
 // Copyright (c) 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2005 Clinton Ebadi
 
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "DCCParser.H"
+
+#include "DCCConnection.H"
 #include "DCCPerson.H"
-#include "Macros.H"
 #include "Parser.H"
-#include "Bot.H"
+#include "Utils.H"
+
+#ifdef USESCRIPTS
+#include "BotInterp.H"
+#endif
 
 void
 DCCParser::parseLine(DCCConnection *cnx, String line)
 {
   Person * from = new DCCPerson(cnx);
-  Parser::parseMessage(cnx->bot->serverConnection, from, cnx->bot->nickName,
+#ifdef USESCRIPTS
+  // Call hooks/dcc/chat-message hook functions
+  cnx->get_bot()->botInterp->RunHooks (Hook::DCC_CHAT_MESSAGE, 
+                                from->getAddress () + " " + line,
+                                scm_list_n 
+                                      (Utils::str2scm (from->getAddress ()),
+                                       Utils::str2scm (line),
+                                       SCM_UNDEFINED));
+#endif
+  Parser::parseMessage(cnx->get_bot()->serverConnection, 
+                      from, cnx->get_bot()->nickName,
                        line);
   delete from;
 }