Convos::Plugin::Bot - A bot system for Convos

  1. SYNOPSIS
  2. DESCRIPTION
    1. Example config file
    2. Actions
  3. HELPERS
    1. bot
  4. ATTRIBUTES
    1. actions
    2. config
    3. user
  5. METHODS
    1. action
    2. load_config_file
    3. register
  6. SEE ALSO

SYNOPSIS

$ [email protected] ./script/convos daemon

DESCRIPTION

Convos::Plugin::Bot is a bot system that integrates tightly with Convos. This works by registering a user with the email specified by the CONVOS_BOT_EMAIL environment variable and a random password.

The bot will read $CONVOS_HOME/$CONVOS_BOT_EMAIL/bot.yaml on a regular interval and act upon the instructions. Some instructions can also be given using chat commands, if you are a convos admin.

Example config file

---
generic:
  password: supersecret # Set bot login password
  reply_delay: 1        # Wait one second before posting reply

# The order of actions is significant, since the first action
# that generates a reply wins.
actions:
- class: Convos::Plugin::Bot::Action::Core
- class: Convos::Plugin::Bot::Action::Karma
- class: Convos::Plugin::Bot::Action::Calc

# Default config parameters can be specified for each action,
# and overridden per connection or channel
- class: Convos::Plugin::Bot::Action::Hailo
  free_speak_ratio: 0
  reply_on_highlight: 0

# Specify which servers to connect to
connections:
- url: 'irc://localhost:6667?tls=0'
  wanted_state: connected          # connected (default), disconnected
  actions:
    Convos::Plugin::Bot::Action::Hailo:
      free_speak_ratio: 0.001      # override "free_speak_ratio" for any conversation on freenode
  conversations:
    "#convos":
      password: s3cret             # optional
      state: join                  # join (default), part
      actions:
        Convos::Plugin::Bot::Action::Hailo:
          free_speak_ratio: 0.5    # override "free_speak_ratio" for #convos on freenode

Actions

"Actions" are modules that provide the bot with functionality. Each action can react to messages and/or generate replies. Bundled with Convos you have some core actions, but you can also write your own. The core actions are:

HELPERS

bot

$bot = $app->bot;
$bot = $c->bot;

Can be used to access the $bot instance from the Convos web application.

ATTRIBUTES

actions

$hash_ref = $bot->actions;

Holds a key value pair where the keys are Convos::Plugin::Bot:: class names and the value is an instance of that class.

config

$pointer = $bot->config;

Holds the global config in a Mojo::JSON::Pointer object.

user

$user = $bot->user;

Holds a Convos::Core::User object representing the bot.

METHODS

action

$action = $bot->action($moniker);
$action = $bot->action($class_name);

Returns an action object by $moniker or $class_name. Example:

$karma_action = $bot->action("karma");
$karma_action = $bot->action("Karma");
$karma_action = $bot->action("Convos::Plugin::Bot::Action::Karma");

load_config_file

$hash_ref = $self->load_config_file($path);

Used to load YAML config file and return it as a data structure.

register

$bot->register($app, \%config);

Will set up "user" and start watching "config" for changes.

SEE ALSO

Convos, Convos::Plugin.