mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Merge pull request #60 from moos3/master
Slowvote support for Irc Bot
This commit is contained in:
commit
716eab82bb
1 changed files with 17 additions and 1 deletions
|
@ -45,7 +45,7 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
|
|||
$pattern =
|
||||
'@'.
|
||||
'(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123".
|
||||
'(D|T|P)(\d+)'.
|
||||
'(D|T|P|V)(\d+)'.
|
||||
'(?:\b|$)'.
|
||||
'@';
|
||||
|
||||
|
@ -53,6 +53,7 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
|
|||
$task_ids = array();
|
||||
$paste_ids = array();
|
||||
$commit_names = array();
|
||||
$vote_ids = array();
|
||||
|
||||
if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
|
@ -66,6 +67,9 @@ class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
|
|||
case 'P':
|
||||
$paste_ids[] = $match[2];
|
||||
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) {
|
||||
foreach ($paste_ids as $paste_id) {
|
||||
$paste = $this->getConduit()->callMethodSynchronous(
|
||||
|
|
Loading…
Reference in a new issue