1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Make phabot never private message anyone.

Summary:
This replaces D4175 and makes it so phabot doesn't message anyone.

The reasons for this are twofold:

- It was possible to get information from the bot, by private messaging it, even
  if the bot was only in a +i channel (on a public network) -- meaning that if
  someone knew the nickname of the bot, they could obtain e.g. ticket names
  or diff titles.
- The other time it messaged people was when you typed e.g. "somenick: T123".
  Most times when this is triggered, it's done so on accident.

See discussion on the old revision (D4175).

Test Plan:
  15:29:33 ::: Irssi: Starting query in quartz with cb-phabot
  15:29:38 <relrod> T2
  (nothing back)

and

  15:29:21 <@relrod> rublets: T1
  15:29:21 < cb-phabot> T1: asdfasdf (Priority: Needs Triage) - http://local.elrod.me/T1

Reviewers: epriestley, btrahan, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4339
This commit is contained in:
Ricky Elrod 2013-01-03 12:44:29 -08:00 committed by epriestley
parent 9a936b5bf3
commit f12af03836
2 changed files with 14 additions and 28 deletions

View file

@ -31,11 +31,6 @@ final class PhabricatorIRCMessage {
if ($target[0] == '#') { if ($target[0] == '#') {
return $target; return $target;
} }
$matches = null;
if (preg_match('/^:([^!]+)!/', $this->sender, $matches)) {
return $matches[1];
}
break; break;
} }
return null; return null;

View file

@ -33,7 +33,6 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
'(D|T|P|V|F)(\d+)'. '(D|T|P|V|F)(\d+)'.
'(?:\b|$)'. '(?:\b|$)'.
'@'; '@';
$pattern_override = '/(^[^\s]+)[,:] [DTPVF]\d+/';
$revision_ids = array(); $revision_ids = array();
$task_ids = array(); $task_ids = array();
@ -41,12 +40,8 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
$commit_names = array(); $commit_names = array();
$vote_ids = array(); $vote_ids = array();
$file_ids = array(); $file_ids = array();
$matches_override = array();
if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) { if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) {
if (preg_match($pattern_override, $message, $matches_override)) {
$reply_to = $matches_override[1];
}
foreach ($matches as $match) { foreach ($matches as $match) {
switch ($match[1]) { switch ($match[1]) {
case 'D': case 'D':
@ -180,10 +175,8 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
// Don't mention the same object more than once every 10 minutes // Don't mention the same object more than once every 10 minutes
// in public channels, so we avoid spamming the chat over and over // in public channels, so we avoid spamming the chat over and over
// again for discsussions of a specific revision, for example. In // again for discsussions of a specific revision, for example.
// direct-to-bot chat, respond to every object reference.
if ($this->isChannelName($reply_to)) {
if (empty($this->recentlyMentioned[$reply_to])) { if (empty($this->recentlyMentioned[$reply_to])) {
$this->recentlyMentioned[$reply_to] = array(); $this->recentlyMentioned[$reply_to] = array();
} }
@ -199,8 +192,6 @@ final class PhabricatorIRCObjectNameHandler extends PhabricatorIRCHandler {
} }
$this->recentlyMentioned[$reply_to][$phid] = time(); $this->recentlyMentioned[$reply_to][$phid] = time();
}
$this->write('PRIVMSG', "{$reply_to} :{$description}"); $this->write('PRIVMSG', "{$reply_to} :{$description}");
} }
break; break;