Пример #1
0
            // any values here do rather...
            $_SERVER['REQUEST_METHOD'] = NULL;
            // ...odd things. uh huh.
            break;
    }
}
// load in our required libraries.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once 'Net/SmartIRC.php';
// initialize the bot with some sane defaults.
global $irc;
$bot = new drupal_wrapper();
$irc = new Net_SmartIRC();
$irc->setDebug(variable_get('bot_debugging', 0) ? SMARTIRC_DEBUG_ALL : SMARTIRC_DEBUG_NONE);
$irc->setAutoReconnect(TRUE);
// reconnect to the server if disconnected.
$irc->setAutoRetry(TRUE);
// retry if a server connection fails.
$irc->setChannelSyncing(TRUE);
// keep a list of joined users per channel.
$irc->setUseSockets(TRUE);
// uses real sockets instead of fsock().
// send every message type the library supports to our wrapper class.
// we can automate the creation of these actionhandlers, but not the
// class methods below (only PHP 5 supports default methods easily).
$irc_message_types = array('UNKNOWN', 'CHANNEL', 'QUERY', 'CTCP', 'NOTICE', 'WHO', 'JOIN', 'INVITE', 'ACTION', 'TOPICCHANGE', 'NICKCHANGE', 'KICK', 'QUIT', 'LOGIN', 'INFO', 'LIST', 'NAME', 'MOTD', 'MODECHANGE', 'PART', 'ERROR', 'BANLIST', 'TOPIC', 'NONRELEVANT', 'WHOIS', 'WHOWAS', 'USERMODE', 'CHANNELMODE', 'CTCP_REQUEST', 'CTCP_REPLY');
foreach ($irc_message_types as $irc_message_type) {
    $irc->registerActionhandler(constant('SMARTIRC_TYPE_' . $irc_message_type), '.*', $bot, 'invoke_irc_msg_' . strtolower($irc_message_type));
}
// connect and begin listening.
Пример #2
0
// load in our required libraries.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once 'Net/SmartIRC.php';
// prevent MySQL timeouts on slow channels.
db_query('SET SESSION wait_timeout = %d', 24 * 60 * 60);
// initialize the bot with some sane defaults.
global $irc;
// allow it to be slurped by Drupal modules if need be.
$bot = new drupal_wrapper();
// wrapper that integrates with Drupal hooks.
$irc = new Net_SmartIRC();
// MmmmmmM. The IRC object itself. Magick happens here.
$irc->setDebug(variable_get('bot_debugging', 0) ? SMARTIRC_DEBUG_ALL : SMARTIRC_DEBUG_NONE);
// the (boolean) here is required, as Net_SmartIRC doesn't respect a FAPI checkbox value of 1, only TRUE.
$irc->setAutoReconnect((bool) variable_get('bot_auto_reconnect', 1));
// reconnect to the server if disconnected.
$irc->setAutoRetry((bool) variable_get('bot_auto_retry', 1));
// retry if a server connection fails.
$irc->setChannelSyncing(TRUE);
// keep a list of joined users per channel.
$irc->setUseSockets(TRUE);
// uses real sockets instead of fsock().
// send every message type the library supports to our wrapper class.
// we can automate the creation of these actionhandlers, but not the
// class methods below (only PHP 5 supports default methods easily).
$irc_message_types = array('UNKNOWN', 'CHANNEL', 'QUERY', 'CTCP', 'NOTICE', 'WHO', 'JOIN', 'INVITE', 'ACTION', 'TOPICCHANGE', 'NICKCHANGE', 'KICK', 'QUIT', 'LOGIN', 'INFO', 'LIST', 'NAME', 'MOTD', 'MODECHANGE', 'PART', 'ERROR', 'BANLIST', 'TOPIC', 'NONRELEVANT', 'WHOIS', 'WHOWAS', 'USERMODE', 'CHANNELMODE', 'CTCP_REQUEST', 'CTCP_REPLY');
foreach ($irc_message_types as $irc_message_type) {
    $irc->registerActionhandler(constant('SMARTIRC_TYPE_' . $irc_message_type), '.*', $bot, 'invoke_irc_msg_' . strtolower($irc_message_type));
}
// set up a timers similar to Drupal's hook_cron(), multiple types. I would have
Пример #3
0
    {
        global $channels;
        foreach ($channels as $prj_id => $options) {
            foreach ($options as $chan => $categories) {
                $irc->join($chan);
            }
        }
    }
}
require_once 'Net/SmartIRC.php';
$bot = new Eventum_Bot();
$irc = new Net_SmartIRC();
$irc->setLogdestination(SMARTIRC_FILE);
$irc->setLogfile(APP_IRC_LOG);
$irc->setUseSockets(true);
$irc->setAutoReconnect(true);
$irc->setAutoRetry(true);
$irc->setReceiveTimeout(600);
$irc->setTransmitTimeout(600);
$irc->registerTimehandler(3000, $bot, 'notifyEvents');
// methods that keep track of who is authenticated
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?list-auth', $bot, 'listAuthenticatedUsers');
$irc->registerActionhandler(SMARTIRC_TYPE_NICKCHANGE, '.*', $bot, '_updateAuthenticatedUser');
$irc->registerActionhandler(SMARTIRC_TYPE_KICK | SMARTIRC_TYPE_QUIT | SMARTIRC_TYPE_PART, '.*', $bot, '_removeAuthenticatedUser');
$irc->registerActionhandler(SMARTIRC_TYPE_LOGIN, '.*', $bot, '_joinChannels');
// real bot commands
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?help', $bot, 'listAvailableCommands');
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?auth ', $bot, 'authenticate');
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?clock', $bot, 'clockUser');
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?list-clocked-in', $bot, 'listClockedInUsers');
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!?list-quarantined', $bot, 'listQuarantinedIssues');