? bot_addressed.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 11:00:50 -0000 @@ -68,17 +68,18 @@ 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 = $from_query ? '' : bot_name_regexp(); // our IRC help interface which piggybacks off of Drupal's hook_help(). if (preg_match("/^${addressed}help\s*([^\?]*)\s*\??/i", $data->message, $help_matches)) { - if (!$help_matches[2]) { // no specific help was asked for so give 'em a list. + $matches = $addressed ? $help_matches[2] : $help_matches[1]; + if (!$matches) { // no specific help was asked for so give 'em a list. $irc_features = array_filter(module_invoke_all('help', 'irc:features', NULL)); asort($irc_features); // alphabetical listing of features. the chainsaw is family. bot_message($to, t('Detailed information is available by asking for "help " where is one of: !features.', array('!features' => implode(', ', $irc_features)))); } else { // a specific type of help was required, so load up just that bit of text. - $feature_name = 'irc:features#'. preg_replace('/[^\w\d]/', '_', drupal_strtolower(trim($help_matches[2]))); + $feature_name = 'irc:features#'. preg_replace('/[^\w\d]/', '_', drupal_strtolower(trim($matches))); $feature_help = array_filter(module_invoke_all('help', $feature_name, NULL)); bot_message($to, array_shift($feature_help)); } 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 11:00:50 -0000 @@ -75,7 +75,7 @@ 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 = $from_query ? '' : bot_name_regexp(); // look for factoids to answer wherever we can. if (preg_match("/^($addressed)?(.*)[!\?]+$/i", $data->message, $matches)) { @@ -87,8 +87,9 @@ function bot_factoid_irc_msg_channel($da // allow "tell about " private messaging. 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. + $match_factoid = $addressed ? $matches[5] : $matches[4]; + $factoid = bot_factoid_load($match_factoid); + $to = $addressed ? $matches[3] : $matches[2]; // specified user. } // a known factoid was requested... 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 11:00:50 -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 = $from_query ? '' : bot_name_regexp(); // check for existing messages. $messages = bot_tell_load($data->nick); @@ -47,18 +47,28 @@ 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 ($addressed) { + $match_about = substr($matches[3], 0, 5); + $match_factoid = substr($matches[3], 6); + $match_recipient = $matches[2]; + } + else { + $match_about = substr($matches[2], 0, 5); + $match_factoid = substr($matches[2], 6); + $match_recipient = $matches[1]; + } // 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. // @todo ideally, this would be smoother with http://drupal.org/node/218595. - if (module_exists('bot_factoid') && substr($matches[4], 0, 5) == 'about' && $factoid = bot_factoid_load(substr($matches[4], 6))) { + if (module_exists('bot_factoid') && $match_about == 'about' && $factoid = bot_factoid_load($match_factoid)) { return; // we're just not gonna do anything with this, cos bot_factoid will gladly take over. } // queued message accepted, keptin. - bot_tell_save($data->nick, $matches[3], preg_replace("/^($addressed)\s*/", '', $data->message)); // see that? it's saved! in one line! - bot_message($to, t("!nick: I'll pass that on when !recipient is around.", array('!nick' => $data->nick, '!recipient' => $matches[3]))); + bot_tell_save($data->nick, $match_recipient, preg_replace("/^($addressed)\s*/", '', $data->message)); // see that? it's saved! in one line! + bot_message($to, t("!nick: I'll pass that on when !recipient is around.", array('!nick' => $data->nick, '!recipient' => $match_recipient))); } }