? bot-queue.patch ? queue_4.patch Index: bot.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/Attic/bot.install,v retrieving revision 1.1.2.1.2.1 diff -u -p -r1.1.2.1.2.1 bot.install --- bot.install 23 Jun 2008 00:52:19 -0000 1.1.2.1.2.1 +++ bot.install 12 May 2010 16:50:07 -0000 @@ -2,9 +2,82 @@ // $Id: bot.install,v 1.1.2.1.2.1 2008/06/23 00:52:19 morbus Exp $ /** + * Implementation of hook_schema(). + */ +function bot_schema() { + $schema = array(); + + $schema['bot_queue'] = array( + 'description' => 'Store queued items for the bot to process.', + 'fields' => array( + 'qid' => array( + 'description' => "Unique queue ID.", + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'author' => array( + 'description' => 'A string identifying the source of this entry.', + 'type' => 'varchar', + 'length' => 60, + 'not null' => TRUE, + 'default' => '', + ), + 'recipient' => array( + 'description' => 'The IRC nick or channel this entry is addressed to.', + 'type' => 'varchar', + 'length' => 60, + 'not null' => TRUE, + 'default' => '', + ), + 'module' => array( + 'description' => 'The name of an installed bot module that will handle this entry. By default its handled by bot module.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'data' => array( + 'description' => 'The content of the queue entry.', + 'type' => 'text', + 'not null' => TRUE, + 'default' => '', + ), + 'timestamp' => array( + 'description' => 'At what time this message was created.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'type' => array( + 'description' => 'Determine the type of the queue entry so modules can decide how to proces it.', + 'type' => 'int', + 'size' => 'small', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('qid'), + ); + + return $schema; +} + +/** + * Implementation of hook_install(). + */ +function bot_install() { + drupal_install_schema('bot'); +} + +/** * Implementation of hook_uninstall(). */ function bot_uninstall() { + drupal_uninstall_schema('bot'); + variable_del('bot_auto_retry'); variable_del('bot_auto_reconnect'); variable_del('bot_cache_cleared'); @@ -15,3 +88,4 @@ function bot_uninstall() { variable_del('bot_server'); variable_del('bot_server_port'); } + Index: bot.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot.module,v retrieving revision 1.9.2.9.2.18 diff -u -p -r1.9.2.9.2.18 bot.module --- bot.module 10 May 2010 15:44:13 -0000 1.9.2.9.2.18 +++ bot.module 12 May 2010 16:50:07 -0000 @@ -105,6 +105,25 @@ function bot_irc_bot_cron_fastest() { } /** + * Implementation of hook_irc_bot_queue(). + */ +function bot_irc_bot_queue() { + // Pull the queue entries that were meant for core processing. + $result = db_query('SELECT qid, author, recipient, data, timestamp, type FROM {bot_queue} WHERE module = "" OR module = "bot" ORDER BY timestamp DESC'); + + // The default behaviour is to send the messages onto IRC. + while ($row = db_fetch_object($result)) { + if ($row->type) { + bot_action($row->recipient, $row->data); + } + else { + bot_message($row->recipient, $row->data); + } + db_query('DELETE FROM {bot_queue} WHERE qid = %d', $row->qid); + } +} + +/** * Framework related messages and features. * * @param $data Index: bot_start.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_start.php,v retrieving revision 1.2.2.4.2.6 diff -u -p -r1.2.2.4.2.6 bot_start.php --- bot_start.php 10 May 2010 12:41:24 -0000 1.2.2.4.2.6 +++ bot_start.php 12 May 2010 16:50:08 -0000 @@ -75,6 +75,9 @@ $irc->registerTimehandler(300000, $bot, $irc->registerTimehandler(60000, $bot, 'invoke_irc_bot_cron_faster'); // 1 minute. $irc->registerTimehandler(15000, $bot, 'invoke_irc_bot_cron_fastest'); // 15 seconds. +// Add a ten-second timer for the web message queue. +$irc->registerTimehandler(10000, $bot, 'invoke_irc_bot_queue'); + // connect and begin listening. $irc->connect(variable_get('bot_server', 'irc.freenode.net'), variable_get('bot_server_port', 6667)); $irc->login(variable_get('bot_nickname', 'bot_module'), variable_get('bot_nickname', 'bot_module') . ' :http://drupal.org/project/bot', 8, variable_get('bot_nickname', 'bot_module'), (variable_get('bot_password', '') != '') ? variable_get('bot_password', '') : NULL); @@ -90,6 +93,7 @@ class drupal_wrapper { function invoke_irc_bot_cron(&$irc) { module_invoke_all('irc_bot_cron'); } function invoke_irc_bot_cron_faster(&$irc) { module_invoke_all('irc_bot_cron_faster'); } function invoke_irc_bot_cron_fastest(&$irc) { module_invoke_all('irc_bot_cron_fastest'); } + function invoke_irc_bot_queue(&$irc) { module_invoke_all('irc_bot_queue'); } function invoke_irc_msg_unknown(&$irc, &$data) { module_invoke_all('irc_msg_unknown', $data); } function invoke_irc_msg_channel(&$irc, &$data) { module_invoke_all('irc_msg_channel', $data); } function invoke_irc_msg_query(&$irc, &$data) { module_invoke_all('irc_msg_query', $data); }