? bot_messaged.patch
Index: bot.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot.module,v
retrieving revision 1.9.2.9.2.13
diff -u -p -r1.9.2.9.2.13 bot.module
--- bot.module	6 Feb 2009 17:44:31 -0000	1.9.2.9.2.13
+++ bot.module	10 Feb 2009 16:08:32 -0000
@@ -68,7 +68,7 @@ function bot_irc_bot_cron() {
  */
 function bot_irc_msg_channel($data, $from_query = FALSE) {
   $to = $from_query ? $data->nick : $data->channel;
-  $addressed = bot_name_regexp();
+  $addressed = bot_name_regexp($from_query);
 
   // our IRC help interface which piggybacks off of Drupal's hook_help().
   if (preg_match("/^${addressed}help\s*([^\?]*)\s*\??/i", $data->message, $help_matches)) {
@@ -161,8 +161,14 @@ function bot_overview() {
  * boundaries, use ^ and $ yourself). Since, however, it does match against
  * potentially MORE THAN ONE BOT NAME, it DOES capture the name, so you
  * will have to worry about that in preg_match $matches results.
+ * @param $from_query
+ *   Optional, indicating if the original message came from query. Default: FALSE.
  */
-function bot_name_regexp() {
+function bot_name_regexp($from_query = FALSE) {
+  if ($from_query) { // If request is coming from private query, no need to name the bot
+    return '()';
+  }
+
   global $irc; // to get the connected name.
   $names[] = $irc->_nick; // said connected name.
   $names[] = variable_get('bot_nickname', 'bot_module');
Index: bot_factoid/bot_factoid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_factoid/Attic/bot_factoid.module,v
retrieving revision 1.1.2.6.2.15
diff -u -p -r1.1.2.6.2.15 bot_factoid.module
--- bot_factoid/bot_factoid.module	6 Feb 2009 01:07:31 -0000	1.1.2.6.2.15
+++ bot_factoid/bot_factoid.module	10 Feb 2009 16:08:33 -0000
@@ -75,10 +75,10 @@ function bot_factoid_overview() {
  */
 function bot_factoid_irc_msg_channel($data, $from_query = FALSE) {
   $to = $from_query ? $data->nick : $data->channel;
-  $addressed = bot_name_regexp();
+  $addressed = bot_name_regexp($from_query);
 
   // look for factoids to answer wherever we can.
-  if (preg_match("/^($addressed)?(.*)[!\?]+$/i", $data->message, $matches)) {
+  if (preg_match("/^{$addressed}?(.*)[!\?]+$/i", $data->message, $matches)) {
 
     // "BOTNAME?" fails as a factoid. this fixes it.
     $subject = $matches[3] ? $matches[3] : $matches[2];
@@ -86,7 +86,7 @@ function bot_factoid_irc_msg_channel($da
   }
 
   // allow "tell <nick> about <subject>" private messaging.
-  if (preg_match("/^($addressed)tell ([a-zA-Z0-9\[\]\{\}\\\|\^\`\-\_\*]*)( about)? (.*)$/i", $data->message, $matches)) {
+  if (preg_match("/^${addressed}tell ([a-zA-Z0-9\[\]\{\}\\\|\^\`\-\_\*]*)( about)? (.*)$/i", $data->message, $matches)) {
     $factoid = bot_factoid_load($matches[5]);
     $to = $matches[3]; // specified user.
   }
@@ -106,7 +106,7 @@ function bot_factoid_irc_msg_channel($da
   // @todo allow subject searching and return list of subjects that match?
 
   // look for factoids to delete.
-  if (preg_match("/^($addressed)forget( about)? (.*)$/i", $data->message, $matches)) {
+  if (preg_match("/^{$addressed}forget( about)? (.*)$/i", $data->message, $matches)) {
     bot_factoid_delete($matches[4]); // good night, sweetheart. baaah dum dum dum. it's time to GoOoOooOOoo.
     bot_message($to, t("!nick: I've forgotten about !subject.", array('!nick' => $data->nick, '!subject' => $matches[4])));
   } // @todo delete message should be customizable. this one sucks.
Index: bot_tell/bot_tell.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_tell/Attic/bot_tell.module,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 bot_tell.module
--- bot_tell/bot_tell.module	6 Feb 2009 17:04:09 -0000	1.1.2.6
+++ bot_tell/bot_tell.module	10 Feb 2009 16:08:33 -0000
@@ -28,7 +28,7 @@ function bot_tell_help($path, $arg) {
  */
 function bot_tell_irc_msg_channel($data, $from_query = FALSE) {
   $to = $from_query ? $data->nick : $data->channel;
-  $addressed = bot_name_regexp();
+  $addressed = bot_name_regexp($from_query);
 
   // check for existing messages.
   $messages = bot_tell_load($data->nick);
@@ -47,7 +47,7 @@ function bot_tell_irc_msg_channel($data,
   }
 
   // check for tells to queue up.
-  if (preg_match("/^($addressed)tell\s+([a-zA-Z0-9\[\]\{\}\\\|\^\`\-\_\*]*)\s+(.*)$/i", $data->message, $matches)) {
+  if (preg_match("/^{$addressed}tell\s+([a-zA-Z0-9\[\]\{\}\\\|\^\`\-\_\*]*)\s+(.*)$/i", $data->message, $matches)) {
 
     // if bot_factoid.module is enabled, we'll check to see if this could be about a factoid.
     // if it is, we'll let bot_factoid handle it and skip over this message's processing here.
