diff options
Diffstat (limited to 'scripts/twitterstatusfetcher.php')
-rwxr-xr-x | scripts/twitterstatusfetcher.php | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 8b10bfbad..e1745cfc0 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -25,19 +25,18 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('MAXCHILDREN', 2); define('POLL_INTERVAL', 60); // in seconds -$shortoptions = 'i::'; -$longoptions = array('id::'); +$shortoptions = 'di::'; +$longoptions = array('id::', 'debug'); $helptext = <<<END_OF_TRIM_HELP Batch script for retrieving Twitter messages from foreign service. - -i --id Identity (default 'generic') - -END_OF_TRIM_HELP; + -i --id Identity (default 'generic') + -d --debug Debug (lots of log output) -require_once INSTALLDIR.'/scripts/commandline.inc'; +END_OF_TRIM_HELP; -require_once INSTALLDIR . '/lib/common.php'; +require_once INSTALLDIR .'/scripts/commandline.inc'; require_once INSTALLDIR . '/lib/daemon.php'; /** @@ -61,6 +60,15 @@ class TwitterStatusFetcher extends Daemon { private $_children = array(); + function __construct($id=null, $daemonize=true) + { + parent::__construct($daemonize); + + if ($id) { + $this->set_id($id); + } + } + /** * Name of this daemon * @@ -80,6 +88,11 @@ class TwitterStatusFetcher extends Daemon function run() { + if (defined('SCRIPT_DEBUG')) { + common_debug($this->name() . + ': debugging log output enabled.'); + } + do { $flinks = $this->refreshFlinks(); @@ -317,7 +330,7 @@ class TwitterStatusFetcher extends Daemon $notice->rendered = common_render_content($notice->content, $notice); $notice->source = 'twitter'; $notice->reply_to = null; // XXX lookup reply - $notice->is_local = NOTICE_GATEWAY; + $notice->is_local = Notice::GATEWAY; if (Event::handle('StartNoticeSave', array(&$notice))) { $id = $notice->insert(); @@ -640,6 +653,10 @@ if (have_option('i')) { $id = null; } +if (have_option('d') || have_option('debug')) { + define('SCRIPT_DEBUG', true); +} + $fetcher = new TwitterStatusFetcher($id); $fetcher->runOnce(); |