Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F949936
PhabricatorBotWhatsNewHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorBotWhatsNewHandler.php
View Options
<?php
/**
* Responds to "Whats new?" with some recent feed content.
*/
final
class
PhabricatorBotWhatsNewHandler
extends
PhabricatorBotHandler
{
private
$floodblock
=
0
;
public
function
receiveMessage
(
PhabricatorBotMessage
$message
)
{
switch
(
$message
->
getCommand
())
{
case
'MESSAGE'
:
$message_body
=
$message
->
getBody
();
$now
=
time
();
$prompt
=
'~what( i|
\'
)?s new
\?
~i'
;
if
(
preg_match
(
$prompt
,
$message_body
))
{
if
(
$now
<
$this
->
floodblock
)
{
return
;
}
$this
->
floodblock
=
$now
+
60
;
$this
->
reportNew
(
$message
);
}
break
;
}
}
public
function
reportNew
(
PhabricatorBotMessage
$message
)
{
$latest
=
$this
->
getConduit
()->
callMethodSynchronous
(
'feed.query'
,
array
(
'limit'
=>
5
,
'view'
=>
'text'
,
));
foreach
(
$latest
as
$feed_item
)
{
if
(
isset
(
$feed_item
[
'text'
]))
{
$this
->
replyTo
(
$message
,
html_entity_decode
(
$feed_item
[
'text'
]));
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 1:51 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
223987
Default Alt Text
PhabricatorBotWhatsNewHandler.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment