1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 15:00:58 +01:00

Add Pxxx to phabot.

Summary:
Summarize (or at least link to) pastes when P<id> is given in a channel. This depends on D552!

Test Plan:
04:34:03 <@codeblock-phabot> P15 - http://phabricator.local/P15
04:35:22 <@CodeBlock> P1 asdf foo Bar Baz Diet Sprite P4
04:35:24 <@codeblock-phabot> P1 - http://phabricator.local/P1
04:35:24 <@codeblock-phabot> P4 - http://phabricator.local/P4

Reviewers:
epriestley

CC:

Differential Revision: 553
This commit is contained in:
Ricky Elrod 2011-06-29 04:33:13 -04:00
parent 63980af010
commit 3346f04d89

View file

@ -45,12 +45,13 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
$pattern =
'@'.
'(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123".
'(D|T)(\d+)'.
'(D|T|P)(\d+)'.
'(?:\b|$)'.
'@';
$revision_ids = array();
$task_ids = array();
$paste_ids = array();
$commit_names = array();
if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) {
@ -62,6 +63,9 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
case 'T':
$task_ids[] = $match[2];
break;
case 'P':
$paste_ids[] = $match[2];
break;
}
}
}
@ -96,6 +100,22 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
// TODO: Support tasks in Conduit.
if ($paste_ids) {
foreach ($paste_ids as $paste_id) {
$paste = $this->getConduit()->callMethodSynchronous(
'paste.info',
array(
'paste_id' => $paste_id,
));
// Eventually I'd like to show the username of the paster as well,
// however that will need something like a user.username_from_phid
// since we (ideally) want to keep the bot to Conduit calls...and
// not call to Phabricator-specific stuff (like actually loading
// the User object and fetching his/her username.)
$output[$paste['phid']] = 'P'.$paste['id'].': '.$paste['uri'];
}
}
if ($commit_names) {
$commits = $this->getConduit()->callMethodSynchronous(
'diffusion.getcommits',