diff --git a/resources/chatbot/example_config.json b/resources/chatbot/example_config.json --- a/resources/chatbot/example_config.json +++ b/resources/chatbot/example_config.json @@ -21,5 +21,6 @@ "macro.size" : 48, "macro.aspect" : 0.66, - "notification.channels" : ["#phabot-test"] + "notification.channels" : ["#phabot-test"], + "notification.verbosity" : 0 } diff --git a/src/docs/tech/chatbot.diviner b/src/docs/tech/chatbot.diviner --- a/src/docs/tech/chatbot.diviner +++ b/src/docs/tech/chatbot.diviner @@ -34,7 +34,8 @@ bot. - ##conduit.uri##, ##conduit.user##, ##conduit.cert## Conduit configuration, see below. - - ##notification.channels## Notification configuration, see below. + - ##notification.channels##, ##notification.verbosity## Notification + configuration, see below. = Handlers = @@ -46,7 +47,9 @@ up, and says their name with a link to the object. Requires conduit. - @{class:PhabricatorBotFeedNotificationHandler} This handler posts notifications about changes to revisions to the channels listed in - ##notification.channels##. + ##notification.channels##. The verbosity of output is controlled by + ##notification.verbosity##. 3 is off, 0 is minimal. 1 and 2 increase output + respectively. - @{class:PhabricatorBotLogHandler} This handler records chatlogs which can be browsed in the Phabricator web interface. - @{class:PhabricatorBotSymbolHandler} This handler posts responses to lookups diff --git a/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php b/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php --- a/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php +++ b/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php @@ -118,14 +118,14 @@ $last_seen_chrono_key = $this->lastSeenChronoKey; $chrono_key_cursor = 0; - + $message_counter = 0; // Not efficient but works due to feed.query API for ($max_pages = $config_max_pages; $max_pages > 0; $max_pages--) { $stories = $this->getConduit()->callMethodSynchronous( 'feed.query', array( 'limit' => $config_page_size, - 'after' => $chrono_key_cursor, + 'before' => $chrono_key_cursor, 'view' => 'text', )); @@ -161,7 +161,7 @@ $message .= ' '.$objects[$story['objectPHID']]['uri']; } - $channels = $this->getConfig('join'); + $channels = $this->getConfig('notification.channels'); foreach ($channels as $channel_name) { $channel = id(new PhabricatorBotChannel()) @@ -172,6 +172,7 @@ ->setCommand('MESSAGE') ->setTarget($channel) ->setBody($message)); + usleep($message_counter++ * 50000); } } }