1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00

Merge pull request #60 from moos3/master

Slowvote support for Irc Bot
This commit is contained in:
Evan Priestley 2011-08-23 19:07:25 -07:00
commit 716eab82bb

View file

@ -45,7 +45,7 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
$pattern = $pattern =
'@'. '@'.
'(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123". '(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123".
'(D|T|P)(\d+)'. '(D|T|P|V)(\d+)'.
'(?:\b|$)'. '(?:\b|$)'.
'@'; '@';
@ -53,6 +53,7 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
$task_ids = array(); $task_ids = array();
$paste_ids = array(); $paste_ids = array();
$commit_names = array(); $commit_names = array();
$vote_ids = array();
if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) { if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) { foreach ($matches as $match) {
@ -66,6 +67,9 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
case 'P': case 'P':
$paste_ids[] = $match[2]; $paste_ids[] = $match[2];
break; break;
case 'V':
$vote_ids[] = $match[2];
break;
} }
} }
} }
@ -110,6 +114,18 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
} }
} }
if ($vote_ids) {
foreach ($vote_ids as $vote_id) {
$vote = $this->getConduit()->callMethodSynchronous(
'slowvote.info',
array(
'poll_id' => $vote_id,
));
$output[$vote['phid']] = 'V'.$vote['id'].': '.$vote['question'].
' Come Vote '.$vote['uri'];
}
}
if ($paste_ids) { if ($paste_ids) {
foreach ($paste_ids as $paste_id) { foreach ($paste_ids as $paste_id) {
$paste = $this->getConduit()->callMethodSynchronous( $paste = $this->getConduit()->callMethodSynchronous(