[project @ 2005-07-04 01:48:38 by unknown_lamer]
authorunknown_lamer <unknown>
Mon, 4 Jul 2005 01:48:38 +0000 (01:48 +0000)
committerunknown_lamer <unknown>
Mon, 4 Jul 2005 01:48:38 +0000 (01:48 +0000)
Big documentation enhancements. All hooks are now documented. Changed
hooks/send/message to match dest and pass dest to send hook. Changed
hooks/signoff to take a second argument (intentional flag). A few
source cleanups (lazy catch handlers are now methods of the Interp
class).

15 files changed:
ChangeLog
NEWS
bobot++.info
bobot++.texinfo
scripts/bobot-utils.scm
source/Bot.C
source/BotInterp.C
source/BotInterp.H
source/Commands.C
source/Interp.C
source/Interp.H
source/Parser.C
source/ScriptCommands.C
source/ScriptCommands.H
source/ServerQueue.C

index 758dd8b..8af66ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,70 @@
+2005-07-03  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * bobot++.texinfo (Hook Types): Documented all hooks
+
+       * source/ServerQueue.C (sendPrivmsg): Changed SEND_MESSAGE hook to
+       match dest and pass dest to send hook
+
+       * bobot++.texinfo (Hook Types): Changed language of
+       hooks/dcc/chat-* hook documention
+       (Received Message Hooks): Added subsub section of Hook Types
+       (Sent Message Hooks): Added subsub section of Hook Types
+       (DCC CHAT Hooks): Added subsub section of Hook Types
+       (Miscellaneous Hooks): Added subsub section of Hook Types
+
+       * source/Parser.C (parseScriptFunction): Changed
+       lazy_apply_wrapper to Interp::LazyApplyWrapper
+       (parseScriptFunction): Changed empty_handler to Interp::EmptyHandler
+       (parsePart): Grammar fix in log (Leaved => Left)
+
+       * source/Interp.H (Interp): Added LazyHandler method
+
+       * source/BotInterp.C (RunHooks): changed lazy_apply_wrapper to
+       Interp::LazyApplyWrapper
+       (RunTimers): Changed empty_handler to Interp::EmptyHandler
+       (RunHooks): Changed empty_handler to Interp::EmptyHandler
+       (RunTimers): Changed lazy_apply_wrapper to Interp::LazyApplyWrapper
+
+       * source/Interp.C (LazyHandler): Renamed from lazy_handler
+       (ScmApplyWrapper): Renamed from scm_apply_wrapper
+       (EmptyHandler): Renamed from empty_handler
+
+       * source/Interp.H (Interp): Removed ErrorHandler method
+       (Interp): Added LazyApplyWrapper method
+       (Interp): Added EmptyHandler method
+       (Interp): Added ScmApplyWrapper method
+
+       * scripts/bobot-utils.scm: Added hooks/leave as an alias for hooks/part
+       Added begin-deprecated around deprecated definitions
+       (_deprecated-fun): Added macro to define an alias for a function
+       and issue a deprecation warning when used
+       Converted all bot- aliases to use _deprecated-fun
+
+       * source/Interp.C (interp_init_helper): Changed Hook::LEAVE to
+       Hook::PART
+       (interp_init_helper): Removed definition of hooks/leave
+
+       * bobot++.texinfo (Hook Types): Removed stub for hooks/leave, only
+       document hooks/part name (hooks/leave still exists, but will not
+       be documented as it is the same as hooks/part)
+
+       * source/Parser.C (parsePart): Use Hook::PART instead of Hook::LEAVE
+
+       * source/BotInterp.H: Removed Hook::LEAVE, added Hook::PART
+
+       * bobot++.texinfo (Scripting): Added note about most arguments
+       being strings
+
+       * source/Commands.C (NextServer): Call hooks/disconnect
+
+       * source/Bot.C (run): Pass extra argument to Hook::DISCONNECT
+
+       * bobot++.texinfo (Creating a Hook): Reformatted the bot:addhook
+       section to make it more readable
+       (Hook Types): Reformatted hooks/action
+       (Hook Types): Changed grammar of hooks/nickname (their => his)
+       (Hook Types): Documented hooks/signoff
+
 2005-06-29  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * bobot++.texinfo: Updated copyright years, changed "applies to
diff --git a/NEWS b/NEWS
index ef40a83..a2a7eb2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,16 @@ IMPORTANT NOTES:
 =====================================================================
 
 Version 2.1.9:
+- Scripting
+  + hooks/disconnect now takes an additonal argument that specifies
+    whether the disconnect was intentional or not.
+  + The deprecated scripting procedure and hook names are now in a
+    `begin-deprecated' block. If your guile is built without
+    deprecated feature support, they will not be available.
+- Documention
+  + Reorganized a few sections
+  + Every hook is now documented
+- The code was cleaned up a bit
 
 Version 2.1.8: 
 - Scripting
index b60c532..912e273 100644 (file)
@@ -18,9 +18,9 @@ File: bobot++.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
    This document describes Bobot++ by Clinton Ebadi and Etienne Bernard
 (original author, no longer works on program).
 
-   This document applies to version 2.1.5 of the program named Bobot++
+   This document applies to version 2.2 of the program named Bobot++
 
-   Copyright 2002,2004 Clinton Ebadi
+   Copyright 2002,2004,2005 Clinton Ebadi
 
    Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.1 or
@@ -76,6 +76,13 @@ Hooks
 * Creating a Hook::
 * Hook Types::
 
+Hook Types
+
+* Received Message Hooks::
+* Sent Message Hooks::
+* DCC CHAT Hooks::
+* Miscellaneous Hooks::
+
 Sending Messages
 
 * High Level Message Functions::
@@ -507,6 +514,9 @@ Bobot++ 3.0. New commands are only available with the `bot:' prefix.
 The command `perl -pi -e ``s/bot-/bot:/g'' YOUR-FILES' should be enough
 to convert your code to use the new functions.
 
+   *NOTE*: All arguments to functions and hooks called by the bot are
+strings unless otherwise specified.
+
 * Menu:
 
 * Adding New Commands::
@@ -545,7 +555,7 @@ Adding a new command is simple. To register a new command use
           (bot:addcommand "hello" hello #t 2 0)
 
      This will display "Hello World!" if called as `!hello' and "Hello
-     World `USER'" if called as `!hello USER'.
+     World USER" if called as `!hello USER'.
 
 \1f
 File: bobot++.info,  Node: Hooks,  Next: Scheme User Levels,  Prev: Adding New Commands,  Up: Scripting
@@ -582,19 +592,27 @@ To add a new hook you use the function `bot:addhook'.
 
  -- Function: bot:addhook type regex function [pri fall name]
      TYPE specifies the type of hook (the types of hooks are listed in
-     *Note Hook Types::). REGEX is a standard regular expression. If
-     REGEX is matched, FUNCTION will be called. FUNCTION will take a
-     different number of args depending on the hook type. PRI specifies
-     the priority of the hook--higher priority hooks are executed
-     first. This argument is optional and defaults to `0'. FALL is `#t'
-     if the hook is a fallthrough hook and `#f' is the hook is not a
-     fallthrough hook. This arg is also optional and default to `#t'.
-     NAME is the optional name of the hook that defaults to "DEFAULT".
-     If you set the name then you can have more than one hook that
-     matches the same regexp, as long as they have the same name. E.g.
-     in a log script you could have the regexps for the log function
-     all be `".*"' and set their names to `"log"' to avoid a conflict
-     with other hooks.
+     *Note Hook Types::).
+
+     REGEX is a standard regular expression. If REGEX is matched,
+     FUNCTION will be called.
+
+     FUNCTION will take a different number of args depending on the
+     hook type.
+
+     PRI specifies the priority of the hook--higher priority hooks are
+     executed first. This argument is optional and defaults to `0'.
+
+     FALL is `#t' if the hook is a fallthrough hook and `#f' is the
+     hook is not a fallthrough hook. This arg is also optional and
+     defaults to `#t'.
+
+     NAME is the optional name of the hook that defaults to
+     `"DEFAULT"'. If you set the name then you can have more than one
+     hook that matches the same regexp, as long as they have the same
+     name. E.g. in a log script you could have the regexps for the log
+     function all be `".*"' and set their names to `"log"' to avoid a
+     conflict with other hooks.
 
 \1f
 File: bobot++.info,  Node: Hook Types,  Prev: Creating a Hook,  Up: Hooks
@@ -602,83 +620,261 @@ File: bobot++.info,  Node: Hook Types,  Prev: Creating a Hook,  Up: Hooks
 4.2.2 Hook Types
 ----------------
 
-Here is a list of the various hooks funtions and notes on each one. The
-general format of each hook description is as if it were a function to
-be defined, but these describe the function to be passwd to
+The following sections document the different hooks Bobot++ exposes.
+
+   The general format of each hook description is as if it were a
+function to be defined, but these describe the function to be passwd to
 `bot:add-hook'.  Do _not_ name your functions these names.
 
    That said, here is the list of available hooks functions.  FIXME:
 write docs
 
+* Menu:
+
+* Received Message Hooks::
+* Sent Message Hooks::
+* DCC CHAT Hooks::
+* Miscellaneous Hooks::
+
+\1f
+File: bobot++.info,  Node: Received Message Hooks,  Next: Sent Message Hooks,  Prev: Hook Types,  Up: Hook Types
+
+4.2.2.1 Receieved Message Hooks
+...............................
+
+The following hooks are triggered when a mesage is received by the bot.
+
  -- Function: hooks/action from to action
-     This hook is triggered when someone performs an action.  FROM is
-     the address of the person that performed the action in the form
-     `NICK ! USER @ HOST' (without the spaces).  TO is the target of
-     the action, which is either a channel or the Bot's nick.  ACTION
-     is the text of the action. E.g. if someone did `* foobar does
-     baz', then ACTION would be the string `"does baz"'.
+     This hook is triggered when someone performs an action.
+
+     FROM is the nickname the person that performed the action.
+
+     TO is the target of the action, which is either a channel or the
+     Bot's nick if the user private messages the bot.
+
+     ACTION is the text of the action. E.g. if someone did `* foobar
+     does baz', then ACTION would be the string `"does baz"'.
 
  -- Function: hooks/nickname old-nick new-nick
-     This hook gets called when someone changes thir nickname from
+     This hook is called when someone changes his nickname from
      OLD-NICK to NEW-NICK.
 
- -- Function: hooks/signoff nick rest
+ -- Function: hooks/signoff nick message
+     This hook is called when someone signs off of IRC.
+
+     NICK is the nickname of the person signing off.
+
+     MESSAGE is his quit message
 
  -- Function: hooks/ctcp nick to command rest
+     This hook is called when a CTCP request is received by the bot.
+
+     NICK is the nickname of the sender.
+
+     TO is the target of the CTCP request. This will either be a
+     channel the bot is in, or the nickname of the bot.
+
+     COMMAND is the CTCP command issued.
+
+     REST contains the arguments to the CTCP command.
 
  -- Function: hooks/ctcp-reply nick command rest
+     This hook is called when a CTCP REPLY is received. This occurs when
+     the bot has sent a CTCP request to another client. The CTCP REPLY
+     is always addressed to the bot directly.
 
- -- Function: hooks/disconnect server
-     This is called when the bot is disconnected from a server
-     unintentionally. `hooks/signoff' is called when the bot
-     purposefully disconnected. The hook function is passed the
-     hostname of the server it was disconnected from.
+     NICK is the nickname of the person who replied.
 
- -- Function: hooks/flood nick
+     COMMAND is the command to which NICK is replying.
+
+     REST contains the body of the reply.
+
+ -- Function: hooks/disconnect server intentional
+     This is called when the bot is disconnected from a server.
+
+     SERVER is the hostname of the server from which the bot was
+     disconnected.
+
+     INTENTIONAL is a flag set to `#t' when the bot disonnected from
+     the server as the result of a command (issued by a user from IRC,
+     SIGHUP, or from a script), or `#f' when the bot disconnected from
+     the server unintentionally..
 
  -- Function: hooks/invite nick channel
+     This hook is called when a user invited the bot to join a channel.
+
+     NICK is the nickname of the user who sent the invite.
+
+     CHANNEL is the channel to which the bot was invited.
 
  -- Function: hooks/join nick channel
+     This is called when a user or the bot joins a channel.
+
+     NICK is the nickname of the user who joined CHANNEL. This may be
+     the bot's nickname (the IRC server sends the JOIN command back to
+     the the bot after it joins a channel).
+
+     CHANNEL is the channel that was joined
 
  -- Function: hooks/kick target from channel reason
+     This hook is called when a user, including the bot, is kicked out
+     of a channel.
+
+     TARGET is the nick of the user who was kicked. This may be the
+     bot's nick.
+
+     FROM is the nick of the user who issued the kick. This may also be
+     the bot's nick.
+
+     CHANNEL is the channel the kick was issued in.
+
+     REASON is the reason the user was kicked.
 
- -- Function: hooks/leave nick channel
  -- Function: hooks/part nick channel
+     This hook is called when a user parts a channel.
+
+     NICK is the user who parted the channel. This may be the bot.
+
+     CHANNEL is the channel from which the user parted.
+
+ -- Function: hooks/mode nick target modes
+     This hook is called when someone sets the modes of TARGET.
 
- -- Function: hooks/mode nick channel modes
+     NICK is the user who set the modes. This may be the bot.
 
- -- Function: hooks/message from message
+     TARGET is the target of the MODE command. This may be a channel or
+     a user. If it is a user, it may be the bot.
+
+     MODES is the MODE string.
+
+ -- Function: hooks/message nick message
+     This hook is called when someone sends a private message to the
+     bot.
+
+     NICK is the nickname of the user who sent the message.
+
+     MESSAGE is the message the user sent.
 
  -- Function: hooks/notice nick message
+     This hook is called when a user send a private notice to the bot.
+
+     NICK is the user who sent the notice.
+
+     MESSAGE is the message the user sent.
 
- -- Function: hooks/public from to message
+ -- Function: hooks/public nick channel message
+     This hook is called when a user sends a normal message to a
+     channel.
 
- -- Function: hooks/public-notice nick to message
+     NICK is the user who sent the message.
+
+     CHANNEL is the channel to which the message was sent.
+
+     MESSAGE is the message that was sent.
+
+ -- Function: hooks/public-notice nick channel message
+     This hook is called when a user send a notice to a channel.
+
+     NICK is the user who sent the notice.
+
+     CHANNEL is the channel to which the notice was sent.
+
+     MESSAGE is the message that was sent.
 
  -- Function: hooks/raw raw-message
+     This hook is called every time a message is received. This matches
+     on the raw message text and passes the hook function the raw IRC
+     message.
 
- -- Function: hooks/timer time
-     This hook seems to be called once a minute.  TIME is in `hh:mm'
-     format.
+     RAW-MESSAGE is the raw IRC message.
 
  -- Function: hooks/topic nick channel new-topic
+     This hook is called when a user changes the topic in a channel.
+
+     NICK is the user who set the topic. This may be the bot.
+
+     CHANNEL is the channel that's topic was changed.
+
+     NEW-TOPIC is the new topic.
+
+\1f
+File: bobot++.info,  Node: Sent Message Hooks,  Next: DCC CHAT Hooks,  Prev: Received Message Hooks,  Up: Hook Types
 
- -- Function: hooks/send/public mynick dest message
+4.2.2.2 Sent Message Hooks
+..........................
 
- -- Function: hooks/send/message botnick message
+These hooks are called when the bot sends a message. MYNICK is always
+the bot's nick and will not be documented in each hook description.
+
+ -- Function: hooks/send/public mynick channel message
+     This hook is called when the bot sends a normal message to a
+     channel.
+
+     CHANNEL is the channel to which the bot sent the message.
+
+     MESSAGE is the message the bot sent.
+
+ -- Function: hooks/send/message mynick to message
+     This hook is called when the bot sends a private message to a user.
+
+     TO is the nick of the user to whom the message was sent.
+
+     MESSAGE is the message that was sent.
 
  -- Function: hooks/send/action mynick to message
+     This hook is called when the bot sents an action to a channel or a
+     user.
+
+     TO is the channel or nick of the user to which the action was sent.
+
+     MESSAGE is the text of the action.
 
  -- Function: hooks/send/ctcp mynick to command message
+     This hook is called when the bot sends a CTCP message _other than_
+     an ACTION to a channel or user.
+
+     TO is the channel or nick of the user to which the CTCP was sent.
+
+     COMMAND is the CTCP command that was sent.
+
+     MESSAGE is a string containing the arguments to the CTCP command.
+
+\1f
+File: bobot++.info,  Node: DCC CHAT Hooks,  Next: Miscellaneous Hooks,  Prev: Sent Message Hooks,  Up: Hook Types
+
+4.2.2.3 DCC CHAT Hooks
+......................
+
+These hooks are called when a user initializes a DCC CHAT and when the
+bot receives messages from the user in a DCC CHAT.
 
  -- Function: hooks/dcc/chat-begin from
-     This hook is triggered when a user begins a DCC CHAT with the bot.
+     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-message from message
-     This hook is triggered when a user sends a message to the bot
-     through a DCC CHAT FROM is the user's address in the form
-     `nick!user@host'.  MESSAGE is the message the user sent to the bot.
+     This hook is called when a user sends a message to the bot through
+     a DCC CHAT.
+
+     FROM is the user's address in the form `nick!user@host'.
+
+     MESSAGE is the message the user sent to the bot.
+
+\1f
+File: bobot++.info,  Node: Miscellaneous Hooks,  Prev: DCC CHAT Hooks,  Up: Hook Types
+
+4.2.2.4 Miscellaneous Hooks
+...........................
+
+ -- Function: hooks/flood nick
+     This hook is called when a user is detected flooding the bot.
+
+     NICK is the nickname of the user flooding the bot.
+
+ -- Function: hooks/timer time
+     This hook is called once a minute. The regex is *not* used.
+
+     TIME is the in zero-padded `hh:mm' format.
 
 \1f
 File: bobot++.info,  Node: Scheme User Levels,  Next: Sending Messages,  Prev: Hooks,  Up: Scripting
@@ -1113,32 +1309,48 @@ Function Index
                                                               (line 145)
 * bot:use-module:                        Misc Scripting Stuff.
                                                               (line 188)
-* hooks/action:                          Hook Types.          (line  15)
-* hooks/ctcp:                            Hook Types.          (line  29)
-* hooks/ctcp-reply:                      Hook Types.          (line  31)
-* hooks/dcc/chat-begin:                  Hook Types.          (line  76)
-* hooks/dcc/chat-message:                Hook Types.          (line  80)
-* hooks/disconnect:                      Hook Types.          (line  33)
-* hooks/flood:                           Hook Types.          (line  39)
-* hooks/invite:                          Hook Types.          (line  41)
-* hooks/join:                            Hook Types.          (line  43)
-* hooks/kick:                            Hook Types.          (line  45)
-* hooks/leave:                           Hook Types.          (line  47)
-* hooks/message:                         Hook Types.          (line  52)
-* hooks/mode:                            Hook Types.          (line  50)
-* hooks/nickname:                        Hook Types.          (line  23)
-* hooks/notice:                          Hook Types.          (line  54)
-* hooks/part:                            Hook Types.          (line  48)
-* hooks/public:                          Hook Types.          (line  56)
-* hooks/public-notice:                   Hook Types.          (line  58)
-* hooks/raw:                             Hook Types.          (line  60)
-* hooks/send/action:                     Hook Types.          (line  72)
-* hooks/send/ctcp:                       Hook Types.          (line  74)
-* hooks/send/message:                    Hook Types.          (line  70)
-* hooks/send/public:                     Hook Types.          (line  68)
-* hooks/signoff:                         Hook Types.          (line  27)
-* hooks/timer:                           Hook Types.          (line  62)
-* hooks/topic:                           Hook Types.          (line  66)
+* hooks/action:                          Received Message Hooks.
+                                                              (line   9)
+* hooks/ctcp:                            Received Message Hooks.
+                                                              (line  31)
+* 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/disconnect:                      Received Message Hooks.
+                                                              (line  54)
+* hooks/flood:                           Miscellaneous Hooks. (line   7)
+* hooks/invite:                          Received Message Hooks.
+                                                              (line  65)
+* hooks/join:                            Received Message Hooks.
+                                                              (line  72)
+* hooks/kick:                            Received Message Hooks.
+                                                              (line  81)
+* hooks/message:                         Received Message Hooks.
+                                                              (line 112)
+* hooks/mode:                            Received Message Hooks.
+                                                              (line 102)
+* hooks/nickname:                        Received Message Hooks.
+                                                              (line  20)
+* hooks/notice:                          Received Message Hooks.
+                                                              (line 120)
+* hooks/part:                            Received Message Hooks.
+                                                              (line  95)
+* hooks/public:                          Received Message Hooks.
+                                                              (line 127)
+* hooks/public-notice:                   Received Message Hooks.
+                                                              (line 137)
+* hooks/raw:                             Received Message Hooks.
+                                                              (line 146)
+* hooks/send/action:                     Sent Message Hooks.  (line  25)
+* hooks/send/ctcp:                       Sent Message Hooks.  (line  33)
+* hooks/send/message:                    Sent Message Hooks.  (line  18)
+* hooks/send/public:                     Sent Message Hooks.  (line  10)
+* hooks/signoff:                         Received Message Hooks.
+                                                              (line  24)
+* hooks/timer:                           Miscellaneous Hooks. (line  12)
+* hooks/topic:                           Received Message Hooks.
+                                                              (line 153)
 
 \1f
 File: bobot++.info,  Node: Variable Index,  Prev: Function Index,  Up: Top
@@ -1163,32 +1375,36 @@ Variable Index
 \1f
 Tag Table:
 Node: Top\7f527
-Node: Introduction\7f1816
-Node: Configuration\7f2008
-Node: Configuration File Placement\7f2295
-Node: Configuration Files\7f2795
-Node: bot.conf\7f2988
-Node: server syntax\7f4426
-Node: channel syntax\7f5290
-Node: bot.users\7f6133
-Node: Using the Bot\7f7036
-Node: Starting the Bot\7f7286
-Node: User Levels\7f8795
-Node: Protection\7f10197
-Node: Automatic Op\7f10805
-Node: Built-In Commands\7f11094
-Node: Scripting\7f18073
-Node: Adding New Commands\7f19038
-Node: Hooks\7f20361
-Node: Creating a Hook\7f21201
-Node: Hook Types\7f22384
-Node: Scheme User Levels\7f25151
-Node: Sending Messages\7f26285
-Node: High Level Message Functions\7f26901
-Node: Low Level Message Functions\7f27681
-Node: Misc Scripting Stuff\7f28744
-Node: Concept Index\7f35320
-Node: Function Index\7f35539
-Node: Variable Index\7f45670
+Node: Introduction\7f1925
+Node: Configuration\7f2117
+Node: Configuration File Placement\7f2404
+Node: Configuration Files\7f2904
+Node: bot.conf\7f3097
+Node: server syntax\7f4535
+Node: channel syntax\7f5399
+Node: bot.users\7f6242
+Node: Using the Bot\7f7145
+Node: Starting the Bot\7f7395
+Node: User Levels\7f8904
+Node: Protection\7f10306
+Node: Automatic Op\7f10914
+Node: Built-In Commands\7f11203
+Node: Scripting\7f18182
+Node: Adding New Commands\7f19254
+Node: Hooks\7f20575
+Node: Creating a Hook\7f21415
+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
 \1f
 End Tag Table
index cef1828..767a859 100644 (file)
@@ -102,6 +102,13 @@ Hooks
 * Creating a Hook::             
 * Hook Types::                  
 
+Hook Types
+
+* Received Message Hooks::      
+* Sent Message Hooks::          
+* DCC CHAT Hooks::              
+* Miscellaneous Hooks::         
+
 Sending Messages
 
 * High Level Message Functions::  
@@ -549,6 +556,9 @@ available with the @code{bot:} prefix. The command @command{perl -pi
 -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to convert
 your code to use the new functions.
 
+@strong{NOTE}: All arguments to functions and hooks called by the bot
+are strings unless otherwise specified.
+
 @menu
 * Adding New Commands::         
 * Hooks::                       
@@ -586,7 +596,7 @@ An example of a new command would be:
 @end example
 
 This will display ``Hello World!'' if called as @kbd{!hello} and
-``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}.
+``Hello World @var{USER}'' if called as @kbd{!hello @var{USER}}.
 @end defun
 
 @node Hooks, Scheme User Levels, Adding New Commands, Scripting
@@ -620,26 +630,36 @@ To add a new hook you use the function @code{bot:addhook}.
 
 @defun bot:addhook type regex function [pri fall name]
 @var{type} specifies the type of hook (the types of hooks are listed
-in @ref{Hook Types}). @var{regex} is a standard regular expression. If
-@var{regex} is matched, @var{function} will be called. @var{function}
-will take a different number of args depending on the hook
-type. @var{pri} specifies the priority of the hook---higher priority
-hooks are executed first. This argument is optional and defaults to
-@code{0}. @var{fall} is @code{#t} if the hook is a fallthrough hook
-and @code{#f} is the hook is not a fallthrough hook. This arg is also
-optional and default to @code{#t}.  @var{name} is the optional name of
-the hook that defaults to ``DEFAULT''. If you set the name then you
-can have more than one hook that matches the same regexp, as long as
-they have the same name. E.g. in a log script you could have the
-regexps for the log function all be @code{".*"} and set their names to
-@code{"log"} to avoid a conflict with other hooks.
+in @ref{Hook Types}). 
+
+@var{regex} is a standard regular expression. If
+@var{regex} is matched, @var{function} will be called. 
+
+@var{function} will take a different number of args depending on the
+hook type. 
+
+@var{pri} specifies the priority of the hook---higher priority hooks
+are executed first. This argument is optional and defaults to
+@code{0}. 
+
+@var{fall} is @code{#t} if the hook is a fallthrough hook and
+@code{#f} is the hook is not a fallthrough hook. This arg is also
+optional and defaults to @code{#t}.
+
+@var{name} is the optional name of the hook that defaults to
+@code{"DEFAULT"}. If you set the name then you can have more than
+one hook that matches the same regexp, as long as they have the same
+name. E.g. in a log script you could have the regexps for the log
+function all be @code{".*"} and set their names to @code{"log"} to
+avoid a conflict with other hooks.
 @end defun
 
 @node Hook Types,  , Creating a Hook, Hooks
 @subsection Hook Types
 
-Here is a list of the various hooks funtions and notes on each
-one. The general format of each hook description is as if it were a
+The following sections document the different hooks Bobot++ exposes.
+
+The general format of each hook description is as if it were a
 function to be defined, but these describe the function to be passwd
 to @code{bot:add-hook}.  Do @emph{not} name your functions these
 names.
@@ -647,102 +667,265 @@ names.
 That said, here is the list of available hooks functions.
 FIXME: write docs
 
+@menu
+* Received Message Hooks::      
+* Sent Message Hooks::          
+* DCC CHAT Hooks::              
+* Miscellaneous Hooks::         
+@end menu
+
+@node Received Message Hooks, Sent Message Hooks, Hook Types, Hook Types
+@subsubsection Receieved Message Hooks
+
+The following hooks are triggered when a mesage is received by the bot.
+
 @defun hooks/action from to action
-This hook is triggered when someone performs an action.  @var{from} is
-the address of the person that performed the action in the form
-@samp{@var{nick} ! @var{user} @@ @var{host}} (without the spaces).
+This hook is triggered when someone performs an action.
+
+@var{from} is the nickname the person that performed the
+action.
+
 @var{to} is the target of the action, which is either a channel or the
-Bot's nick.  @var{action} is the text of the action. E.g. if someone
-did @samp{* foobar does baz}, then @var{action} would be the string
-@code{"does baz"}.
-@end defun
+Bot's nick if the user private messages the bot.
 
+@var{action} is the text of the action. E.g. if someone did @samp{*
+foobar does baz}, then @var{action} would be the string @code{"does
+baz"}.
+@end defun
 
 @defun hooks/nickname old-nick new-nick
-This hook gets called when someone changes thir nickname from
+This hook is called when someone changes his nickname from
 @var{old-nick} to @var{new-nick}.
 @end defun
 
-@defun hooks/signoff nick rest
+@defun hooks/signoff nick message
+This hook is called when someone signs off of IRC.
+
+@var{nick} is the nickname of the person signing off.
+
+@var{message} is his quit message
 @end defun
 
 @defun hooks/ctcp nick to command rest
+This hook is called when a CTCP request is received by the bot.
+
+@var{nick} is the nickname of the sender.
+
+@var{to} is the target of the CTCP request. This will either be a
+channel the bot is in, or the nickname of the bot.
+
+@var{command} is the CTCP command issued.
+
+@var{rest} contains the arguments to the CTCP command.
 @end defun
 
 @defun hooks/ctcp-reply nick command rest
-@end defun
+This hook is called when a CTCP REPLY is received. This occurs when
+the bot has sent a CTCP request to another client. The CTCP REPLY is
+always addressed to the bot directly.
+
+@var{nick} is the nickname of the person who replied.
+
+@var{command} is the command to which @var{nick} is replying.
 
-@defun hooks/disconnect server
-This is called when the bot is disconnected from a server
-unintentionally. @code{hooks/signoff} is called when the bot purposefully
-disconnected. The hook function is passed the hostname of the
-server it was disconnected from.
+@var{rest} contains the body of the reply.
 @end defun
 
-@defun hooks/flood nick
+@defun hooks/disconnect server intentional
+This is called when the bot is disconnected from a server.
+
+@var{server} is the hostname of the server from which the bot was
+disconnected.
+
+@var{intentional} is a flag set to @code{#t} when the bot disonnected
+from the server as the result of a command (issued by a user from IRC,
+SIGHUP, or from a script), or @code{#f} when the bot disconnected from
+the server unintentionally..
 @end defun
 
 @defun hooks/invite nick channel
+This hook is called when a user invited the bot to join a channel.
+
+@var{nick} is the nickname of the user who sent the invite.
+
+@var{channel} is the channel to which the bot was invited.
 @end defun
 
 @defun hooks/join nick channel
+This is called when a user or the bot joins a channel.
+
+@var{nick} is the nickname of the user who joined @var{channel}. This
+may be the bot's nickname (the IRC server sends the JOIN command back
+to the the bot after it joins a channel).
+
+@var{channel} is the channel that was joined
 @end defun
 
 @defun hooks/kick target from channel reason
+This hook is called when a user, including the bot, is kicked out of a
+channel.
+
+@var{target} is the nick of the user who was kicked. This may be the
+bot's nick.
+
+@var{from} is the nick of the user who issued the kick. This may also
+be the bot's nick.
+
+@var{channel} is the channel the kick was issued in.
+
+@var{reason} is the reason the user was kicked.
 @end defun
 
-@defun hooks/leave nick channel
-@defunx hooks/part nick channel
+@defun hooks/part nick channel
+This hook is called when a user parts a channel.
+
+@var{nick} is the user who parted the channel. This may be the bot.
+
+@var{channel} is the channel from which the user parted.
 @end defun
 
-@defun hooks/mode nick channel modes
+@defun hooks/mode nick target modes
+This hook is called when someone sets the modes of @var{target}.
+
+@var{nick} is the user who set the modes. This may be the bot.
+
+@var{target} is the target of the MODE command. This may be a
+channel or a user. If it is a user, it may be the bot.
+
+@var{modes} is the MODE string.
 @end defun
 
-@defun hooks/message from message
+@defun hooks/message nick message
+This hook is called when someone sends a private message to the bot.
+
+@var{nick} is the nickname of the user who sent the message.
+
+@var{message} is the message the user sent.
 @end defun
 
 @defun hooks/notice nick message
+This hook is called when a user send a private notice to the bot.
+
+@var{nick} is the user who sent the notice.
+
+@var{message} is the message the user sent.
 @end defun
 
-@defun hooks/public from to message
+@defun hooks/public nick channel message
+This hook is called when a user sends a normal message to a channel.
+
+@var{nick} is the user who sent the message.
+
+@var{channel} is the channel to which the message was sent.
+
+@var{message} is the message that was sent.
 @end defun
 
-@defun hooks/public-notice nick to message
+@defun hooks/public-notice nick channel message
+This hook is called when a user send a notice to a channel.
+
+@var{nick} is the user who sent the notice.
+
+@var{channel} is the channel to which the notice was sent.
+
+@var{message} is the message that was sent.
 @end defun
 
 @defun hooks/raw raw-message
-@end defun
+This hook is called every time a message is received. This matches on
+the raw message text and passes the hook function the raw IRC message.
 
-@defun hooks/timer time
-This hook seems to be called once a minute.  @var{time} is in
-@code{hh:mm} format.
+@var{raw-message} is the raw IRC message.
 @end defun
 
 @defun hooks/topic nick channel new-topic
+This hook is called when a user changes the topic in a channel.
+
+@var{nick} is the user who set the topic. This may be the bot.
+
+@var{channel} is the channel that's topic was changed.
+
+@var{new-topic} is the new topic.
 @end defun
 
-@defun hooks/send/public mynick dest message
+@node Sent Message Hooks, DCC CHAT Hooks, Received Message Hooks, Hook Types
+@subsubsection Sent Message Hooks
+
+These hooks are called when the bot sends a message. @var{mynick} is
+always the bot's nick and will not be documented in each hook
+description.
+
+@defun hooks/send/public mynick channel message
+This hook is called when the bot sends a normal message to a channel.
+
+@var{channel} is the channel to which the bot sent the message.
+
+@var{message} is the message the bot sent.
 @end defun
 
-@defun hooks/send/message botnick message
+@defun hooks/send/message mynick to message
+This hook is called when the bot sends a private message to a user.
+
+@var{to} is the nick of the user to whom the message was sent.
+
+@var{message} is the message that was sent.
 @end defun
 
 @defun hooks/send/action mynick to message
+This hook is called when the bot sents an action to a channel or a
+user.
+
+@var{to} is the channel or nick of the user to which the action was
+sent.
+
+@var{message} is the text of the action.
 @end defun
 
 @defun hooks/send/ctcp mynick to command message
+This hook is called when the bot sends a CTCP message @emph{other
+than} an ACTION to a channel or user.
+
+@var{to} is the channel or nick of the user to which the CTCP was
+sent.
+
+@var{command} is the CTCP command that was sent.
+
+@var{message} is a string containing the arguments to the CTCP command.
 @end defun
 
+@node DCC CHAT Hooks, Miscellaneous Hooks, Sent Message Hooks, Hook Types
+@subsubsection DCC CHAT Hooks
+
+These hooks are called when a user initializes a DCC CHAT and when the
+bot receives messages from the user in a DCC CHAT.
+
 @defun hooks/dcc/chat-begin from
-This hook is triggered when a user begins a DCC CHAT with the bot.
+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-message from message
-This hook is triggered when a user sends a message to the bot through
-a DCC CHAT @var{from} is the user's address in the form
-@samp{nick!user@@host}.  @var{message} is the message the user sent to
-the bot.
+This hook is called when a user sends a message to the bot through
+a DCC CHAT.
+
+@var{from} is the user's address in the form @samp{nick!user@@host}.
+
+@var{message} is the message the user sent to the bot.
+@end defun
+
+@node Miscellaneous Hooks,  , DCC CHAT Hooks, Hook Types
+@subsubsection Miscellaneous Hooks
+
+@defun hooks/flood nick
+This hook is called when a user is detected flooding the bot.
+
+@var{nick} is the nickname of the user flooding the bot.
+@end defun
+
+@defun hooks/timer time
+This hook is called once a minute. The regex is @strong{not} used.
+
+@var{time} is the in zero-padded @code{hh:mm} format.
 @end defun
 
 @node Scheme User Levels, Sending Messages, Hooks, Scripting
index afb9f36..4f7b6d1 100644 (file)
 ;;; DEPRECATED FUNCTION NAMES
 ;;; These are provided for backwards compatibility
 ;;; and will be removed in the 3.0 release
-
-(define-public bot-load bot:load)
-(define-public bot-action bot:action)
-(define-public bot-adduser bot:adduser)
-(define-public bot-addserver bot:addserver)
-(define-public bot-addshit bot:addshit)
-(define-public bot-ban bot:ban)
-(define-public bot-cycle bot:cycle)
-(define-public bot-deban bot:deban)
-(define-public bot-delserver bot:delserver)
-(define-public bot-deluser bot:deluser)
-(define-public bot-delshit bot:delshit)
-(define-public bot-deop bot:deop)
-(define-public bot-die bot:die)
-(define-public bot-do bot:do)
-(define-public bot-invite bot:invite)
-(define-public bot-join bot:join)
-(define-public bot-keep bot:keep)
-(define-public bot-kick bot:kick)
-(define-public bot-kickban bot:kickban)
-(define-public bot-lock bot:lock)
-(define-public bot-logport bot:logport)
-(define-public bot-mode bot:mode)
-(define-public bot-msg bot:msg)
-(define-public bot-nextserver bot:nextserver)
-(define-public bot-nick bot:nick)
-(define-public bot-op bot:op)
-(define-public bot-part bot:part)
-(define-public bot-reconnect bot:reconnect)
-(define-public bot-say bot:say)
-(define-public bot-server bot:server)
-(define-public bot-setversion bot:setversion)
-(define-public bot-tban bot:tban)
-(define-public bot-tkban bot:tkban)
-(define-public bot-topic bot:topic)
-(define-public bot-unlock bot:unlock)
-(define-public bot-getnickname bot:getnickname)
-(define-public bot-getserver bot:getserver)
-(define-public bot-getserverlist bot:getserverlist)
-(define-public bot-flush bot:flush)
-(define-public bot-flushport bot:flushport)
-(define-public bot-random bot:random)
-(define-public bot-addcommand bot:addcommand)
-(define-public bot-delcommand bot:delcommand)
-(define-public bot-addhook bot:addhook)
-(define-public bot-addtimer bot:addtimer)
-(define-public bot-deltimer bot:deltimer)
\ No newline at end of file
+(begin-deprecated
+
+ (define-macro (_deprecated-fun old-name new-name)
+   `(define-public ,old-name
+      (lambda args
+       (issue-deprecation-warning
+        (string-append
+         (symbol->string ',old-name)
+         " is a deprecated function. Please use "
+         (symbol->string ',new-name) " instead."))
+       (apply ,new-name args))))
+     
+ (_deprecated-fun bot-load bot:load)
+ (_deprecated-fun bot-action bot:action)
+ (_deprecated-fun bot-adduser bot:adduser)
+ (_deprecated-fun bot-addserver bot:addserver)
+ (_deprecated-fun bot-addshit bot:addshit)
+ (_deprecated-fun bot-ban bot:ban)
+ (_deprecated-fun bot-cycle bot:cycle)
+ (_deprecated-fun bot-deban bot:deban)
+ (_deprecated-fun bot-delserver bot:delserver)
+ (_deprecated-fun bot-deluser bot:deluser)
+ (_deprecated-fun bot-delshit bot:delshit)
+ (_deprecated-fun bot-deop bot:deop)
+ (_deprecated-fun bot-die bot:die)
+ (_deprecated-fun bot-do bot:do)
+ (_deprecated-fun bot-invite bot:invite)
+ (_deprecated-fun bot-join bot:join)
+ (_deprecated-fun bot-keep bot:keep)
+ (_deprecated-fun bot-kick bot:kick)
+ (_deprecated-fun bot-kickban bot:kickban)
+ (_deprecated-fun bot-lock bot:lock)
+ (_deprecated-fun bot-logport bot:logport)
+ (_deprecated-fun bot-mode bot:mode)
+ (_deprecated-fun bot-msg bot:msg)
+ (_deprecated-fun bot-nextserver bot:nextserver)
+ (_deprecated-fun bot-nick bot:nick)
+ (_deprecated-fun bot-op bot:op)
+ (_deprecated-fun bot-part bot:part)
+ (_deprecated-fun bot-reconnect bot:reconnect)
+ (_deprecated-fun bot-say bot:say)
+ (_deprecated-fun bot-server bot:server)
+ (_deprecated-fun bot-setversion bot:setversion)
+ (_deprecated-fun bot-tban bot:tban)
+ (_deprecated-fun bot-tkban bot:tkban)
+ (_deprecated-fun bot-topic bot:topic)
+ (_deprecated-fun bot-unlock bot:unlock)
+ (_deprecated-fun bot-getnickname bot:getnickname)
+ (_deprecated-fun bot-getserver bot:getserver)
+ (_deprecated-fun bot-getserverlist bot:getserverlist)
+ (_deprecated-fun bot-flush bot:flush)
+ (_deprecated-fun bot-flushport bot:flushport)
+ (_deprecated-fun bot-random bot:random)
+ (_deprecated-fun bot-addcommand bot:addcommand)
+ (_deprecated-fun bot-delcommand bot:delcommand)
+ (_deprecated-fun bot-addhook bot:addhook)
+ (_deprecated-fun bot-addtimer bot:addtimer)
+ (_deprecated-fun bot-deltimer bot:deltimer)
+ (define-public hooks/leave hooks/part))
\ No newline at end of file
index 0260d93..64b4e46 100644 (file)
@@ -330,12 +330,13 @@ Bot::run()
        {
          // Disconnected
 #ifdef USESCRIPTS
-         // Run hooks/disconnected
+         // Run hooks/disconnect
          this->botInterp->RunHooks 
            (Hook::DISCONNECT, 
             serverConnection->server->getHostName (),
             scm_list_n 
-            (Utils::str2scm  (serverConnection->server->getHostName ())));
+            (Utils::str2scm  (serverConnection->server->getHostName ()),
+             SCM_BOOL_F));
 #endif
          nextServer();
        }
index 01ba996..e020cfd 100644 (file)
@@ -1,6 +1,6 @@
 // BotInterp.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
@@ -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"
@@ -115,9 +116,10 @@ BotInterp::RunHooks(int hooktype, String match, SCM args)
       {
        wd.func = (*it)->function;
        result = scm_internal_catch(SCM_BOOL_T, 
-                                   (scm_t_catch_body) lazy_apply_wrapper,
+                                   (scm_t_catch_body) 
+                                   Interp::LazyApplyWrapper,
                                    static_cast<void *> (&wd), 
-                                   (scm_t_catch_handler) empty_handler, 0);
+                                   (scm_t_catch_handler) Interp::EmptyHandler, 0);
        if (! (*it)->fallthru)
          break;
     }
@@ -168,8 +170,8 @@ BotInterp::RunTimers(int now)
     if ((*it)->when <= now) {
       wd.func = (*it)->function;
       scm_internal_catch(SCM_BOOL_T,
-                    (scm_t_catch_body) lazy_apply_wrapper, (void *)&wd,
-                    (scm_t_catch_handler) empty_handler, 0);
+                    (scm_t_catch_body) Interp::LazyApplyWrapper, (void *)&wd,
+                    (scm_t_catch_handler) Interp::EmptyHandler, 0);
       scm_gc_unprotect_object(wd.func);
       it3 = it;
       ++it3;
index 85644aa..4ce1a2f 100644 (file)
@@ -76,8 +76,8 @@ struct Hook {
 
   enum {
     ACTION, NICKNAME, SIGNOFF, CTCP, CTCP_REPLY,
-    DISCONNECT, FLOOD, INVITE, JOIN, KICK, LEAVE,
-    MODE, MESSAGE, NAMES, NOTICE, PUBLIC,
+    DISCONNECT, FLOOD, INVITE, JOIN, KICK, MODE, 
+    MESSAGE, NAMES, NOTICE, PART, PUBLIC,
     PUBLIC_NOTICE, RAW, TIMER, TOPIC,
     // send hooks
     SEND_ACTION, SEND_CTCP, SEND_PUBLIC, SEND_MESSAGE,
index f222380..fb181e9 100644 (file)
@@ -588,6 +588,16 @@ Commands::NextServer(Bot *bot)
 
   if (!bot->canChangeServer())
     return CanNotChangeServer;
+
+#ifdef USESCRIPTS
+  // Run hooks/disconnect
+  bot->botInterp->RunHooks 
+    (Hook::DISCONNECT, 
+     bot->serverConnection->server->getHostName (),
+     scm_list_n 
+     (Utils::str2scm  (bot->serverConnection->server->getHostName ()),
+      SCM_BOOL_T));
+#endif
   
   QUEUE->sendQuit("Changing server");
   bot->nextServer();
index 1107f57..161b89f 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"
@@ -40,7 +41,7 @@ pthread_mutex_t Interp::mutex = PTHREAD_MUTEX_INITIALIZER;
 typedef SCM (*SCMFunc)();
 
 SCM
-scm_apply_wrapper(void *data)
+Interp::ScmApplyWrapper (void *data)
 {
 #ifdef MULTITHREAD
   //  pthread_mutex_lock (&Interp::mutex);
@@ -56,8 +57,8 @@ scm_apply_wrapper(void *data)
   return SCM_BOOL_T;
 }
 
-static SCM
-lazy_handler(void *data, SCM tag, SCM throw_args)
+SCM
+Interp::LazyHandler (void *data, SCM tag, SCM throw_args)
 {
   SCM log_port = Interp::bot->botInterp->ScriptLog();
   SCM eport = scm_set_current_error_port(log_port);
@@ -70,18 +71,20 @@ lazy_handler(void *data, SCM tag, SCM throw_args)
 }
 
 SCM
-empty_handler(void *data, SCM tag, SCM args)
+Interp::EmptyHandler(void *data, SCM tag, SCM args)
 {
   return SCM_UNSPECIFIED;
 }
 
 
 SCM
-lazy_apply_wrapper(void *data)
+Interp::LazyApplyWrapper(void *data)
 {
   return scm_internal_lazy_catch(SCM_BOOL_T,
-                                (scm_t_catch_body) scm_apply_wrapper, data,
-                                (scm_t_catch_handler) lazy_handler, 0);
+                                (scm_t_catch_body) Interp::ScmApplyWrapper, 
+                                data,
+                                (scm_t_catch_handler) Interp::LazyHandler, 
+                                0);
 }
 
 
@@ -89,8 +92,9 @@ static SCM
 lazy_eval_file(char *filename)
 {
   return scm_internal_lazy_catch(SCM_BOOL_T,
-                                (scm_t_catch_body) scm_c_primitive_load, filename,
-                                (scm_t_catch_handler) lazy_handler, 0);
+                                (scm_t_catch_body) scm_c_primitive_load, 
+                                filename,
+                                (scm_t_catch_handler) Interp::LazyHandler, 0);
 }
 
 static SCM
@@ -98,7 +102,7 @@ lazy_eval_string(char *str)
 {
   return scm_internal_lazy_catch(SCM_BOOL_T,
                                 (scm_t_catch_body) scm_c_eval_string, str,
-                                (scm_t_catch_handler) lazy_handler, 0);
+                                (scm_t_catch_handler) Interp::LazyHandler, 0);
 }
 
 
@@ -147,11 +151,10 @@ interp_init_helper (void* unused)
   scm_c_define ("hooks/invite", scm_long2num(Hook::INVITE));
   scm_c_define ("hooks/join", scm_long2num(Hook::JOIN));
   scm_c_define ("hooks/kick", scm_long2num(Hook::KICK));
-  scm_c_define ("hooks/leave", scm_long2num(Hook::LEAVE));
-  scm_c_define ("hooks/part", scm_long2num(Hook::LEAVE));
   scm_c_define ("hooks/mode", scm_long2num(Hook::MODE));
   scm_c_define ("hooks/message", scm_long2num(Hook::MESSAGE));
   scm_c_define ("hooks/notice", scm_long2num(Hook::NOTICE));
+  scm_c_define ("hooks/part", scm_long2num(Hook::PART));
   scm_c_define ("hooks/public", scm_long2num(Hook::PUBLIC));
   scm_c_define ("hooks/public-notice", scm_long2num(Hook::PUBLIC_NOTICE));
   scm_c_define ("hooks/raw", scm_long2num(Hook::RAW));
@@ -300,7 +303,7 @@ Interp::Execute(Bot *b, String command)
   bot = b;
   scm_internal_catch(SCM_BOOL_T,
                     (scm_t_catch_body) lazy_eval_string, (void *) static_cast<const char *> (command),
-                    (scm_t_catch_handler) empty_handler, 0);
+                    (scm_t_catch_handler) Interp::EmptyHandler, 0);
   
 #ifdef MULTITHREAD
   // We release the lock
@@ -318,8 +321,9 @@ Interp::LoadScript(Bot *b, String filename)
 #endif
   bot = b;
   scm_internal_catch(SCM_BOOL_T,
-                    (scm_t_catch_body) lazy_eval_file, (void *)static_cast<const char * >(filename),
-                    (scm_t_catch_handler) empty_handler, 0);
+                    (scm_t_catch_body) lazy_eval_file, 
+                    (void *)static_cast<const char * >(filename),
+                    (scm_t_catch_handler) Interp::EmptyHandler, 0);
 #ifdef MULTITHREAD
   // We release the lock
   pthread_mutex_unlock(&mutex);
index 2708d97..752f1b1 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 INTERP_H
 #define INTERP_H
@@ -38,9 +39,6 @@ struct wrapper_data {
   SCM args;
 };
 
-SCM lazy_apply_wrapper(void *);
-SCM empty_handler(void *, SCM, SCM);
-
 class Interp {
 public:
   static Bot *bot;
@@ -54,9 +52,11 @@ public:
   static void Shutdown();
   static void Execute(Bot *, String);
   static void LoadScript(Bot *, String);
-  static SCM ErrorHandler(void *, SCM, SCM);
 
-  friend SCM scm_apply_wrapper (void*);
+  static SCM LazyApplyWrapper (void *);
+  static SCM EmptyHandler (void *, SCM, SCM);
+  static SCM LazyHandler (void *, SCM, SCM);
+  static SCM ScmApplyWrapper (void *);
 };
 
 #endif
index c950955..1dd60cb 100644 (file)
@@ -33,7 +33,7 @@
 #include "ShitList.H"
 
 typedef void (*fptr) (ServerConnection *, Person *, String);
-std::map < std::string, fptr, std::less < std::string > >Parser::functions;
+std::map < std::string, fptr, std::less < std::string > > Parser::functions;
 
 void
 Parser::init ()
@@ -714,7 +714,7 @@ Parser::parsePart (ServerConnection * cnx, Person * from, String rest)
   StringTokenizer st (rest);
   String channel = st.next_token ();
 #ifdef USESCRIPTS
-  cnx->bot->botInterp->RunHooks (Hook::LEAVE, n + " " + channel,
+  cnx->bot->botInterp->RunHooks (Hook::PART, n + " " + channel,
                                 scm_listify (Utils::
                                              str2scm (n),
                                              Utils::
@@ -723,7 +723,7 @@ Parser::parsePart (ServerConnection * cnx, Person * from, String rest)
 #endif
   if (n.toLower () == cnx->bot->nickName.toLower ())
     {
-      cnx->bot->logLine (String ("Leaved channel ") + channel + ".");
+      cnx->bot->logLine (String ("Left channel ") + channel + ".");
       cnx->bot->channelList->delChannel (channel);
     }
   else
@@ -1047,7 +1047,8 @@ Parser::parseScriptFunction (ServerConnection * cnx,
   wd.func = scmFunc;
   wd.args = args_list;
   scm_internal_catch (SCM_BOOL_T,
-                     (scm_t_catch_body) lazy_apply_wrapper, (void *) &wd,
-                     (scm_t_catch_handler) empty_handler, 0);
+                     (scm_t_catch_body) Interp::LazyApplyWrapper, 
+                     (void *) &wd,
+                     (scm_t_catch_handler) Interp::EmptyHandler, 0);
 }
 #endif
index 4eb4c72..cbf39f1 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"
index 689931d..ab8b9aa 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 SCRIPTCOMMANDS_H
 #define SCRIPTCOMMANDS_H
index 03ae0f3..4fa02c0 100644 (file)
@@ -233,14 +233,14 @@ ServerQueue::sendPrivmsg(String dest, String message)
                                                     str2scm
                                                     (message), SCM_UNDEFINED));
     else
-      Interp::bot->botInterp->RunHooks (Hook::SEND_MESSAGE,
-                                       Interp::bot->nickName + " " +
-                                       message,
-                                       scm_listify (Utils::
-                                                    str2scm (Interp::bot->nickName),
-                                                    Utils::
-                                                    str2scm
-                                                    (message), SCM_UNDEFINED));
+      Interp::bot->botInterp->RunHooks 
+       (Hook::SEND_MESSAGE,
+        Interp::bot->nickName + " " + dest +
+        message,
+        scm_listify (Utils::str2scm (Interp::bot->nickName),
+                     Utils::str2scm (dest),
+                     Utils::str2scm
+                     (message), SCM_UNDEFINED));
 #endif
 }