[project @ 2005-07-04 08:15:08 by unknown_lamer]
authorunknown_lamer <unknown>
Mon, 4 Jul 2005 08:15:08 +0000 (08:15 +0000)
committerunknown_lamer <unknown>
Mon, 4 Jul 2005 08:15:08 +0000 (08:15 +0000)
hooks/dcc/chat-end is now called when a chat is killed for being idle,
and when a chat is closed by the user on the other end. It was also
documented.

12 files changed:
ChangeLog
TODO
bobot++.info
bobot++.texinfo
scripts/bobot-utils.scm
source/Bot.C
source/BotInterp.H
source/DCCConnection.H
source/DCCManager.C
source/DCCParser.C
source/Interp.C
source/ServerQueue.H

index 8af66ea..a2aaca2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-07-04  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/DCCManager.C (checkInput):
+
+       * scripts/bobot-utils.scm (bot:log): Updated to use bot:logport
+       instead of bot-logport
+
+       * source/Interp.C (interp_init_helper): Add hooks/dcc/chat-end
+       constant to Scheme
+
+       * bobot++.texinfo (DCC CHAT Hooks): Document hooks/dcc/chat-end
+
+       * source/BotInterp.H: Add DCC_CHAT_END to enum
+
+       * source/DCCManager.C (checkStale): Run hooks/dcc/chat-end when
+       deleting a stale connection.
+
 2005-07-03  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * bobot++.texinfo (Hook Types): Documented all hooks
diff --git a/TODO b/TODO
index 5ff87a4..ced8d56 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,6 +9,7 @@ Done:
 * Utils::valid_nickname_p should have a configurable max nick length
 * More detailed script error reporting
 * Commands::sendCTCP, Commands::sendCTCPReply
+* Add DCC_CHAT_END hook for Scheme
 
 2.2:
 * Finish Texinfo manual
@@ -16,7 +17,6 @@ Done:
   (e.g. bot:send-CTCP to send a CTCP message)
 * Add util functions for doing stuff like quoting CTCP messages
 * Finish adding hooks/send hooks
-* Add DCC_CHAT_END hook for Scheme
 
 2.4: 
 * Use configuration database class
index 912e273..5883a10 100644 (file)
@@ -852,6 +852,14 @@ bot receives messages from the user in a DCC CHAT.
      This hook is called when a user begins a DCC CHAT with the bot.
      FROM is the user's address in the form `nick!user@host'.
 
+ -- Function: hooks/dcc/chat-end address
+     This hook is called when a DCC CHAT is purged after being idle for
+     a while, or when the user closes the DCC CHAT. As such, you cannot
+     write any more data to the DCC CHAT.
+
+     ADDRESS is the address (nick!user@host) of the person on the other
+     side of the DCC.
+
  -- Function: hooks/dcc/chat-message from message
      This hook is called when a user sends a message to the bot through
      a DCC CHAT.
@@ -1316,7 +1324,8 @@ Function Index
 * hooks/ctcp-reply:                      Received Message Hooks.
                                                               (line  43)
 * hooks/dcc/chat-begin:                  DCC CHAT Hooks.      (line  10)
-* hooks/dcc/chat-message:                DCC CHAT Hooks.      (line  14)
+* hooks/dcc/chat-end:                    DCC CHAT Hooks.      (line  14)
+* hooks/dcc/chat-message:                DCC CHAT Hooks.      (line  22)
 * hooks/disconnect:                      Received Message Hooks.
                                                               (line  54)
 * hooks/flood:                           Miscellaneous Hooks. (line   7)
@@ -1397,14 +1406,14 @@ Node: Hook Types\7f22621
 Node: Received Message Hooks\7f23185
 Node: Sent Message Hooks\7f28412
 Node: DCC CHAT Hooks\7f29809
-Node: Miscellaneous Hooks\7f30526
-Node: Scheme User Levels\7f30975
-Node: Sending Messages\7f32109
-Node: High Level Message Functions\7f32725
-Node: Low Level Message Functions\7f33505
-Node: Misc Scripting Stuff\7f34568
-Node: Concept Index\7f41144
-Node: Function Index\7f41363
-Node: Variable Index\7f52526
+Node: Miscellaneous Hooks\7f30849
+Node: Scheme User Levels\7f31298
+Node: Sending Messages\7f32432
+Node: High Level Message Functions\7f33048
+Node: Low Level Message Functions\7f33828
+Node: Misc Scripting Stuff\7f34891
+Node: Concept Index\7f41467
+Node: Function Index\7f41686
+Node: Variable Index\7f52922
 \1f
 End Tag Table
index 767a859..47f1d53 100644 (file)
@@ -904,6 +904,15 @@ This hook is called when a user begins a DCC CHAT with the bot.
 @var{from} is the user's address in the form @samp{nick!user@@host}.
 @end defun
 
+@defun hooks/dcc/chat-end address
+This hook is called when a DCC CHAT is purged after being idle for a
+while, or when the user closes the DCC CHAT. As such, you cannot write
+any more data to the DCC CHAT.
+
+@var{address} is the address (nick!user@@host) of the person on the
+other side of the DCC.
+@end defun
+
 @defun hooks/dcc/chat-message from message
 This hook is called when a user sends a message to the bot through
 a DCC CHAT.
index 4f7b6d1..b9d6b66 100644 (file)
@@ -25,8 +25,8 @@
   (for-each
    (lambda (x)
      (if (thunk? x)
-       (display (x) (bot-logport))
-       (display x (bot-logport))))
+       (display (x) (bot:logport))
+       (display x (bot:logport))))
    messages)
   (bot:flushport))
 
index 64b4e46..8a38d01 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #include <fstream>
 #include <algorithm>
index 4ce1a2f..959a172 100644 (file)
@@ -82,7 +82,7 @@ struct Hook {
     // send hooks
     SEND_ACTION, SEND_CTCP, SEND_PUBLIC, SEND_MESSAGE,
     // DCC hooks
-    DCC_CHAT_BEGIN, DCC_CHAT_MESSAGE
+    DCC_CHAT_BEGIN, DCC_CHAT_END, DCC_CHAT_MESSAGE
   };  
 };
 
index c203b8f..916add9 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #ifndef DCCCONNECTION_H
 #define DCCCONNECTION_H
index caf855d..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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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);
index f0028a9..6ca0fa8 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -34,9 +35,10 @@ DCCParser::parseLine(DCCConnection *cnx, String line)
   // 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));
+                                scm_list_n 
+                                      (Utils::str2scm (from->getAddress ()),
+                                       Utils::str2scm (line),
+                                       SCM_UNDEFINED));
 #endif
   Parser::parseMessage(cnx->get_bot()->serverConnection, 
                       from, cnx->get_bot()->nickName,
index 161b89f..27ad0fb 100644 (file)
@@ -168,6 +168,8 @@ interp_init_helper (void* unused)
   // dcc hooks
   scm_c_define ("hooks/dcc/chat-begin", 
                scm_long2num (Hook::DCC_CHAT_BEGIN));
+  scm_c_define ("hooks/dcc/chat-end",
+               scm_long2num (Hook::DCC_CHAT_END));
   scm_c_define ("hooks/dcc/chat-message", 
                scm_long2num (Hook::DCC_CHAT_MESSAGE));
 
index 8881ec9..399a9ce 100644 (file)
@@ -14,7 +14,8 @@
 
 // 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
 
 #ifndef SERVERQUEUE_H
 #define SERVERQUEUE_H