Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98258008
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
Sat, Jan 11, 12:58
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 13, 12:58 (2 d)
Engine
blob
Format
Raw Data
Handle
23538736
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