I'm implementing my own irc server to host live chats, and I'd like to see if it is possible to have more control of the drupal bot joining channels, particularly by issuing a php command from a custom module.

My drupal site allows scheduling live chat sessions and integrates a flash based irc client to connect to my IRC server.

As such, I plan that the channels will be 'ephemeral'. That is, they will spawn for the chat and then be destroyed after everyone leaves. I don't want to have persistant channels or host generic discussions. (yes, I checked out some of the other chat room modules...they all have various limitations)

I'd like a bot to jump in when the channel is created, make a log of the activity and messages, and then post them to a drupal content type.

Is this possible and can anyone give me some suggestions of how I might begin to accomplish this?

Thanks,

Comments

morbus iff’s picture

Take a look at the code in 6.x-dev. In the past, the bot has had to be restarted to recognize (and connect to) a new channel, but the current development code (which has been running Druplicon for a good four or five months now) has support for channel joining based on the admin/settings/bot configurations. Of relevance:

* Configuration values made from admin/settings/bot are refreshed every 5 minutes.
* The bot checks its channels list every 15 seconds. If it's not in a configured channel, it joins it.

Ideally, your workflow would be something like:

* Your Drupal site is told to spawn a chat.
* The spawning code would modify the channels list of the bot.
* The spawning code would then modify the logged channels of the bot.

There are two problems as I see it:

1. There's currently no way to tell the bot to leave a channel (you can /kick it, of course).
2. The five minute refresh of the settings might cause an undesirable delay.

The second one you could get past by hacking bot.module to move the refresh from bot_irc_bot_cron to bot_irc_bot_cron_fastest. This would bring the delay down to 15 seconds, which is probably acceptable. The first one, I don't have an immediate suggestion for.

meecect’s picture

Thanks for the quick response. I upgraded and think I can tackle the workflow you suggested.

Of course, I can't seem to get the bot to work at all at the moment, though ;)

When I try to start it:

php bot_start.php --root /path/to/drupal/root --url http://www.example.com

I get output like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
    <title>Site off-line | Drupal</title>
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/maintenance.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/minnelli/minnelli.css?0" />
<link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?0" />
        <!--[if lt IE 7]>
      <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" />    <![endif]-->
  </head>
  <body>

<!-- Layout -->
  <div id="header-region" class="clear-block"></div>

    <div id="wrapper">
    <div id="container" class="clear-block">

      <div id="header">
        <div id="logo-floater">
        <h1><a href="/" title="Drupal"><img src="/themes/garland/minnelli/logo.png" alt="Drupal" id="logo" /><span>Drupal</span></a></h1>        </div>

      </div> <!-- /header -->

      
      <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
          <h2>Site off-line</h2>                              <div class="clear-block">
            <p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p><hr /><p><small>If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the <a href="http://drupal.org/node/258">handbook</a>, or contact your hosting provider.</small></p><p><small>The <em></em> error was: <em>The database type &#039;&#039; is unsupported. Please use either &#039;mysql&#039; or &#039;mysqli&#039; for MySQL, or &#039;pgsql&#039; for PostgreSQL databases.</em>.</small></p>          </div>
          <div id="footer"></div>
      </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->

      
    </div> <!-- /container -->
  </div>
<!-- /layout -->

  </body>
</html>

This is output on the command line. I should point out that I am using aegir, so I don't know if that interferes at all.

morbus iff’s picture

That error is from Drupal, not necessarily from the bot. What directory are you running the script? Instead of doing a /path/to/drupal/root, could you go into the bot directory, and use ../../, instead? So, like:

cd /path/to/drupal/root/sites/all/modules/bot
php ./bot_start.php --root ../../../../ --url http://www.example.com/

I'm not familiar with Aegir myself.

meecect’s picture

It has something to do with the way aegir writes the settings.php file, apparently. See here:

http://davexoxide.jaiku.com/presence/7b41e75ec9334bc3adebb589dc11aab7

I wonder where the error is happening though? I'd glady submit a fix..if I can find out where it's going wrong.

Anyway, now the error is gone, but I can't tell if it is working or not. The bot isn't in the channel I told him to go to.

sirkitree’s picture

I hardcoded $db_url in settings.php on my aegir setup and was able to start the bot up.

morbus iff’s picture

Status: Active » Closed (cannot reproduce)