Last updated November 9, 2009. Created by snufkin on March 13, 2009.
Edited by LeeHunter. Log in to edit this page.
Initial documentation for developing bot modules.
bot.module uses the net_smartirc php class to work with IRC.
The global $irc object
$irc is the object created when running the bot_start.php. It is a Net_SmartIRC() object. Configuration of the IRC connection happens by setting certain values belonging to this object.
Example: $irc->setAutoReconnect((boolean)variable_get('bot_auto_reconnect', 1)); which makes the bot try to reconnect to the server if disconnected for some reason.
In bot_start.php several configurations are set (for exact parameters check the source): $irc->setDebug(), $irc->setAutoReconnect(), $irc->setAutoRetry(), $irc->setChannelSyncing(), $irc->setUseSockets(), $irc->registerActionhandler(), $irc->registerTimehandler().
After the settings and registration of callbacks the bot is connected and logged in, then joins the configured channels and starts listening.
Some properties of $irc, such as $irc->channel, which is array type only becomes available after connecting to the channel, so make sure you check for the variable before doing a loop over its elements.
$irc object documentation
After joining the channels most of the $irc object gets populated with interesting details of the network.
Example $irc->channel (array):
Array
(
[#test] => Net_SmartIRC_channel Object
(
[name] => #test
[key] =>
[users] => Array
(
[bot] => Net_SmartIRC_channeluser Object
(
[op] =>
[voice] =>
[nick] => bot
[ident] => ~bot
[host] => localhost
[realname] =>
[ircop] =>
[away] =>
[server] =>
[hopcount] =>
)
[balu] => Net_SmartIRC_channeluser Object
(
[op] =>
[voice] =>
[nick] => balu
[ident] =>
[host] =>
[realname] =>
[ircop] =>
[away] =>
[server] =>
[hopcount] =>
)
)
[ops] => Array
(
)
[voices] => Array
(
)
[bans] => Array
(
)
[topic] =>
[mode] =>
)
)