bot_irc_msg_channel

Versions
6
bot_irc_msg_channel($data, $from_query = FALSE)

Framework related messages and features.

Parameters

$data The regular $data object prepared by the IRC library.

$from_query Boolean; whether this was a queried request.

Code

contributions/bot/bot.module, line 68

<?php
function bot_irc_msg_channel($data, $from_query = FALSE) {
  $to = $from_query ? $data->nick : $data->channel;
  $addressed = 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.
      $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 <feature>" where <feature> 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_help = array_filter(module_invoke_all('help', $feature_name, NULL));
      bot_message($to, array_shift($feature_help));
    }
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.