Go to file
2016-05-15 00:04:17 +02:00
plugins Added kick and ops plugins 2016-05-14 23:32:54 +02:00
test fix builtins 2015-08-12 15:35:52 +02:00
.codeclimate.yml Add .codeclimate 2015-05-09 14:45:22 +02:00
.gitignore update gitignore 2015-08-12 16:09:54 +02:00
arguments.rb clean lew lines 2015-08-29 17:18:21 +02:00
botpop_plugin_inclusion.rb add plugin "example" and ignore it in inclusion 2015-08-11 23:34:34 +02:00
botpop.rb fix argument --plugin-disable 2015-08-29 16:47:02 +02:00
builtins.rb fix builtins 2015-08-12 15:35:52 +02:00
contributors update contributors list 2015-08-17 17:22:15 +02:00
DATABASE_EXTENSION.md Improve rights system 2015-08-24 15:21:35 +02:00
database.rb Improve rights system 2015-08-24 15:21:35 +02:00
Gemfile add dep 'i18n' 2015-12-30 22:08:08 +01:00
Gemfile.lock add dep 'i18n' 2015-12-30 22:08:08 +01:00
modules_config.yml.example add diceroller 2016-03-21 16:30:10 +01:00
Rakefile Improve rights system 2015-08-24 15:21:35 +02:00
README.md Fix readme 2015-11-20 12:51:22 +01:00
RIGHTS_MANAGEMENT.md fix groups problem 2015-08-24 15:52:04 +02:00
version add plugin points 2015-09-23 23:07:25 +02:00

botpop

Code Climate GitHub version

Requirements

  • Ruby 2.0 or greater
  • Postgresql 9.3 or greater

Installation

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 ! ;)

Too install the stuff, just do :

bundle install            # install the required gems
cp modules_config.yml.example modules_config.yml
editor modules_config.yml # set the database settings, etc.
# create your database
rake db:install           # migrate the base plugin

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. It also provide a full groups's system.
  • 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...
  • Proxy : an audacious plugin to create user access to a local proxy
  • Log : simple logger
  • IAmAlive : a plugin to learn how to respond to the users. Fucking machine learning, oh yearh.
  • CeQueTuDisNaAucunSens : a funny plugin to say "ce que tu dis n'a aucun sens" without any meaning.
  • Points : a gem to add points to an user. !p noob for_you
  • Anecdote : a cool meme generator plugin with nazi and youtuber. French meme.

In version 0.X, not upgraded to v1

  • 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 :

class MyFuryPlugin < Botpop::Plugin
  include Cinch::Plugin

  def exec_whatkingofanimal m
    m.reply "Die you son of a" + ["lion", "pig", "red panda"].sample + " !!"
  end
  ...code...
end

Matching messages

To create a matching to respond to a message, you have to specifie in your plugin :

class MyFuryPlugin < Botpop::Plugin
  include Cinch::Plugin
  match(/!whatkingofanimal.*/, use_prefix: false, method: :exec_whatkingofanimal)
  ...code...
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:

class MyFuryPlugin < Botpop::Plugin
  HELP = ["!whatkingofanimal", "!animallist", "!checkanimal [type]"]
  ...code...
end

Enable and disable plugin

You can enable or disable plugin by using the constant ENABLED. The constant must be defined by the developper of the plugin. For example, you can implement it like :

class MyFuryPlugin < Botpop::Plugin
  ENABLED = config['enable'].nil? ? true : config['enable']
end

Then, a simple line in the modules_configuration.yml file should be enough.

Plugin Configuration

You can configure your plugins via the file modules_configuration.yml. If you considere that your plugin needs a particular configuration file, then create a new one il the plugins directory.

To use the configuration loaded by modules_configuration.yml, use the method config.

config takes an optionnal Hash as argument. It can take:

  • :safe => (true or false)
  • :name => (string or symbol)

This method returns a Hash with configuration.

By default, the method raise a MissingConfigurationZone error if no entry in the modules_configuration.yml file.

The configuration file modules_configuration.yml must seems like :

name:
  entry: "string"
  entry2:
    - 1
    - 2.2
	- "ohoh"
	- nextelement:
	  - oh oh !

By default, the modules_configuration.yml file is configured for default plugins.

Plugin Database

Check this specified README FOR DATABASE IN PLUGINS

Rights managements (users, groups)

Requires postgresql, because it uses the pg_array extension.

Check this specified README FOR RIGHTS MANAGEMENT