-
Notifications
You must be signed in to change notification settings - Fork 16
Creating a plugin
Ehsan Abbasi edited this page May 3, 2017
·
4 revisions
Every functionality needs to be handled by a command e.g. /help
which belongs to a plugin e.g. Help
plugin. In other words, a plugin can have one or more commands.
Add the new command to src/Botonomous/CommandContainer.php
and also add the plugin file to src/Botonomous/plugin
. For every command plugin name, action (which is a function with the same name in the plugin) and description need to be specified. e.g.
protected static $commands = [
'ping' => [
'plugin' => 'Ping',
'action' => 'index',
'description' => 'Use as a health check',
]
];
Please note if action
is not specified, index
is considered as the default action. Finally, for each action add a function with the same name to the plugin file:
/**
* Class Ping.
*/
class Ping extends AbstractPlugin
{
/**
* @return string
*/
public function index()
{
return 'pong';
}
}