@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Lock down bot adapter API slightly

Summary:
- Reduce visibiliy of config.
- Add a typehint.

Test Plan: Ran campfire/irc bots and chatted with them.

Reviewers: indiefan

Reviewed By: indiefan

CC: aran, amerigomasini

Differential Revision: https://secure.phabricator.com/D4923

+19 -14
+6 -1
src/infrastructure/daemon/bot/adapter/PhabricatorBaseProtocolAdapter.php
··· 4 4 * Defines the api for protocol adapters for @{class:PhabricatorBot} 5 5 */ 6 6 abstract class PhabricatorBaseProtocolAdapter { 7 - protected $config; 7 + 8 + private $config; 8 9 9 10 public function setConfig($config) { 10 11 $this->config = $config; 11 12 return $this; 13 + } 14 + 15 + public function getConfig($key, $default = null) { 16 + return idx($this->config, $key, $default); 12 17 } 13 18 14 19 /**
+5 -5
src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorCampfireProtocolAdapter 4 - extends PhabricatorBaseProtocolAdapter { 4 + extends PhabricatorBaseProtocolAdapter { 5 5 6 6 private $readBuffers; 7 7 private $authtoken; ··· 12 12 private $inRooms = array(); 13 13 14 14 public function connect() { 15 - $this->server = idx($this->config, 'server'); 16 - $this->authtoken = idx($this->config, 'authtoken'); 17 - $ssl = idx($this->config, 'ssl', false); 18 - $rooms = idx($this->config, 'join'); 15 + $this->server = $this->getConfig('server'); 16 + $this->authtoken = $this->getConfig('authtoken'); 17 + $ssl = $this->getConfig('ssl', false); 18 + $rooms = $this->getConfig('join'); 19 19 20 20 // First, join the room 21 21 if (!$rooms) {
+7 -7
src/infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorIRCProtocolAdapter 4 - extends PhabricatorBaseProtocolAdapter { 4 + extends PhabricatorBaseProtocolAdapter { 5 5 6 6 private $socket; 7 7 ··· 13 13 'PRIVMSG' => 'MESSAGE'); 14 14 15 15 public function connect() { 16 - $nick = idx($this->config, 'nick', 'phabot'); 17 - $server = idx($this->config, 'server'); 18 - $port = idx($this->config, 'port', 6667); 19 - $pass = idx($this->config, 'pass'); 20 - $ssl = idx($this->config, 'ssl', false); 21 - $user = idx($this->config, 'user', $nick); 16 + $nick = $this->getConfig('nick', 'phabot'); 17 + $server = $this->getConfig('server'); 18 + $port = $this->getConfig('port', 6667); 19 + $pass = $this->getConfig('pass'); 20 + $ssl = $this->getConfig('ssl', false); 21 + $user = $this->getConfig('user', $nick); 22 22 23 23 if (!preg_match('/^[A-Za-z0-9_`[{}^|\]\\-]+$/', $nick)) { 24 24 throw new Exception(
+1 -1
src/infrastructure/daemon/bot/handler/PhabricatorBotHandler.php
··· 39 39 return; 40 40 } 41 41 42 - public function replyTo($original_message, $body) { 42 + public function replyTo(PhabricatorBotMessage $original_message, $body) { 43 43 if ($original_message->getCommand() != 'MESSAGE') { 44 44 throw new Exception( 45 45 "Handler is trying to reply to something which is not a message!");