Welcome to Rumpy
Our goal is 'DO NOT REINVENT THE WHEEL'.
- Forget about xmpp-related things. Just set your login and password.
- Forget about database-related things. Just set your database preferences.
- Write logic using
ActiveRecordand callback functions.
Rumpy uses 3 configs:
- database.yml :: Your bot's database preferences.
- lang.yml :: Your bot's responces. Append to existing keys more answers and use them like
@lang['someanswer']. There MUST be at least 3 keys:
hello(used when somebody adds bot),
stranger(used when somebody trying to speak with bot without authorization) and
authorized(used when bot gets authorization).
- xmpp.yml :: Your bot's jabber account settings.
Look at Examples section to see this configs.
You have to implement at least one model, for users.
Prepare your database
Your bot's class
You have to mix in your bot's class the
Rumpy uses next instance variables:
@models_files:: Array of your models files.
@config_path:: Path to directory, containing all ruby configuration files. Default is
@main_model:: Symbol, that stands for main model. For example, if your main model is
User, you have to set
@main_model = :user. And this is default.
@pid_file:: Location of the file to which pid of detached process will be saved. Default is
NameOfYourBotClass.downcase + '.pid'.
@log_file:: Location of the logfile. Default is
@log_level:: Logging severity threshold. Possible values are the same the logger from standard library has. Default is
@log_shift_age:: Number of old log files to keep, or frequency of rotation (
monthly). Default is
@log_shift_size:: Maximum logfile size. Default is
@logger:: If you need more accuracy in configuring logger, simply create one. It have to be compatible with standard library's
@bot_name:: Name of the bot. Default is name of bot's class.
@bot_version:: Optional version of the bot. Default is
Rumpy needs only three methods:
backend_func() -> [[receiver, message]*]:: This optional method is running all the time in the loop. Returns array of pairs
parser_func(msg) -> pars_result:: This method parses any incoming message and returs results of parsing.
do_func(usermodel, pars_results) -> msg:: This method uses results from
parser_func, doing some stuff with model of user, from whom the message was received. Returns the answer to this user.
Hint: empty answer will not be sent.
You can run your bot without detaching:
Or with detaching:
bot = YourBotClassName.new #To start your bot: Rumpy.start bot #To stop it: Rumpy.stop bot
Feel free to contact us about any questions related to Rumpy.
Rumpy is released under the MIT license.