Convos::Plugin::Bot - A bot system for Convos
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
- class: Convos::Plugin::Bot::Action::Github
repositories:
'convos-chat/convos':
- events: [ create, fork, issues, milestone, pull_request, star ]
to: 'irc-localhost/#convos'
# 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 libera
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 libera
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");
call_actions
@res = $bot->call_actions($method => @args);
Will call a given method on all "actions" that implements the method.
register
$bot->register($app, \%config);
Will set up "user" and start watching "config" for changes.