[project @ 2005-07-06 19:32:18 by unknown_lamer]
authorunknown_lamer <unknown>
Wed, 6 Jul 2005 19:32:19 +0000 (19:32 +0000)
committerunknown_lamer <unknown>
Wed, 6 Jul 2005 19:32:19 +0000 (19:32 +0000)
Added bot:who and bot:whois functions

14 files changed:
ChangeLog
NEWS
TODO
bobot++.info
bobot++.texinfo
source/Commands.C
source/Commands.H
source/Interp.C
source/Interp.H
source/Message.H
source/ScriptCommands.C
source/ScriptCommands.H
source/UserCommands.C
source/Utils.H

index 6ef201d..7d0c40f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2005-07-06  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * bobot++.texinfo (Misc Scripting Stuff): Documented bot:who and
+       bot:whois
+
+       * source/Interp.C (interp_init_helper): Add bot:who and bot:whois
+       bindings to Scheme
+
+       * source/ScriptCommands.C (Who): Implemented Who method
+       Removed IQUEUE macro (no longer needed)
+       (Whois): Implemented Whois method
+
+       * source/ScriptCommands.H: Added Who and Whois methods
+
+       * source/Commands.C (Who): Implemented Who
+       (Whois): Implemented Whois
+
+       * source/Commands.H: Add Who and Whois tethods
+
+       * source/Interp.C: Updated copyright notice
+       (interp_init_helper): Remove send from CTCP/CTCPReply method names
+
+       * source/Interp.H: Updated copyright notice
+
+       * source/ScriptCommands.C (CTCP): Renamed from sendCTCP
+       (CTCPReply): Renamed from sendCTCPReply
+
 2005-07-05  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * bobot++.texinfo (Low Level Message Functions): Updated docs to
diff --git a/NEWS b/NEWS
index c18a654..05acab9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ Version 2.1.9:
     deprecated feature support, they will not be available.
   + RENAME: bot:send-ctcp was renamed to bot:ctcp
   + RENAME: bot:send-ctcp-reply was renamed to bot:ctcp-reply
+  + Added bot:who function
+  + Added bot:whois function
 - Documention
   + Reorganized a few sections
   + Every hook is now documented
diff --git a/TODO b/TODO
index 25ef4a2..99aaada 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,13 +10,12 @@ Done (2.2):
 * More detailed script error reporting
 * Commands::sendCTCP, Commands::sendCTCPReply
 * Add DCC_CHAT_END hook for Scheme
+* Finish adding commands to Scheme for sending messages
+* Finish adding hooks/send hooks
 
 2.2:
 * Finish Texinfo manual
-* Finish adding commands to Scheme for sending messages
-  (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
 
 2.4: 
 * Use configuration database class
index d674325..d86aa0b 100644 (file)
@@ -980,12 +980,12 @@ before using these. If you have no idea what these do, read rfc 2812
 (IRC Client Protocol) and CTCP spec. These functions all return
 `*unspecified*' always, so don't use the return value for anything.
 
- -- Function: bot:send-ctcp to command message
+ -- Function: bot:ctcp to command message
      TO is the target of your CTCP message, COMMAND is the CTCP
      command, and MESSAGE is the message (or arguments) of the command.
      Make sure to `bot:ctcp-quote' the message!
 
- -- Function: bot:send-ctcp-reply to command message
+ -- Function: bot:ctcp-reply to command message
      TO is the target of your CTCP reply, COMMAND is the CTCP command,
      and MESSAGE is the message (or arguments) of the command. Make
      sure to `bot:ctcp-quote' the message!
@@ -1139,6 +1139,14 @@ thunk). When the bot exits your thunk will be called.
  -- Function: bot:unlock channel
      Makes the bot unlock topic on CHANNEL.
 
+ -- Function: bot:who target
+     Sends a WHO command to TARGET. TARGET may be either a channel or a
+     user.
+
+ -- Function: bot:whois nick
+     Sends a WHOIS command to NICK. NICK *must* be a nickname, you
+     cannot send a WHOIS to a channel.
+
  -- Function: bot:getnickname
      [ Gets the bot's nickname? ]
 
@@ -1220,7 +1228,7 @@ Function Index
 * Menu:
 
 * %bot:load-extensions:                  Misc Scripting Stuff.
-                                                              (line 206)
+                                                              (line 214)
 * bot:action:                            High Level Message Functions.
                                                               (line  13)
 * bot:addcommand:                        Adding New Commands. (line  11)
@@ -1230,29 +1238,33 @@ Function Index
 * bot:addshit:                           Misc Scripting Stuff.
                                                               (line  38)
 * bot:addtimer:                          Misc Scripting Stuff.
-                                                              (line 167)
+                                                              (line 175)
 * bot:adduser:                           Misc Scripting Stuff.
                                                               (line  22)
 * bot:ban:                               Misc Scripting Stuff.
                                                               (line  49)
 * bot:change-command-level:              Misc Scripting Stuff.
                                                               (line  54)
+* bot:ctcp:                              Low Level Message Functions.
+                                                              (line  13)
 * bot:ctcp-quote:                        Misc Scripting Stuff.
-                                                              (line 200)
+                                                              (line 208)
+* bot:ctcp-reply:                        Low Level Message Functions.
+                                                              (line  18)
 * bot:cycle:                             Misc Scripting Stuff.
                                                               (line  60)
 * bot:dcc-chat-send:                     Misc Scripting Stuff.
-                                                              (line 171)
+                                                              (line 179)
 * bot:deban:                             Misc Scripting Stuff.
                                                               (line  63)
 * bot:delcommand:                        Misc Scripting Stuff.
-                                                              (line 164)
+                                                              (line 172)
 * bot:delserver:                         Misc Scripting Stuff.
                                                               (line  67)
 * bot:delshit:                           Misc Scripting Stuff.
                                                               (line  74)
 * bot:deltimer:                          Misc Scripting Stuff.
-                                                              (line 169)
+                                                              (line 177)
 * bot:deluser:                           Misc Scripting Stuff.
                                                               (line  71)
 * bot:deop:                              Misc Scripting Stuff.
@@ -1262,15 +1274,15 @@ Function Index
 * bot:do:                                Misc Scripting Stuff.
                                                               (line  83)
 * bot:flush:                             Misc Scripting Stuff.
-                                                              (line 155)
+                                                              (line 163)
 * bot:flushport:                         Misc Scripting Stuff.
-                                                              (line 158)
+                                                              (line 166)
 * bot:getnickname:                       Misc Scripting Stuff.
-                                                              (line 148)
+                                                              (line 156)
 * bot:getserver:                         Misc Scripting Stuff.
-                                                              (line 151)
+                                                              (line 159)
 * bot:getserverlist:                     Misc Scripting Stuff.
-                                                              (line 153)
+                                                              (line 161)
 * bot:invite:                            Misc Scripting Stuff.
                                                               (line  85)
 * bot:join:                              Misc Scripting Stuff.
@@ -1282,19 +1294,19 @@ Function Index
 * bot:kickban:                           Misc Scripting Stuff.
                                                               (line  98)
 * bot:load:                              Misc Scripting Stuff.
-                                                              (line 184)
+                                                              (line 192)
 * bot:load-module:                       Misc Scripting Stuff.
-                                                              (line 186)
+                                                              (line 194)
 * bot:lock:                              Misc Scripting Stuff.
                                                               (line 102)
 * bot:log:                               Misc Scripting Stuff.
-                                                              (line 179)
+                                                              (line 187)
 * bot:logport:                           Misc Scripting Stuff.
                                                               (line 105)
 * bot:match-not-channel:                 Misc Scripting Stuff.
-                                                              (line 190)
+                                                              (line 198)
 * bot:match-to-me:                       Misc Scripting Stuff.
-                                                              (line 194)
+                                                              (line 202)
 * bot:mode:                              Misc Scripting Stuff.
                                                               (line 108)
 * bot:msg:                               High Level Message Functions.
@@ -1310,17 +1322,13 @@ Function Index
 * bot:part:                              Misc Scripting Stuff.
                                                               (line 120)
 * bot:random:                            Misc Scripting Stuff.
-                                                              (line 161)
+                                                              (line 169)
 * bot:reconnect:                         Misc Scripting Stuff.
                                                               (line 123)
 * bot:say:                               High Level Message Functions.
                                                               (line   7)
-* bot:send-ctcp:                         Low Level Message Functions.
-                                                              (line  13)
-* bot:send-ctcp-reply:                   Low Level Message Functions.
-                                                              (line  18)
 * bot:sent-to-me?:                       Misc Scripting Stuff.
-                                                              (line 198)
+                                                              (line 206)
 * bot:server:                            Misc Scripting Stuff.
                                                               (line 126)
 * bot:setfloodrate:                      Misc Scripting Stuff.
@@ -1336,7 +1344,11 @@ Function Index
 * bot:unlock:                            Misc Scripting Stuff.
                                                               (line 145)
 * bot:use-module:                        Misc Scripting Stuff.
-                                                              (line 188)
+                                                              (line 196)
+* bot:who:                               Misc Scripting Stuff.
+                                                              (line 148)
+* bot:whois:                             Misc Scripting Stuff.
+                                                              (line 152)
 * hooks/action:                          Received Message Hooks.
                                                               (line   9)
 * hooks/ctcp:                            Received Message Hooks.
@@ -1391,7 +1403,7 @@ Variable Index
 * Menu:
 
 * %bot:loadpath:                         Misc Scripting Stuff.
-                                                              (line 204)
+                                                              (line 212)
 * exit-hook:                             Misc Scripting Stuff.
                                                               (line   9)
 * user-friend:                           Scheme User Levels.  (line   6)
@@ -1431,9 +1443,9 @@ Node: Scheme User Levels\7f32009
 Node: Sending Messages\7f33143
 Node: High Level Message Functions\7f33759
 Node: Low Level Message Functions\7f34539
-Node: Misc Scripting Stuff\7f35602
-Node: Concept Index\7f42178
-Node: Function Index\7f42397
-Node: Variable Index\7f53633
+Node: Misc Scripting Stuff\7f35592
+Node: Concept Index\7f42417
+Node: Function Index\7f42636
+Node: Variable Index\7f54144
 \1f
 End Tag Table
index 0b46fe5..1455e81 100644 (file)
@@ -1269,6 +1269,16 @@ the bot will change @var{channel}'s topic to @var{topic}.
 Makes the bot unlock topic on @var{channel}.
 @end defun
 
+@defun bot:who target
+Sends a WHO command to @var{target}. @var{target} may be either a
+channel or a user.
+@end defun
+
+@defun bot:whois nick
+Sends a WHOIS command to @var{nick}. @var{nick} @strong{must} be a
+nickname, you cannot send a WHOIS to a channel.
+@end defun
+
 @c (0, 0, 0)
 @defun bot:getnickname
 [ Gets the bot's nickname? ]
index fb181e9..5d7e3be 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 "Macros.H"
 #include "Message.H"
@@ -875,3 +876,31 @@ Commands::Unlock(Bot *bot, String channel)
 
   return Ok;
 }
+
+Message
+Commands::Who (Bot *bot, String target)
+{
+  CHECK_CONNECTION;
+
+  QUEUE->sendWho (target);
+
+  return Ok;
+}
+
+Message
+Commands::Whois (Bot *bot, String nick)
+{
+  CHECK_CONNECTION;
+
+  if (!Utils::valid_nickname_p (bot, nick))
+    {
+      return InvalidNick (nick);
+    }
+  else
+    {
+      QUEUE->sendWhois (nick);
+      return Ok;
+    }
+}
+
+  
index 1939e6e..6e54fc6 100644 (file)
@@ -1,6 +1,6 @@
 // Commands.H  -*- C++ -*-
 // Copyright (c) 1997, 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
@@ -69,6 +69,8 @@ public:
   static Message TKBan(Bot *, String, String, int, String);
   static Message Topic(Bot *, String, String);
   static Message Unlock(Bot *, String);
+  static Message Who (Bot *, String);
+  static Message Whois (Bot *, String);
 };
 
 #endif
index f1487ae..331b9d7 100644 (file)
@@ -1,6 +1,6 @@
 // Interp.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
@@ -185,6 +185,10 @@ interp_init_helper (void* unused)
   bot_new_procedure ("bot:change-command-level", 
                     (SCMFunc)ScriptCommands::ChangeCommandLevel,
                     2, 0, 0);
+  scm_c_define_gsubr ("bot:ctcp", 3, 0, 0,
+                     (SCMFunc)ScriptCommands::CTCP);
+  scm_c_define_gsubr ("bot:ctcp-reply", 3, 0, 0,
+                     (SCMFunc)ScriptCommands::CTCPReply);
   bot_new_procedure ("bot:cycle", (SCMFunc)ScriptCommands::Action, 1, 0, 0);
   bot_new_procedure ("bot:deban", (SCMFunc)ScriptCommands::Deban, 2, 0, 0);
   bot_new_procedure ("bot:delserver", (SCMFunc)ScriptCommands::DelServer, 
@@ -224,6 +228,8 @@ interp_init_helper (void* unused)
   bot_new_procedure ("bot:tkban", (SCMFunc)ScriptCommands::TKBan, 3, 1, 0);
   bot_new_procedure ("bot:topic", (SCMFunc)ScriptCommands::Topic, 2, 0, 0);
   bot_new_procedure ("bot:unlock", (SCMFunc)ScriptCommands::Unlock, 1, 0, 0);
+  scm_c_define_gsubr ("bot:who", 1, 0, 0, (SCMFunc)ScriptCommands::Who);
+  scm_c_define_gsubr ("bot:whois", 1, 0, 0, (SCMFunc)ScriptCommands::Whois);
 
   bot_new_procedure ("bot:getnickname", (SCMFunc)ScriptCommands::getNickname, 
                     0, 0, 0);
@@ -250,12 +256,6 @@ interp_init_helper (void* unused)
 
   scm_c_define_gsubr ("bot:dcc-chat-send", 2, 0, 0,
                      (SCMFunc)ScriptCommands::sendDCCChatMessage);
-
-  // "Low Level" Message functuions
-  scm_c_define_gsubr ("bot:ctcp", 3, 0, 0,
-                     (SCMFunc)ScriptCommands::sendCTCP);
-  scm_c_define_gsubr ("bot:ctcp-reply", 3, 0, 0,
-                     (SCMFunc)ScriptCommands::sendCTCPReply);
 }
 
 #undef bot_new_procedure
index 752f1b1..20105f1 100644 (file)
@@ -1,6 +1,6 @@
 // Interp.H  -*- 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
index 239051a..bce1e18 100644 (file)
@@ -1,5 +1,6 @@
 // Message.H  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
+// Copyright (c) 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
@@ -13,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 MESSAGE_H
 #define MESSAGE_H
index 837e5b5..84049f5 100644 (file)
@@ -158,7 +158,8 @@ ScriptCommands::ChangeCommandLevel(SCM command, SCM level)
 
   SCM_STRING_COERCE_0TERMINATION_X (command);
   std::string ccommand = SCM_STRING_CHARS (command);
-  unsigned int llevel = scm_num2uint (level, 0, "ScriptCommands::ChangeCommandLevel");
+  unsigned int llevel = scm_num2uint 
+    (level, 0, "ScriptCommands::ChangeCommandLevel");
 
   if (llevel > 4)
     return SCM_BOOL_F;
@@ -177,6 +178,34 @@ ScriptCommands::ChangeCommandLevel(SCM command, SCM level)
   return SCM_BOOL_T;
 }
 
+SCM
+ScriptCommands::CTCP(SCM to, SCM command , SCM message)
+{
+  VERIFY_STRING(to);
+  VERIFY_STRING(command);
+  VERIFY_STRING(message);
+
+  Commands::CTCP (Interp::bot, Utils::scm2str (to), 
+                     Utils::scm2str (command),
+                     Utils::scm2str (message));
+
+  return SCM_UNSPECIFIED;
+}
+
+SCM
+ScriptCommands::CTCPReply (SCM to, SCM command , SCM message)
+{
+  VERIFY_STRING(to);
+  VERIFY_STRING(command);
+  VERIFY_STRING(message);
+
+  Commands::CTCPReply (Interp::bot, Utils::scm2str (to), 
+                      Utils::scm2str (command),
+                      Utils::scm2str (message));
+
+  return SCM_UNSPECIFIED;
+}
+
 SCM
 ScriptCommands::Cycle(SCM channel)
 {
@@ -479,6 +508,26 @@ ScriptCommands::Unlock(SCM channel)
   return scm_long2num(m.getCode());
 }
 
+SCM
+ScriptCommands::Who (SCM target)
+{
+  VERIFY_STRING (target);
+
+  Message m = Commands::Who (Interp::bot, Utils::scm2str (target));
+
+  return scm_long2num (m.getCode ());
+}
+
+SCM
+ScriptCommands::Whois (SCM nick)
+{
+  VERIFY_STRING (nick);
+
+  Message m = Commands::Whois (Interp::bot, Utils::scm2str (nick));
+
+  return scm_long2num (m.getCode ());
+}
+
 SCM
 ScriptCommands::getNickname(void)
 {
@@ -649,38 +698,9 @@ ScriptCommands::sendDCCChatMessage (SCM to, SCM message)
                    Utils::scm2str (message)));
 }
 
-// Message sending
-// FIXME: write these
-
-#define IQUEUE Interp::bot->serverConnection->queue
 
-SCM
-ScriptCommands::sendCTCP(SCM to, SCM command , SCM message)
-{
-  VERIFY_STRING(to);
-  VERIFY_STRING(command);
-  VERIFY_STRING(message);
 
-  Commands::CTCP (Interp::bot, Utils::scm2str (to), 
-                     Utils::scm2str (command),
-                     Utils::scm2str (message));
 
-  return SCM_UNSPECIFIED;
-}
-
-SCM
-ScriptCommands::sendCTCPReply (SCM to, SCM command , SCM message)
-{
-  VERIFY_STRING(to);
-  VERIFY_STRING(command);
-  VERIFY_STRING(message);
-
-  Commands::CTCPReply (Interp::bot, Utils::scm2str (to), 
-                      Utils::scm2str (command),
-                      Utils::scm2str (message));
-
-  return SCM_UNSPECIFIED;
-}
 
 
 #endif
index 53f5205..b2ecaec 100644 (file)
@@ -37,6 +37,8 @@ public:
   static SCM AddShit(SCM, SCM, SCM, SCM, SCM);
   static SCM Ban(SCM, SCM);
   static SCM ChangeCommandLevel(SCM, SCM);
+  static SCM CTCP(SCM, SCM, SCM);
+  static SCM CTCPReply(SCM, SCM, SCM);
   static SCM Cycle(SCM);
   static SCM Deban(SCM, SCM);
   static SCM DelServer(SCM);
@@ -68,6 +70,8 @@ public:
   static SCM TKBan(SCM, SCM, SCM, SCM);
   static SCM Topic(SCM, SCM);
   static SCM Unlock(SCM);
+  static SCM Who(SCM);
+  static SCM Whois(SCM);
 
   static SCM getNickname(void);
   static SCM getServer(void);
@@ -84,9 +88,6 @@ public:
   // DCC CHAT
   static SCM sendDCCChatMessage (SCM, SCM);
 
-  // Message sending
-  static SCM sendCTCP(SCM, SCM, SCM);
-  static SCM sendCTCPReply(SCM, SCM, SCM);
   /*
   SCM sendChannelMode(SCM);
   SCM sendChannelMode(SCM, SCM, SCM);
index 527f37e..d75a433 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"
@@ -1450,7 +1451,7 @@ UserCommands::UserList(ServerConnection *cnx, Person *from,
 
 void
 UserCommands::Who(ServerConnection *cnx, Person *from,
-                    String channel, String rest)
+                 String channel, String rest)
 {
   String nick = from->getNick();
   User * u = cnx->bot->channelList->getChannel(channel)->getUser(nick);
index f287f29..c1b4741 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 UTILS_H
 #define UTILS_H