mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
If PhabricatorIRCBot encounters a 'nick used' error, try adding a number
Summary: Someone stole my bot's name, so the bot couldn't (re)connect. This tries adding some text to the name if it encounters a 433 'nick in use' error Test Plan: Started a ton of bots: F154744 Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9123
This commit is contained in:
parent
6a45b7e670
commit
358b59ffa7
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,8 @@ final class PhabricatorIRCProtocolAdapter
|
|||
private $writeBuffer;
|
||||
private $readBuffer;
|
||||
|
||||
private $nickIncrement = 0;
|
||||
|
||||
public function getServiceType() {
|
||||
return 'IRC';
|
||||
}
|
||||
|
@ -183,6 +185,12 @@ final class PhabricatorIRCProtocolAdapter
|
|||
private function handleIRCProtocol(array $matches) {
|
||||
$data = $matches['data'];
|
||||
switch ($matches['command']) {
|
||||
case '433': // Nickname already in use
|
||||
// If we receive this error, try appending "-1", "-2", etc. to the nick
|
||||
$this->nickIncrement++;
|
||||
$nick = $this->getConfig('nick', 'phabot').'-'.$this->nickIncrement;
|
||||
$this->write("NICK {$nick}");
|
||||
return true;
|
||||
case '422': // Error - no MOTD
|
||||
case '376': // End of MOTD
|
||||
$nickpass = $this->getConfig('nickpass');
|
||||
|
|
Loading…
Reference in a new issue