? bot_messaged_0.patch ? bot_messaged_1.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 -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 12 Feb 2009 21:22:24 -0000 @@ -68,7 +68,7 @@ */ 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 @@ * 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_karma/bot_karma.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_karma/Attic/bot_karma.module,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 bot_karma.module --- bot_karma/bot_karma.module 6 Feb 2009 02:28:48 -0000 1.1.2.5 +++ bot_karma/bot_karma.module 12 Feb 2009 21:22:24 -0000 @@ -53,7 +53,7 @@ */ function bot_karma_irc_msg_channel($data, $from_query = FALSE) { $to = $from_query ? $data->nick : $data->channel; - $addressed = bot_name_regexp(); + $addressed = bot_name_regexp($from_query); // addressing is required. "bot_module: karma foo?". if (preg_match("/^${addressed}karma\s+(.*?)[!\?\.]*\s*$/i", $data->message, $matches)) { @@ -63,7 +63,7 @@ } // someone has affected the cosmos! modify the karma! - elseif (preg_match("/^($addressed)?(.*?)(\+\+|--)$/", $data->message, $matches)) { + elseif (preg_match("/^(${addressed})?(.*?)(\+\+|--)$/", $data->message, $matches)) { $term = trim(drupal_strtolower($matches[3])); // always store it lowercase. if (strlen($term) < 3 || strlen($term) > 15) { return; } // skip odd sizes. Index: bot_seen/bot_seen.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_seen/Attic/bot_seen.module,v retrieving revision 1.1.2.12.2.7 diff -u -r1.1.2.12.2.7 bot_seen.module --- bot_seen/bot_seen.module 6 Feb 2009 17:44:31 -0000 1.1.2.12.2.7 +++ bot_seen/bot_seen.module 12 Feb 2009 21:22:25 -0000 @@ -29,7 +29,7 @@ function bot_seen_irc_msg_channel($data, $from_query = FALSE) { $to = $from_query ? $data->nick : $data->channel; $nicks = array(); // list of nicks to search for. - $addressed = bot_name_regexp(); + $addressed = bot_name_regexp($from_query); // log the message, whatever it is. no UPDATEs; just start anew, eh? if (!$from_query) { // we only want to record public activity, not private messages. @@ -49,7 +49,7 @@ // Our more complicated regexp allows multiple types of syntax and // more than one lookup per query, but require direct addressing. - if (preg_match("/^$addressed/i", $data->message) || $from_query) { + if (preg_match("/^${addressed}/i", $data->message) || $from_query) { if (preg_match_all('!.*?seen ([a-zA-Z0-9\[\]\{\}\\\|\^\`\-\_\*]*)( ?\?|$| ?\,)!i', trim($data->message), $matches)) { foreach ($matches[1] as $match) { // for every construct we've found in our message, find the user. $nicks[] = $match; // the bot will respond addressed to multiple requests and styles in one query. 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 -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 12 Feb 2009 21:22:25 -0000 @@ -28,7 +28,7 @@ */ 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 @@ } // 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.