4.7 KiB
botpop
Usage
Ruby 2 or greater is required. To be compatible with Ruby 1.9, you can try :
sed 's/prepend/include/g' -i botpop.rb
but i did never try... You better update ruby ! ;)
bundle install
to install the gems.
Arguments
By default, only the first occurence of the argument will be used, unless specified.
- --channels, -c OPTION : list of channels (default equilibre)
- --ip, -s OPTION : server ip (default to freenode)
- --port, -p OPTION : port (default 7000 or 6667 if no ssl)
- --no-ssl : disable ssl (enabled by default)
- --nick, -n OPTION : change the nickname
- --user, -u OPTION : change the username
- --config OPTION : change the plugin configuration file (default to
modules_config.yml
) - --plugin-directory OPTION : change the directory where the plugins are installed (default
plugins/
) - --plugin-disable OPTION : disable a plugin (can be specified many times)
- --debug, -d OPTION : enable the debug mod. It et a global $debug_OPTION to true. (can be specified many times)
Debugging easier
You can specify the --debug OPT option at program start. It will define as many $debug_OPT globals to enable debug on the plugins.
As example:
# If debug enabled for this options and error occured
if $debug_plugin and variable == :failed
binding.pry # user hand here
# Obsiously, it is usefull to trylock a mutex before because the bot use
# Threads and can call many times this binding.pry
end
Plugins
Some official plugins are developped. You can propose your own creation by pull request, or add snippets link to the wiki.
List
- Base : this is a basic plugin, providing version, code, help, and troll
- Network : an usefull plugin with commands ping, ping ip, ping http, traceroute, dos attack and poke
- Searchable : a little plugin providing irc research with engines like google, wikipedia, ruby-doc, etc...
- Coupon : the original aim of the bot. It get coupons for the challenge pathwar
- Intranet : an useless plugin to check the intranet of epitech
- Proxy : an audacious plugin to create user access to a local proxy
Create your own
You can easy create your own plugins.
The bot is based on Cinch framework. You should take the time to read the documentation before developping anything.
Example of new plugin
A full example of plugin code is provided in the commented file : Example of Fury Plugin
First, put your ruby code file in plugins/
, and put your code in the scope :
module BotpopPlugins
module MyFuryPlugin
def self.exec_whatkingofanimal m
m.reply "Die you son of a" + ["lion", "pig", "red panda"].shuffle.first + " !!"
end
...code...
end
end
Matching messages
To create a matching to respond to a message, you have to specifie in your plugin :
module BotpopPlugins
module MyFuryPlugin
MATCH = lambda do |parent, plugin|
parent.on :message, /!whatkingofanimal.*/ do |m| plugin.exec_whatkingofanimal m end
end
...code...
end
end
Add entry to the !help command
The official plugin Base provides the command !help and !help plugin.
It list the avaliable commands of the plugins. You can add your help to your plugin by providing a HELP constant. The strings should be as short as possible. You should write it like the following:
module BotpopPlugins
module MyFuryPlugin
HELP = ["!whatkingofanimal", "!animallist", "!checkanimal [type]"]
...code...
end
end
Enable and disable plugin
You can enable or disable plugin by using the constant ENABLED. It should be linked with the Botpop::CONFIG. The constant must be defined by the developper of the plugin. For example, you can implement it like :
module BotpopPlugins
module MyFuryPlugin
CONFIG = Botpop::CONFIG['myfurry'] || raise(MissingConfigurationZone, 'myfurry')
ENABLED = CONFIG['enable'].nil? ? true : CONFIG['enable']
end
end
Then, a simple line in the modules_configuration.yml
file should be enough.