Index: bot_log/bot_log.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_log/Attic/bot_log.module,v retrieving revision 1.1.2.7.2.7 diff -u -p -r1.1.2.7.2.7 bot_log.module --- bot_log/bot_log.module 18 Mar 2009 16:47:30 -0000 1.1.2.7.2.7 +++ bot_log/bot_log.module 21 Dec 2009 11:53:49 -0000 @@ -421,3 +421,50 @@ function bot_log_settings(){ return system_settings_form($form); } +/** + * Implementation of hook_bot_commands(). + */ +function bot_log_bot_commands() { + return array( + 'log start' => array( + 'description' => t('Starts logging messages in the current channel.'), + 'callback' => 'bot_log_add_channel', + ), + 'log stop' => array( + 'description' => t('Stops logging messages in the current channel.'), + 'callback' => 'bot_log_remove_channel', + ), + ); +} + +/** + * Helper function to enable logging of a specific channel. + * @param $channel + * Name of channel where logging should be enabled. + */ +function bot_log_add_channel($data, $from_query = FALSE) { + $to = $from_query ? $data->nick : $data->channel; + $channels = variable_get('bot_log_channels', array()); + if (!in_array($data->channel, $channels)) { + $channels[] = $data->channel; + } + variable_set('bot_log_channels', $channels); + bot_message($to, t('Enabled logging for !channel.', array('!channel' => $data->channel))); +} + +/** + * Helper function to disable logging of a specific channel. + * @param $channel + * Name of channel where logging should be disabled. + */ +function bot_log_remove_channel($data, $from_query = FALSE) { + $to = $from_query ? $data->nick : $data->channel; + $channels = variable_get('bot_log_channels', array()); + $key = array_search($data->channel, $channels); + if ($key !== FALSE) { + unset($channels[$key]); + variable_set('bot_log_channels', $channels); + bot_message($to, t('Disabled logging for !channel.', array('!channel' => $data->channel))); + } +} +