[project @ 2005-06-23 18:49:38 by unknown_lamer]
authorunknown_lamer <unknown>
Thu, 23 Jun 2005 18:49:39 +0000 (18:49 +0000)
committerunknown_lamer <unknown>
Thu, 23 Jun 2005 18:49:39 +0000 (18:49 +0000)
bot:notice has been implemented. Commands::Notice will now send a
notice to a channel. bot:notice was documented. Message macros were
moved around.

ChangeLog
NEWS
bobot++.info
bobot++.texinfo
source/Commands.C
source/Interp.C
source/Message.H
source/ScriptCommands.C
source/ScriptCommands.H

index a5c71c4..e8179ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2005-06-23  Clinton Ebadi  <clinton@unknownlamer.org>
 
+       * source/Commands.C (Notice): Commented out check/abort if target
+       is a channel (there doesn't seem to be a reason for this to not work)
+
+       * source/Interp.C (interp_init_helper): Register bot:notice with scheme
+
+       * bobot++.texinfo (High Level Message Functions): Document bot:notice
+
+       * source/Message.H: Added operator== to Message (tests for error
+       code equality)
+
+       * source/Commands.C: Removed message type macros
+
+       * source/Message.H: Moved message type macros to Message.H
+
+       * source/ScriptCommands.C (sendNotice): Implemented sendNotice
+
+       * source/ScriptCommands.H: Uncomment sendNotice
+
        * source/Bot.C (waitForInput): Use %02d when formatting
        Hooks::TIMER argument instead of %2d, and switch to snprintf to
        enforce max length
diff --git a/NEWS b/NEWS
index a91ed96..9fa7ab9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,8 +11,18 @@ IMPORTANT NOTES:
 =====================================================================
 
 Version 2.1.8: 
-- Added bot:protection/[none|ban|kick|deop] and bot:aop/[yes|no]
-  constants to the Scheme scripting interface
+- Scripting
+  + Hooks
+    * Added bot:protection/[none|ban|kick|deop] and bot:aop/[yes|no]
+      constants to the Scheme scripting interface
+    * hooks/timer argument is now zero padded instead of space padded
+      (e.g. "11:01" instead of "11: 1")
+    * hooks/disconnect is now called when the bot is disconnected from the
+      server unintentionally (network connection timeout, server died,
+      etc.)
+  + Message Sending
+    * Implemented bot:notice
+
 
 Version 2.1.7:
 - Fixed a number of small bugs and corner cases
index 35fbc67..772f7f4 100644 (file)
@@ -749,6 +749,11 @@ File: bobot++.info,  Node: High Level Message Functions,  Next: Low Level Messag
      The same as if a user typed `/msg nick message' to their IRC
      client.
 
+ -- Function: bot:notice target message
+     Sends MESSAGE as a NOTICE to TARGET. TARGET may be a user (nick)
+     or a channel. This returns `#t' if the message was sent
+     successfull, `#f' otherwise.
+
 \1f
 File: bobot++.info,  Node: Low Level Message Functions,  Prev: High Level Message Functions,  Up: Sending Messages
 
@@ -1077,6 +1082,8 @@ Function Index
                                                               (line 111)
 * bot:nick:                              Misc Scripting Stuff.
                                                               (line 114)
+* bot:notice:                            High Level Message Functions.
+                                                              (line  20)
 * bot:op:                                Misc Scripting Stuff.
                                                               (line 117)
 * bot:part:                              Misc Scripting Stuff.
@@ -1179,10 +1186,10 @@ Node: Hook Types\7f22496
 Node: Scheme User Levels\7f25525
 Node: Sending Messages\7f26659
 Node: High Level Message Functions\7f27275
-Node: Low Level Message Functions\7f27898
-Node: Misc Scripting Stuff\7f28666
-Node: Concept Index\7f35242
-Node: Function Index\7f35461
-Node: Variable Index\7f45305
+Node: Low Level Message Functions\7f28104
+Node: Misc Scripting Stuff\7f28872
+Node: Concept Index\7f35448
+Node: Function Index\7f35667
+Node: Variable Index\7f45655
 \1f
 End Tag Table
index 9e573a5..2db1f7a 100644 (file)
@@ -818,6 +818,12 @@ Send an ``action'' type  @var{message} to @var{channel}
 The same as if a user typed @code{/msg nick message} to their IRC client.
 @end defun
 
+@defun bot:notice target message
+Sends @var{message} as a NOTICE to @var{target}. @var{target} may be a
+user (nick) or a channel. This returns @code{#t} if the message was
+sent successfull, @code{#f} otherwise.
+@end defun
+
 @node Low Level Message Functions,  , High Level Message Functions, Sending Messages
 @subsection ``Low Level'' Message Functions
 
index df5711e..7fb0bbc 100644 (file)
 #include "Commands.H"
 #include "Utils.H"
 
-#define Ok (Message(0, ""))
-#define NotOnChannel(c) (Message(-1, String("I am not on channel ") + (c)))
-#define NotChannelOp(c) (Message(-2, String("I am not channel op on ") + (c)))
-#define UserNotFound(w, c) (Message(-3, (w) + " is not on channel " + (c)))
-#define UserNotOp(w, c) (Message(-4, (w) + " is not channel op on " + (c)))
-#define UserProtected(w, c) (Message(-5, (w) + " is protected on " + (c)))
-#define InvalidNick(n) (Message(-6, (n) + " is not a valid nickname"))
-#define InvalidChannel(c) (Message(-7, (c) + " is not a valid channel name"))
-#define MassOpNotAllowed (Message(-8, "Mass op is not allowed."))
-#define UserOnShitList(w) (Message(-9, String("User ") + w + " is on my shitlist"))
-#define CanNotChangeTopic(c) (Message(-10, String("I can not change topic on ") + (c)))
-#define TopicLocked(c) (Message(-11, String("Topic is locked on ") + (c)))
-#define InvalidPort(p) (Message(-12, String((long)(p)) + " is an invalid port number"))
-#define InvalidTime(t) (Message(-13, String((long)(t)) + " is an invalid time"))
-#define CanNotChangeServer (Message(-14, "I cannot change server without loosing op on one of my channels"))
-#define EmptyServerList (Message(-15, "Server list is empty"))
-#define InvalidServerNumber(n) (Message(-16, String((long)(n)) + " is an invalid server number"))
-#define InvalidParameters (Message(-17, "Invalid parameters"))
-#define NotFound(w) (Message(-18, String("I can not find ") + (w)));
-#define NotInUserlist(w) (Message(-19, (w) + " is not in my userlist"))
-#define NotInShitlist(w) (Message(-20, (w) + " is not in my shitlist"))
-#define AlreadyInUserlist(m, mc) (Message(-21, (m) + " is already in userlist on channel(s) " + (mc)))
-#define AlreadyInShitlist(m, mc) (Message(-22, (m) + " is already in shitlist on channel(s) " + (mc)))
-#define EmptyMessage (Message(-23, "Can not send an empty message"))
-#define EmptyAddressee (Message(-24, "Can not send to nobody"))
-#define NotToChannel (Message(-25, "Can not send to a channel. Use \"say\" instead."))
-#define NotConnected (Message(-26, "Not connected."))
 
 #define CHECK_CONNECTION if (!bot->serverConnection) return NotConnected
 
@@ -550,8 +523,8 @@ Commands::Notice(Bot *bot, String who, String message)
   if (who == "")
     return EmptyAddressee;
 
-  if (Utils::channel_p(who))
-    return NotToChannel;
+  //  if (Utils::channel_p(who))
+  //    return NotToChannel;
 
   if (message == "")
     return EmptyMessage;
index c6340b0..5980d9a 100644 (file)
@@ -154,6 +154,10 @@ interp_init_helper (void* unused)
   bot_new_procedure ("bot:nextserver", (SCMFunc)ScriptCommands::NextServer, 
                     0, 0, 0);
   bot_new_procedure ("bot:nick", (SCMFunc)ScriptCommands::Nick, 1, 0, 0);
+
+  scm_c_define_gsubr ("bot:notice", 2, 0, 0, 
+                     (SCMFunc)ScriptCommands::sendNotice);
+
   bot_new_procedure ("bot:op", (SCMFunc)ScriptCommands::Op, 2, 0, 0);
   bot_new_procedure ("bot:part", (SCMFunc)ScriptCommands::Part, 1, 0, 0);
   bot_new_procedure ("bot:reconnect", (SCMFunc)ScriptCommands::Reconnect, 
index 68f939c..97650ec 100644 (file)
@@ -27,6 +27,36 @@ struct Message {
   Message(int c, String d) : code(c), description(d) { }
   int getCode() const { return code; }
   String getMessage() const { return description; }
+
+  bool operator== (Message m) { return getCode () == m.getCode (); }
 };
 
+#define Ok (Message(0, ""))
+#define NotOnChannel(c) (Message(-1, String("I am not on channel ") + (c)))
+#define NotChannelOp(c) (Message(-2, String("I am not channel op on ") + (c)))
+#define UserNotFound(w, c) (Message(-3, (w) + " is not on channel " + (c)))
+#define UserNotOp(w, c) (Message(-4, (w) + " is not channel op on " + (c)))
+#define UserProtected(w, c) (Message(-5, (w) + " is protected on " + (c)))
+#define InvalidNick(n) (Message(-6, (n) + " is not a valid nickname"))
+#define InvalidChannel(c) (Message(-7, (c) + " is not a valid channel name"))
+#define MassOpNotAllowed (Message(-8, "Mass op is not allowed."))
+#define UserOnShitList(w) (Message(-9, String("User ") + w + " is on my shitlist"))
+#define CanNotChangeTopic(c) (Message(-10, String("I can not change topic on ") + (c)))
+#define TopicLocked(c) (Message(-11, String("Topic is locked on ") + (c)))
+#define InvalidPort(p) (Message(-12, String((long)(p)) + " is an invalid port number"))
+#define InvalidTime(t) (Message(-13, String((long)(t)) + " is an invalid time"))
+#define CanNotChangeServer (Message(-14, "I cannot change server without loosing op on one of my channels"))
+#define EmptyServerList (Message(-15, "Server list is empty"))
+#define InvalidServerNumber(n) (Message(-16, String((long)(n)) + " is an invalid server number"))
+#define InvalidParameters (Message(-17, "Invalid parameters"))
+#define NotFound(w) (Message(-18, String("I can not find ") + (w)));
+#define NotInUserlist(w) (Message(-19, (w) + " is not in my userlist"))
+#define NotInShitlist(w) (Message(-20, (w) + " is not in my shitlist"))
+#define AlreadyInUserlist(m, mc) (Message(-21, (m) + " is already in userlist on channel(s) " + (mc)))
+#define AlreadyInShitlist(m, mc) (Message(-22, (m) + " is already in shitlist on channel(s) " + (mc)))
+#define EmptyMessage (Message(-23, "Can not send an empty message"))
+#define EmptyAddressee (Message(-24, "Can not send to nobody"))
+#define NotToChannel (Message(-25, "Can not send to a channel. Use \"say\" instead."))
+#define NotConnected (Message(-26, "Not connected."))
+
 #endif
index 310fd4b..b2bdeaf 100644 (file)
@@ -31,6 +31,8 @@
 #include "DCCPerson.H"
 #include "DCCManager.H"
 #include "Parser.H"
+#include "Commands.H"
+#include "Message.H"
 #include <libguile.h>
 
 #define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \
@@ -649,4 +651,23 @@ ScriptCommands::sendCTCP(SCM to, SCM command , SCM message)
                   Utils::scm2str (message));
   return SCM_UNSPECIFIED;
 }
+
+SCM
+ScriptCommands::sendNotice (SCM to, SCM message)
+{
+  VERIFY_STRING (to);
+  VERIFY_STRING (message);
+
+  if (Commands::Notice (Interp::bot, 
+                       Utils::scm2str (to),
+                       Utils::scm2str (message))
+      == Ok)
+    {
+      return SCM_BOOL_T;
+    }
+  else
+    {
+      return SCM_BOOL_F;
+    }
+}
 #endif
index c3df33d..819fb95 100644 (file)
@@ -92,7 +92,9 @@ public:
   SCM sendJoin(SCM, SCM);
   SCM sendKick(SCM, SCM, SCM);
   SCM sendNick(SCM);
-  SCM sendNotice(SCM, SCM);
+  */
+  static SCM sendNotice(SCM, SCM);
+  /*
   SCM sendPart(SCM);
   SCM sendPass(SCM);
   SCM sendPing(SCM);