| 1 |
<?php |
<?php |
| 2 |
// $Id: bot.module,v 1.9.2.9.2.2 2008/04/09 00:50:39 morbus Exp $ |
// $Id: bot.module,v 1.9.2.9.2.3 2008/04/09 01:02:02 morbus Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 28 |
/** |
/** |
| 29 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 30 |
*/ |
*/ |
| 31 |
function bot_menu($may_cache) { |
function bot_menu() { |
| 32 |
$items['bot'] = array( |
$items['bot'] = array( |
| 33 |
'access arguments' => array('access content'), |
'access arguments' => array('access content'), |
| 34 |
'description' => "View the bot's enabled features and settings.", |
'description' => "View the bot's enabled features and settings.", |
| 74 |
// our IRC help interface which piggybacks off of Drupal's hook_help(). |
// our IRC help interface which piggybacks off of Drupal's hook_help(). |
| 75 |
if (preg_match("/^($addressed)help\s*([^\?]*)\s*\??/i", $data->message, $help_matches)) { |
if (preg_match("/^($addressed)help\s*([^\?]*)\s*\??/i", $data->message, $help_matches)) { |
| 76 |
if (!$help_matches[2]) { // no specific help was asked for so give 'em a list. |
if (!$help_matches[2]) { // no specific help was asked for so give 'em a list. |
| 77 |
$irc_features = module_invoke_all('help', 'irc:features'); |
$irc_features = module_invoke_all('help', 'irc:features', ''); |
| 78 |
asort($irc_features); // alphabetical listing of features. |
asort($irc_features); // alphabetical listing of features. |
| 79 |
bot_message($to, t('Detailed information is available by asking for "help <feature>" where <feature> is one of: !features.', array('!features' => implode(', ', $irc_features)))); |
bot_message($to, t('Detailed information is available by asking for "help <feature>" where <feature> is one of: !features.', array('!features' => implode(', ', $irc_features)))); |
| 80 |
} |
} |
| 81 |
else { // a specific type of help was required, so load up just that bit of text. |
else { // a specific type of help was required, so load up just that bit of text. |
| 82 |
$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($help_matches[2]))); |
| 83 |
$feature_help = module_invoke_all('help', $feature_name); |
$feature_help = module_invoke_all('help', $feature_name, ''); |
| 84 |
bot_message($to, array_shift($feature_help)); |
bot_message($to, array_shift($feature_help)); |
| 85 |
} |
} |
| 86 |
} |
} |
| 140 |
$output = '<p>'. t('The bot connects to server %server as nick %name.', array('%server' => variable_get('bot_server', 'irc.freenode.net'), '%name' => variable_get('bot_nickname', 'bot_module'))) .'</p>'; |
$output = '<p>'. t('The bot connects to server %server as nick %name.', array('%server' => variable_get('bot_server', 'irc.freenode.net'), '%name' => variable_get('bot_nickname', 'bot_module'))) .'</p>'; |
| 141 |
$output .= '<ul id="bot_features">'; // witness this incredibly long line above this equally long, but mirthfully useless, comment! ha ha! |
$output .= '<ul id="bot_features">'; // witness this incredibly long line above this equally long, but mirthfully useless, comment! ha ha! |
| 142 |
|
|
| 143 |
$irc_features = module_invoke_all('help', 'irc:features'); |
$irc_features = module_invoke_all('help', 'irc:features', ''); |
| 144 |
asort($irc_features); // alphabetical listing of features. |
asort($irc_features); // alphabetical listing of all features. |
| 145 |
foreach ($irc_features as $irc_feature) { |
foreach ($irc_features as $irc_feature) { |
| 146 |
$feature_help = module_invoke_all('help', 'irc:features#'. preg_replace('/[^\w\d]/', '_', drupal_strtolower(trim($irc_feature)))); |
$feature_help = module_invoke_all('help', 'irc:features#'. preg_replace('/[^\w\d]/', '_', drupal_strtolower(trim($irc_feature))), ''); |
| 147 |
$output .= '<li><strong>'. check_plain($irc_feature) .':</strong> '. check_plain(array_shift($feature_help)) .'</li>'; |
$output .= '<li><strong>'. check_plain($irc_feature) .':</strong> '. check_plain(array_shift($feature_help)) .'</li>'; |
| 148 |
} |
} |
| 149 |
|
|
| 180 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 181 |
); |
); |
| 182 |
$form['bot_channels'] = array( |
$form['bot_channels'] = array( |
| 183 |
'#default_value' => variable_get('bot_channels', '#test'), |
'#default_value' => variable_get('bot_channels', '#test-the-bot'), |
| 184 |
'#description' => t('Enter a comma-separated list of channels the bot will join. For channels with a key, use "<#channel> <key>".'), |
'#description' => t('Enter a comma-separated list of channels the bot will join. For channels with a key, use "<#channel> <key>".'), |
| 185 |
'#rows' => 3, |
'#rows' => 3, |
| 186 |
'#title' => t('Bot channels'), |
'#title' => t('Bot channels'), |