2013-02-14 12:47:39 -08:00
|
|
|
@title Chat Bot Technical Documentation
|
|
|
|
@group bot
|
2011-12-20 09:32:05 -08:00
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
Configuring and extending the chat bot.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
= Overview =
|
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
Phabricator includes a simple chat bot daemon, which is primarily intended as
|
2011-12-20 09:32:05 -08:00
|
|
|
an example of how you can write an external script that interfaces with
|
2013-02-14 12:47:39 -08:00
|
|
|
Phabricator over Conduit and does some kind of useful work. If you use IRC or
|
|
|
|
another supported chat protocol, you can also have the bot hang out in your
|
|
|
|
channel.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
NOTE: The chat bot is somewhat experimental and not very mature.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
= Configuring the Bot =
|
|
|
|
|
|
|
|
The bot reads a JSON configuration file. You can find an example in:
|
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
resources/chatbot/example_config.json
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
These are the configuration values it reads:
|
|
|
|
|
|
|
|
- ##server## String, required, the server to connect to.
|
|
|
|
- ##port## Int, optional, the port to connect to (defaults to 6667).
|
|
|
|
- ##ssl## Bool, optional, whether to connect via SSL or not (defaults to
|
|
|
|
false).
|
|
|
|
- ##nick## String, nickname to use.
|
|
|
|
- ##user## String, optional, username to use (defaults to ##nick##).
|
|
|
|
- ##pass## String, optional, password for server.
|
|
|
|
- ##nickpass## String, optional, password for NickServ.
|
|
|
|
- ##join## Array, list of channels to join.
|
|
|
|
- ##handlers## Array, list of handlers to run. These are like plugins for the
|
2013-02-14 12:47:39 -08:00
|
|
|
bot.
|
2011-12-20 09:32:05 -08:00
|
|
|
- ##conduit.uri##, ##conduit.user##, ##conduit.cert## Conduit configuration,
|
|
|
|
see below.
|
2012-01-06 11:31:00 -08:00
|
|
|
- ##notification.channels## Notification configuration, see below.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
= Handlers =
|
|
|
|
|
|
|
|
You specify a list of "handlers", which are basically plugins or modules for
|
2013-02-14 12:47:39 -08:00
|
|
|
the bot. These are the default handlers available:
|
2011-12-20 09:32:05 -08:00
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
- @{class:PhabricatorBotObjectNameHandler} This handler looks for users
|
2011-12-20 09:32:05 -08:00
|
|
|
mentioning Phabricator objects like "T123" and "D345" in chat, looks them
|
|
|
|
up, and says their name with a link to the object. Requires conduit.
|
2014-06-11 10:41:12 -07:00
|
|
|
- @{class:PhabricatorBotFeedNotificationHandler} This handler posts
|
2013-02-14 12:47:39 -08:00
|
|
|
notifications about changes to revisions to the channels listed in
|
2012-01-06 11:31:00 -08:00
|
|
|
##notification.channels##.
|
2013-02-14 12:47:39 -08:00
|
|
|
- @{class:PhabricatorBotLogHandler} This handler records chatlogs which can
|
2012-02-17 10:21:38 -08:00
|
|
|
be browsed in the Phabricator web interface.
|
2014-06-11 10:41:12 -07:00
|
|
|
- @{class:PhabricatorBotSymbolHandler} This handler posts responses to lookups
|
|
|
|
for symbols in Diffusion
|
|
|
|
- @{class:PhabricatorBotMacroHandler} This handler looks for users mentioning
|
|
|
|
macros, if found will convert image to ASCII and output in chat. Configure
|
|
|
|
with ##macro.size## and ##macro.aspect##
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
You can also write your own handlers, by extending
|
2013-02-14 12:47:39 -08:00
|
|
|
@{class:PhabricatorBotHandler}.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
= Conduit =
|
|
|
|
|
2013-02-14 12:47:39 -08:00
|
|
|
Some handlers (e.g., @{class:PhabricatorBotObjectNameHandler}) need to read data
|
2012-01-06 11:31:00 -08:00
|
|
|
from Phabricator over Conduit, Phabricator's HTTP API. You can use this method
|
|
|
|
to allow other scripts or programs to access Phabricator's data from different
|
|
|
|
servers and in different languages.
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
To allow the bot to access Conduit, you need to create a user that it can login
|
|
|
|
with. To do this, login to Phabricator as an administrator and go to
|
2014-08-06 14:18:32 -07:00
|
|
|
`People -> Create New Account`. Create a new account and flag them as a
|
2014-04-02 12:06:56 -07:00
|
|
|
"Bot/Script". Then in your configuration file, set these parameters:
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
- ##conduit.uri## The URI for your Phabricator install, like
|
|
|
|
##http://phabricator.example.com/##
|
|
|
|
- ##conduit.user## The username your bot should login to Phabricator with --
|
|
|
|
whatever you selected above, like ##phabot##.
|
|
|
|
- ##conduit.cert## The user's certificate, from the "Conduit Certificate" tab
|
|
|
|
in the user's administrative view.
|
|
|
|
|
|
|
|
Now the bot should be able to connect to Phabricator via Conduit.
|
|
|
|
|
|
|
|
= Starting the Bot =
|
|
|
|
|
|
|
|
The bot is a Phabricator daemon, so start it with ##phd##:
|
|
|
|
|
2013-03-03 06:51:23 -08:00
|
|
|
./bin/phd launch phabricatorbot <absolute_path_to_config_file>
|
2011-12-20 09:32:05 -08:00
|
|
|
|
|
|
|
If you have issues you can try ##debug## instead of ##launch##, see
|
|
|
|
@{article:Managing Daemons with phd} for more information.
|