RIRCB
RIRCB is a IRC Bot written in Ruby. It is designed to be an extensible framework that would allow anyone to add new commands.Installing
To install RIRCB you first need to pull a copy of it from the git repo:
git://github.com/Arcath/RIRCB.git
Once you have a copy of the code cd into your RIRCB directory and run:
rake setup
If you dont have Rake installed you will need to install it. You will now bw guided through the setup of the bot and the bot.yml file will be created
Adding a command
All .rb files in the commands directory are automatically loaded and added to the commands list when the the bot starts up. To add a new one simply copy this code into a file named exactly the same as the command method
1 class Command
2 def newcmd(msg,chan)
3 #Code here
4 end
5 end
When writing a command you have access to a couple of instance variables. @irc is the connection to the IRC server. The instance methods you will want to use are:
| Method | Usage | Output |
|---|---|---|
| privmsg | 1 @irc.privmsg("hello world","#whitefall") | Sends "hello world" as a standard message to the IRC Channel #whitefall |
| notice | 1 @irc.notice("hello world","#whitefall") | Sends "hello world" as a notice to the IRC Channel #whitefall |
| part | 1 part("goodbye","#whitefall") | Leaves the channel "#whitefall" with the parting message "goodbye" |
| join | 1 join("#whitefall") | Joins the channel "#whitefall" |
@bot is the bot object. There isn't anything in the bot object for you really, the 2 command options are already used in the reboot and reload commands.
Commands
In these examples I have my command mark set to "!"
| Command | Example | Result |
|---|---|---|
| repeat | !repeat this | In the IRC Channel: RIRCB: this |
| help | !help | In the IRC Channel: RIRCB: RIRCB runs RIRCB and has the following commands: {cmdlist} |
| reboot | !reboot | In the IRC Channel: RIRCB will quit with the message "Leaving... back soon" In the backend: RIRCB will self terminate and start up again |
| kill | !kill | In the IRC Channel: RIRCB will quit with the message "Leaving" In the backend: The process will terminate |