Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120743608
PhabricatorIRCProtocolHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 6, 17:43
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jul 8, 17:43 (2 d)
Engine
blob
Format
Raw Data
Handle
27241197
Attached To
rPH Phabricator
PhabricatorIRCProtocolHandler.php
View Options
<?php
/**
* Implements the base IRC protocol so servers don't kick you off.
*
* @group irc
*/
final
class
PhabricatorIRCProtocolHandler
extends
PhabricatorBotHandler
{
public
function
receiveMessage
(
PhabricatorBotMessage
$message
)
{
switch
(
$message
->
getCommand
())
{
case
'422'
:
// Error - no MOTD
case
'376'
:
// End of MOTD
$nickpass
=
$this
->
getConfig
(
'nickpass'
);
if
(
$nickpass
)
{
$this
->
writeMessage
(
id
(
new
PhabricatorBotMessage
())
->
setCommand
(
'MESSAGE'
)
->
setTarget
(
'nickserv'
)
->
setBody
(
"IDENTIFY {$nickpass}"
));
}
$join
=
$this
->
getConfig
(
'join'
);
if
(!
$join
)
{
throw
new
Exception
(
"Not configured to join any channels!"
);
}
foreach
(
$join
as
$channel
)
{
$this
->
writeMessage
(
id
(
new
PhabricatorBotMessage
())
->
setCommand
(
'JOIN'
)
->
setBody
(
$channel
));
}
break
;
case
'PING'
:
$this
->
writeMessage
(
id
(
new
PhabricatorBotMessage
())
->
setCommand
(
'PONG'
)
->
setBody
(
$message
->
getBody
()));
break
;
}
}
}
Event Timeline
Log In to Comment