Difference between revisions of "Nanobot code help"

From Insomnia 24/7 Wiki
Jump to: navigation, search
imported>Wikiadmin
(Demo module)
imported>Wikiadmin
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Demo module ==
+
== Writing plugins for nanobot ==
This is the demo.pm module, which is used to demonstrate a modules capabilities and provide an example implementation.
+
If you cannot find a plugin with the functionality you need you may decide you want to write a plugin yourself.
<pre>
 
#!/usr/local/bin/perl
 
 
# These are the variables passed to each function call.
 
#
 
# $_[0] = name for this module (surely you already know this, but still)
 
# $_[1] = sending nickname
 
# $_[2] = sending username
 
# $_[3] = sending hostmask
 
# $_[4] = sending channel (or botnick in case of PM)
 
# $_[5] = current value for $modchan
 
# $_[6] = current value for $botnick
 
# $_[7] = arguments given in IRC
 
 
# The package name must match the filename + .pm, so this file should be called "demo.pm".
 
package demo;
 
 
if ( $firstcall == 0 ) {
 
# Here is some code that is executed when the module is loaded and when a function is called.
 
nanobot::snd("PRIVMSG #bot :Demo module was loaded!");
 
$firstcall == 1;
 
}
 
 
# sub join {} is a special name, if you implement this you will receive JOIN info trough this subroutine
 
# Implementing the join subroutine is optional.
 
 
# Example implemetation of join:
 
sub join {
 
nanobot::snd("PRIVMSG $_[4] :Hello $_[1], welcome to $_[4]!");
 
}
 
 
 
# sub mesg {} is a special name, if you implement this you will receive all messages that don't start with ! (since these are bot commands)
 
# Implementing the mesg subroutine is optional.
 
 
 
# sub notice {} is a special name, if you implement this you will receive notices to the bot.
 
# Implementing the notice subroutine is optional.
 
 
 
# sub raw {} is a special name, if you implement this you will receive all the raw data the bot receives.
 
# This is all raw IRC data, so the normal variables will not be available, this means you'll have to parse this data yourself!
 
# The raw data will be available in the subroutine in the variable $_
 
# Use this function with caution.
 
# Implementing the raw subroutine is optional.
 
 
 
# sub public {} is a special name, this function should contain an array of publicly available function names.
 
# When this subroutine is not implemented, all functions will only be available to bot opers.
 
sub public {
 
@public = ("help", "function");
 
}
 
 
 
# sub help {} is a special name, if you implement this subroutine it will be called when your module is called with no parameters.
 
# Implementing the mesg subroutine is optional, but highly reckomended.
 
sub help {
 
nanobot::snd("NOTICE $_[1] :Commands: help, function, listargs");
 
}
 
 
# Every subroutine is a function that can be called from IRC.
 
sub function {
 
# You can use nanobot::function to use the functions from nanobot. (obviously)
 
nanobot::snd("PRIVMSG $_[4] :Message from demo module!");
 
}
 
 
# This command is only available to bot opers or when pubmods is set.
 
sub listargs {
 
nanobot::snd("PRIVMSG $_[4] :@_");
 
}
 
 
# A module must always end with the line "1;", Perl demands it.
 
1;
 
</pre>
 
  
== What a module MUST have ==
+
== The demo plugin ==
=== Package name ===
+
By far the best place to start is with the demo plugin. It has a short description and example for every special function and examples of some common constructions you may use when writing your own plugin. For a list of the special functions and when they're called have a look at [[Nanobot_manual#Plugins]]
You need to define your module as a Perl package, so the bot will be able to call it.<br />
+
Besides that hand full of special functions it's just plain Ruby.
All you need to do this is add the line '''package yourpackagename;''' to the top of your module file.
 
  
=== File name ===
+
== Global objects ==
The bot needs to have a filename for your module that matches the package name, so if your module has '''package awesomemodule;''' your module file will need to be called '''awesomemodule.pm'''.
+
There are a few global objects that a plugin gets access to when it's loaded, these are defined in the initialize function.
 +
We will be describing functions using the following conventions:
 +
:'''function()''': name of a function so in ruby this would be 'def function'
 +
:''argument'': required argument to a function.
 +
:''<argument>'': optional argument to a function.
 +
:''arg1|arg2'': A specific set of options that are accepted. The function expects either 'arg1' or 'arg2' but not both or neither.
 +
:''<arg1|arg2>'': A specific set of options that are accepted. Unlike the previous, the function may also be called without any arguments. When called without arguments, the function will usually return the current value.
  
=== The last line ===
+
=== @status ===
Every Perl module must end with the line '''1;''' this is so that Perl can keep track of where modules end.
+
This object contains most of the runtime state of the bot. Functions exist to interact with the status objects:
 +
:'''output(''' ''<0|1>'' ''')''': Enable or disable output (-q option on the commandline)
 +
:'''colour(''' ''<0|1>'' ''')''': Enable or disable colour in console output (-c option on the commandline)
 +
:'''debug(''' ''<0|1|2|3>'' ''')''': Controls the debug level (-d option on the commandline)
 +
:'''login(''' ''<0|1>'' ''')''': Switch so the bot knows if it's past it's login sequence. (Ident with nickserv and wait for ping if configured to do so.) Normally not something you want to manipulate yourself
 +
:'''threads(''' ''<0|1>'' ''')''': Controls if threading is enabled. Not something you'd want to normally change at runtime. Things may break horribly if you do. (-t/-nt options on the commandline)
 +
:'''tabcomplete(''' ''<0|1>'' ''')''': Enable or disable tab completion on the console
 +
:'''ssl(''' ''<0|1>'' ''')''': Control use of SSL on connect. No reason to ever change this after you've connected. (-s option on the commandline)
 +
:'''console(''' ''<0|1>'' ''')''': Enable or disable the interactive console (-n option on the commandline)
 +
:'''reconnect(''' ''<0|1>'' ''')''': Control if we should attempt to reconnect automatically if the connection to the IRC server is lost.
 +
:'''autoload(''' ''<0|1>'' ''')''': Status bit to see if we've completed the autoload on startup. No reason to change this yourself.
 +
:'''showconfig(''' ''<0|1>'' ''')''': Used to check if the -p option is given on the commandline. Does nothing after startup.
 +
:'''plugins(''' ''<plugin array>'' ''')''': Used to set or retrieve or set the whole list of plugins references. Not something you'd normally want to get and certainly not something you'd want to set yourself.
 +
:'''addplugin(''' ''plugin_name, plugin_object'' ''')''': Add a plugin to the plugins list. Not something you need unless you're loading in ruby objects yourself.
 +
:'''delplugin(''' ''plugin_name'' ''')''': Removes a plugin from the list of active plugins. Normally only done by the !unload command.
 +
:'''checkplugin(''' ''plugin_name'' ''')''': Check if a plugin by that name is loaded.
 +
:'''getplugin(''' ''plugin_name'' ''')''': Retrieve the reference to a plugin so we can execute it's functions.
 +
:'''startup()''': Returns the time object of when the bot was started.
 +
:'''uptime(''' ''<current_time_object>, <old_time_object>'' ''')''': Returns a human readable string of how much time is between the two time objects. The first defaults to Time.now the second defaults to the bots startup time.
 +
:'''giveconfig(''' ''config_object'' ''')''': Set the config object used by the status object. Normally done by the bot on startup after the config is parsed.
 +
:'''getBaseComplete()''': Returns a list of the built in functions and loaded plugin names. Used by the tab-complete functionality of the interactive console.
 +
:'''getPluginComplete(''' ''plugin_name'' ''')''': Returns a list of a plugins' functions . Used by the tab-complete functionality of the interactive console.
  
 +
=== @config ===
 +
The object contains the static configuration held in config.rb. Any changes made to the contents of the @config object will be lost when the bot is stopped.
 +
:'''nick(''' ''<nickname>'' ''')''': Stores the bot's own nickname. Note that changing this value does not send the 'NICK' command to the IRC server.
 +
:'''pass(''' ''<password>'' ''')''': Stores the bot's nickserv password.
 +
:'''user(''' ''<username>'' ''')''': Stores the username portion of the bot's identification.
 +
:'''version()''': Returns the string containing the current version of the bot.
 +
:'''command(''' ''<cmd_string>'' ''')''': Stores the character used to prefix commands in IRC.
 +
:'''server()''': Returns the address/hostname of the server the bot is connecting to.
 +
:'''port()''': Returns the port number the bot is connecting to.
 +
:'''ssl(''' ''<true|false>'' ''')''': Stores if we should connect using ssl.
 +
:'''verifyssl(''' ''<true|false>'' ''')''': Stores if we should attempt to see if the SSL certificate is valid. (Not self-signed, expired, revoked etc.)
 +
:'''rootcert()''': Returns the location where it looks for SSL root certificates when trying to verify the server's SSL certificate.
 +
:'''ipv6(''' ''<true|false>'' ''')''': Stores if the bot uses @server or @server6 to connect.
 +
:'''serverpass(''' ''<password>'' ''')''': Stores the password used to connect to the IRC server.
 +
:'''connectoptions(''' ''<connect string>'' ''')''': Stores any other string you want to send right when the bot connects. I have no idea why you'd want to do such a thing though.
 +
:'''threads(''' ''<true|false>'' ''')''': Stores if the bot uses threads or not.
 +
:'''threadingfallback()''': Returns if we're allowed to fall back to not using threads if they're not available.
 +
:'''connecttimeout()''': Returns the socket timeout on connecting to the IRC server
 +
:'''pingtimeout()''': Returns the ping timeout after which we will assume we lost connection with the server.
 +
:'''antiflood(''' ''<true|false>'' ''')''': Stores if we should throttle users sending commands to the bot.
 +
:'''floodtime(''' ''<seconds>'' ''')''': Stores the limit for how much time there should be between commands.
 +
:'''floodcut(''' ''<seconds>'' ''')''': Stores how long the delay should become before we just start dropping commands.
 +
:'''throttleoutput(''' ''<true|false>'' ''')''': Stores if we should throttle our own output so the server does not ban us for spamming when there is a lot of output.
 +
:'''rejoin(''' ''<true|false>'' ''')''': Stores if we should try to rejoin a channel when kicked.
 +
:'''rejointime(''' ''<seconds>'' ''')''': Stores how many seconds we should wait before trying to rejoin after being kicked.
 +
:'''waitforping(''' ''<true|false>'' ''')''': Stores if we should wait for the server to send a PING before trying to join channels.
 +
:'''opers(''' ''<list_of_opres'' ''')''': Stores the list of hosts that are bot admins.
 +
:'''channels(''' ''<list_of_channels'' ''')''': Stores the list of channels that we automatically join on connect.
 +
:'''autoload(''' ''<list_of_plugin_names>'' ''')''': Stores the list of plugins to load on startup.
 +
:'''datadir(''' ''<directory_name>'' ''')''': Stores the name of the directory where data may be stored.
 +
:'''plugindir(''' ''<directory_name'' ''')''': Stores the name of the directory where the bot looks for plugins.
 +
:'''auth(''' ''hostname, console_bool'' ''')''': Check if you are authorized to execute a command either because your hostname is in the opers list or because the command is executed from the interactive console.
 +
:'''show()''': Called on startup to see if the -p option is set. Do not call manually since it calls 'Process.exit' at the end of the function.
 +
:'''yn(''' ''variable'' ''')''': Helper function for 'show()'. Returns 'Yes' if a variable is true, 'No' if false.
  
== What modules should have ==
+
=== @output ===
=== Help ===
+
Object used to send output to the console.
Though implementing the '''help''' subroutine is optional, it is highly recommended.<br />
+
:'''std(''' ''string'' ''')''': Prints a string. No automatic newlines.
The bot will call this subroutine when it receives no fucntion call to a module call. (When someone uses !examplemodule instead of !examplemodule.function.)<br />
+
:'''info(''' ''string'' ''')''': Prints a string in yellow. No automatic newlines.
'''The help subroutine is ALWAYS a public command!'''
+
:'''special(''' ''string'' ''')''': Prints a string in blue. No automatic newlines.
 +
:'''good(''' ''string'' ''')''': Prints a string in green. No automatic newlines.
 +
:'''bad(''' ''string'' ''')''': Prints a string in red. No automatic newlines.
 +
:'''debug(''' ''string'' ''')''': Prints a string if the debug level is 1 or higher.
 +
:'''debug_extra(''' ''string'' ''')''': Prints a string if the debug level is 2 or higher.
 +
:'''c(''' ''string'' ''')''': Prints a string for the interactive console. Does not print if console is disabled. No newlines.
 +
:'''cinfo(''' ''string'' ''')''': Same as above, except in yellow.
 +
:'''cgood(''' ''string'' ''')''': Same as above, except in green.
 +
:'''cbad(''' ''string'' ''')''': Same as above, except in red.
 +
:'''cspecial(''' ''string'' ''')''': Same as above, except in blue.
  
=== Public ===
+
=== @irc ===
The '''public''' subroutine is also optional. This subroutine will be called when a non-admin user calls a command. The subroutine should contain an array (@public) of commands that you want to be be available to all users.<br />
+
Object to interact with the IRC socket
<pre>
+
:'''socket()''': Return a reference to the raw socket object. Not something you normally need.
sub public {
+
:'''raw(''' ''line, <true|false>'' ''')''': Send a raw string to the socket. True or false may be specified as the second argument to indicate if this is a priority message. If true it will be placed in a special high priority output queue so it will bypass any long output queues.
@public = ("function1", "function2");
+
:'''connect()''': Used by the bot to set up the initial connection with the IRC server.
}
+
:'''reconnect()''': Used by the bot to reconnect if required for whatever reason.
</pre>
+
:'''disconnect()''': Try to send any messages in the queue and close the connection to the IRC server.
In this example '''function1''' and '''function2''' can be called by any user, but no other functions are available to the public.
+
:'''sendinit()''': Used by the bot upon connect to send server passwords and nickname information.
 +
:'''login()''': Used by the bot to identify with nickserv and autojoin channels.
 +
:'''pong(''' ''PING_line'' ''')''': Used by the bot to respond to PING requests from the server.
 +
:'''message(''' ''dest, message, <true|false>'' ''')''': Send a normal IRC message. Dest may be a nickname or a channel. The boolean specifies if it is a high priority message.
 +
:'''notice(''' ''dest, message, <true|false>'' ''')''': Same as above, except a notice is sent.
 +
:'''nick(''' ''nickname, <true|false>'' ''')''': Send a NICK command to the server to change the bots nickname. Also sets @config.nick. A priority may be specified.
 +
:'''topic(''' ''channel, topic, <true|false>'' ''')''': Set the topic of a channel. High priority may be specified.
 +
:'''join(''' ''channel, <true|false>'' ''')''': Send JOIN command to join a channel. High priority may be specified.
 +
:'''part(''' ''channel, <true|false>'' ''')''': Same as above except PART command is sent.
 +
:'''kick(''' ''channel, user, reason, <true|false>'' ''')''': Kick a user from a channel with a specified reason. High priority may be specified.
 +
:'''mode(''' ''channel, mode, subject, <true|false>'' ''')''': Send MODE command to set modes on a subject. High priority may be specified.
 +
:'''quit(''' ''message, <true|false>'' ''')''': Send QUIT command with a quit message. High priority may be specified.
  
==Writing subroutines==
+
=== @timer ===
===How does a subroutine get called===
+
Object that can be used to schedule code to be executed at a later time.
You will almost always want to add a new subroutine to your module in order to make a command available to you and/or your users.<br />
+
:'''action(''' ''wait_time, command'' ''')''': Wait for ''wait_time'' seconds and then try to execute 'command'.
The commands you give it in IRC translate directly to package(module) names and functions.<br />
+
'''<span style="color:#FF0000">An eval() is performed on 'command' so use with caution!</span>'''
For example:
 
!hello.world
 
Will call a module '''hello''' and it's subroutine '''world'''.<br />
 
Arguements given to the command will be available as the variable $_[7] in the module. (See next section.)
 
 
 
===What variables are available===
 
The module receives an array of arguments whenever a function is called:
 
'''$_[0]''' The modules name.
 
'''$_[1]''' The nickname of the person sending the command.
 
'''$_[2]''' The username of the preson sending the command.
 
'''$_[3]''' The hostmast of the person sending the command.
 
'''$_[4]''' The channel from where the command was received. If the command was sent directly to the bot, this will be the bots nickname.
 
'''$_[5]''' The active channel that's currently set. ($modchan)
 
'''$_[6]''' The bots own nickname
 
'''$_[7]''' Any arguements given to the command in IRC.
 
:If more than one argument is given, the entire arguement string will be in this variable.
 
 
 
 
 
===How to use nanobot's functions===
 
Nanobot's functions can be called much like the functions of any other package in Perl.
 
This means you can call all of nanobot's subroutines like this: '''nanobot::subname();'''.
 
The ones you will probably need commonly are '''msg''', '''ntc''' and '''snd''', for private'''m'''e'''s'''sa'''g'''e, '''n'''o'''t'''i'''c'''e and '''s'''e'''nd'''.
 
====msg====
 
This send a normal message to a user or channel.<br />
 
nanobot::msg("#channel", "Message to send");
 
 
 
====ntc====
 
This will send a notice to a user or channel.<br />
 
nanobot::ntc("nickame", "Message to send");
 
 
 
====snd====
 
This command can be used to send raw data to the IRC server.<br />
 
Unlike the msg and ntc functions, this function does not create the correct IRC syntax for you.
 
You will need to specify the correct syntax yourself. This gives you both great freedom in what you can send, but also means you must make sure you send valid commands, as some IRC servers may disconnect you for sending an invalid command.
 
# Send a message to the $modchan.
 
nanobot::snd("PRIVMSG $_[5] :Hello world!");
 
 
 
== Optional subroutines ==
 
The following subroutines do not need to be implemented. They are exist only to make your life easier when you are writing a module.
 
===Mesg===
 
The mesg subroutine will receive any message sent to the bot or one of the channels it is in, provided the message does not start with an "!", since this character is reserved for commands sent to the bot.<br />
 
Example:
 
<pre>
 
sub mesg {
 
    # Echo the message back to a specified channel.
 
    nanobot::msg("#mychannel", "$_[1] said $_[7]");
 
}
 
</pre>
 
 
 
===Notice===
 
The notice subroutine will catch any notices sent to the bot or to a channel the bot is on.<br />
 
Example:
 
<pre>
 
sub notice {
 
    # Forward notices to a user
 
    nanobot::ntc("myowner", "Received notice from $_[1] containing: $_[7]");
 
}
 
</pre>
 
 
 
===Join===
 
This subroutine will be called whenever a user joins the channel.<br />
 
Example:
 
<pre>
 
sub join {
 
# Notify $modchan when a user joins any other channel the bot is on.
 
nanobot::msg("$_[5]", "Looks like $_[1] just joined $_[4]");
 
}
 
</pre>
 
 
 
===Raw===
 
This subroutine is called whenever the bot receives data.<br />
 
It is a very powerful subroutine, since it allows you to grab and modify any data the bot has access to.
 
 
 
This is the only subroutine where the normal variables are not available, as they have not yet been processed and split. Instead the variable '''$_''' is available which contains the raw data from the socket.
 
 
 
'''Warning:''' When using the raw subroutine, you can modify the actual data the rest of the bot receives, so make to only work with copies of variables when this is not your intention.
 
 
 
Example:
 
<pre>
 
sub raw {
 
# Send data to terminal screen for debugging
 
nanobot::logts("$_\n");
 
}
 
</pre>
 
 
 
===First call===
 
This is a demo construction of how to make a function that will only be called once when the module loads:
 
<pre>
 
if ( $firstcall == 0 ) {
 
# Here is some code that is executed when the module is loaded and when a function is called.
 
nanobot::snd("PRIVMSG #bot :Module was loaded!");
 
$firstcall == 1;
 
}
 
</pre>
 

Latest revision as of 17:54, 31 August 2014

Writing plugins for nanobot

If you cannot find a plugin with the functionality you need you may decide you want to write a plugin yourself.

The demo plugin

By far the best place to start is with the demo plugin. It has a short description and example for every special function and examples of some common constructions you may use when writing your own plugin. For a list of the special functions and when they're called have a look at Nanobot_manual#Plugins Besides that hand full of special functions it's just plain Ruby.

Global objects

There are a few global objects that a plugin gets access to when it's loaded, these are defined in the initialize function. We will be describing functions using the following conventions:

function(): name of a function so in ruby this would be 'def function'
argument: required argument to a function.
<argument>: optional argument to a function.
arg1|arg2: A specific set of options that are accepted. The function expects either 'arg1' or 'arg2' but not both or neither.
<arg1|arg2>: A specific set of options that are accepted. Unlike the previous, the function may also be called without any arguments. When called without arguments, the function will usually return the current value.

@status

This object contains most of the runtime state of the bot. Functions exist to interact with the status objects:

output( <0|1> ): Enable or disable output (-q option on the commandline)
colour( <0|1> ): Enable or disable colour in console output (-c option on the commandline)
debug( <0|1|2|3> ): Controls the debug level (-d option on the commandline)
login( <0|1> ): Switch so the bot knows if it's past it's login sequence. (Ident with nickserv and wait for ping if configured to do so.) Normally not something you want to manipulate yourself
threads( <0|1> ): Controls if threading is enabled. Not something you'd want to normally change at runtime. Things may break horribly if you do. (-t/-nt options on the commandline)
tabcomplete( <0|1> ): Enable or disable tab completion on the console
ssl( <0|1> ): Control use of SSL on connect. No reason to ever change this after you've connected. (-s option on the commandline)
console( <0|1> ): Enable or disable the interactive console (-n option on the commandline)
reconnect( <0|1> ): Control if we should attempt to reconnect automatically if the connection to the IRC server is lost.
autoload( <0|1> ): Status bit to see if we've completed the autoload on startup. No reason to change this yourself.
showconfig( <0|1> ): Used to check if the -p option is given on the commandline. Does nothing after startup.
plugins( <plugin array> ): Used to set or retrieve or set the whole list of plugins references. Not something you'd normally want to get and certainly not something you'd want to set yourself.
addplugin( plugin_name, plugin_object ): Add a plugin to the plugins list. Not something you need unless you're loading in ruby objects yourself.
delplugin( plugin_name ): Removes a plugin from the list of active plugins. Normally only done by the !unload command.
checkplugin( plugin_name ): Check if a plugin by that name is loaded.
getplugin( plugin_name ): Retrieve the reference to a plugin so we can execute it's functions.
startup(): Returns the time object of when the bot was started.
uptime( <current_time_object>, <old_time_object> ): Returns a human readable string of how much time is between the two time objects. The first defaults to Time.now the second defaults to the bots startup time.
giveconfig( config_object ): Set the config object used by the status object. Normally done by the bot on startup after the config is parsed.
getBaseComplete(): Returns a list of the built in functions and loaded plugin names. Used by the tab-complete functionality of the interactive console.
getPluginComplete( plugin_name ): Returns a list of a plugins' functions . Used by the tab-complete functionality of the interactive console.

@config

The object contains the static configuration held in config.rb. Any changes made to the contents of the @config object will be lost when the bot is stopped.

nick( <nickname> ): Stores the bot's own nickname. Note that changing this value does not send the 'NICK' command to the IRC server.
pass( <password> ): Stores the bot's nickserv password.
user( <username> ): Stores the username portion of the bot's identification.
version(): Returns the string containing the current version of the bot.
command( <cmd_string> ): Stores the character used to prefix commands in IRC.
server(): Returns the address/hostname of the server the bot is connecting to.
port(): Returns the port number the bot is connecting to.
ssl( <true|false> ): Stores if we should connect using ssl.
verifyssl( <true|false> ): Stores if we should attempt to see if the SSL certificate is valid. (Not self-signed, expired, revoked etc.)
rootcert(): Returns the location where it looks for SSL root certificates when trying to verify the server's SSL certificate.
ipv6( <true|false> ): Stores if the bot uses @server or @server6 to connect.
serverpass( <password> ): Stores the password used to connect to the IRC server.
connectoptions( <connect string> ): Stores any other string you want to send right when the bot connects. I have no idea why you'd want to do such a thing though.
threads( <true|false> ): Stores if the bot uses threads or not.
threadingfallback(): Returns if we're allowed to fall back to not using threads if they're not available.
connecttimeout(): Returns the socket timeout on connecting to the IRC server
pingtimeout(): Returns the ping timeout after which we will assume we lost connection with the server.
antiflood( <true|false> ): Stores if we should throttle users sending commands to the bot.
floodtime( <seconds> ): Stores the limit for how much time there should be between commands.
floodcut( <seconds> ): Stores how long the delay should become before we just start dropping commands.
throttleoutput( <true|false> ): Stores if we should throttle our own output so the server does not ban us for spamming when there is a lot of output.
rejoin( <true|false> ): Stores if we should try to rejoin a channel when kicked.
rejointime( <seconds> ): Stores how many seconds we should wait before trying to rejoin after being kicked.
waitforping( <true|false> ): Stores if we should wait for the server to send a PING before trying to join channels.
opers( <list_of_opres ): Stores the list of hosts that are bot admins.
channels( <list_of_channels ): Stores the list of channels that we automatically join on connect.
autoload( <list_of_plugin_names> ): Stores the list of plugins to load on startup.
datadir( <directory_name> ): Stores the name of the directory where data may be stored.
plugindir( <directory_name ): Stores the name of the directory where the bot looks for plugins.
auth( hostname, console_bool ): Check if you are authorized to execute a command either because your hostname is in the opers list or because the command is executed from the interactive console.
show(): Called on startup to see if the -p option is set. Do not call manually since it calls 'Process.exit' at the end of the function.
yn( variable ): Helper function for 'show()'. Returns 'Yes' if a variable is true, 'No' if false.

@output

Object used to send output to the console.

std( string ): Prints a string. No automatic newlines.
info( string ): Prints a string in yellow. No automatic newlines.
special( string ): Prints a string in blue. No automatic newlines.
good( string ): Prints a string in green. No automatic newlines.
bad( string ): Prints a string in red. No automatic newlines.
debug( string ): Prints a string if the debug level is 1 or higher.
debug_extra( string ): Prints a string if the debug level is 2 or higher.
c( string ): Prints a string for the interactive console. Does not print if console is disabled. No newlines.
cinfo( string ): Same as above, except in yellow.
cgood( string ): Same as above, except in green.
cbad( string ): Same as above, except in red.
cspecial( string ): Same as above, except in blue.

@irc

Object to interact with the IRC socket

socket(): Return a reference to the raw socket object. Not something you normally need.
raw( line, <true|false> ): Send a raw string to the socket. True or false may be specified as the second argument to indicate if this is a priority message. If true it will be placed in a special high priority output queue so it will bypass any long output queues.
connect(): Used by the bot to set up the initial connection with the IRC server.
reconnect(): Used by the bot to reconnect if required for whatever reason.
disconnect(): Try to send any messages in the queue and close the connection to the IRC server.
sendinit(): Used by the bot upon connect to send server passwords and nickname information.
login(): Used by the bot to identify with nickserv and autojoin channels.
pong( PING_line ): Used by the bot to respond to PING requests from the server.
message( dest, message, <true|false> ): Send a normal IRC message. Dest may be a nickname or a channel. The boolean specifies if it is a high priority message.
notice( dest, message, <true|false> ): Same as above, except a notice is sent.
nick( nickname, <true|false> ): Send a NICK command to the server to change the bots nickname. Also sets @config.nick. A priority may be specified.
topic( channel, topic, <true|false> ): Set the topic of a channel. High priority may be specified.
join( channel, <true|false> ): Send JOIN command to join a channel. High priority may be specified.
part( channel, <true|false> ): Same as above except PART command is sent.
kick( channel, user, reason, <true|false> ): Kick a user from a channel with a specified reason. High priority may be specified.
mode( channel, mode, subject, <true|false> ): Send MODE command to set modes on a subject. High priority may be specified.
quit( message, <true|false> ): Send QUIT command with a quit message. High priority may be specified.

@timer

Object that can be used to schedule code to be executed at a later time.

action( wait_time, command ): Wait for wait_time seconds and then try to execute 'command'.

An eval() is performed on 'command' so use with caution!