Encapsulate obscure detail that lower numeric priority is higher queue priority
[clinton/bobotpp.git] / source / DCCManager.C
index ad0c824..2437fea 100644 (file)
@@ -1,5 +1,5 @@
 // DCCManager.H  -*- C++ -*-
-// 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.
 
 #include "DCCManager.H"
+#include "Utils.H"
 
 void
 DCCManager::addConnection (DCCConnection *cnx)
@@ -57,6 +59,18 @@ DCCManager::checkStale ()
       if (temp_cnx->get_autoRemove () && std::time (0) >= 
          (std::time_t)(temp_cnx->get_lastSpoken () + Bot::DCC_DELAY))
        {
+#ifdef USESCRIPTS
+         DCCPerson *dp = new DCCPerson ((DCCConnection *) temp_cnx);
+
+         // run hooks/dcc/chat-end
+         dp->bot->botInterp->RunHooks 
+           (Hook::DCC_CHAT_END, 
+            dp->getAddress (),
+            scm_list_n (Utils::
+                        str2scm (dp->getAddress ()),
+                        SCM_UNDEFINED));
+         delete dp;
+#endif
          delete it->second;
          dcc_map.erase (it);
        }
@@ -86,6 +100,19 @@ DCCManager::checkInput (fd_set rd)
          {
            if (it2->second->handleInput()) 
              {
+#ifdef USESCRIPTS
+               DCCPerson *dp = new DCCPerson (*it2->second);
+
+               // run hooks/dcc/chat-end
+               dp->bot->botInterp->RunHooks 
+                 (Hook::DCC_CHAT_END, 
+                  dp->getAddress (),
+                  scm_list_n (Utils::
+                              str2scm (dp->getAddress ()),
+                              SCM_UNDEFINED));
+               delete dp;
+#endif
+
                delete it2->second->dcc;
                delete it2->second;
                dcc_map.erase(it2);