Go to file
2015-05-09 13:07:54 +02:00
plugins Improv / Plugin / All * 2015-05-09 13:03:56 +02:00
.gitignore Add up to gitignore 2015-05-01 17:30:33 +02:00
arguments.rb Add +s to --channels option 2015-05-07 22:51:34 +02:00
botpop.rb Use ENABLED instead of DISABLED 2015-05-09 12:52:42 +02:00
builtin.rb Add this awesome plugin.... I'am alive'.... 2015-05-09 01:32:25 +02:00
contributors Add contributors 2015-05-07 23:20:25 +02:00
Gemfile Add colorize to the gemfile 2015-05-06 23:57:20 +02:00
Gemfile.lock Add colorize to the gemfile 2015-05-06 23:57:20 +02:00
modules_config.yml Update default configuration 2015-05-09 13:06:10 +02:00
README.md Fix readme example 2015-05-09 12:57:07 +02:00
version Update version 2015-05-09 13:07:54 +02:00

botpop

Code Climate

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 no garanties... 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

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|
      parent.on :message, /!whatkingofanimal.*/ do |m| BotpopPlugins::exec_whatkingofanimal m end
    end
    ...code...
  end
end

Add entry to the !help command

The official plugin Base provides the command !help.

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.