public function idfeed_add($options)
 {
     $this->cli->header('adding new idfeed');
     if (count($options) < 2) {
         $this->cli->error('atleast two parameters (url, handle) should be given');
         return;
     }
     if (!is_null(Kingboard_IdFeed::findByUrl($options[0]))) {
         $this->cli->error('a feed by this url allready exists!');
         return;
     }
     $feed = new Kingboard_IdFeed();
     $feed->url = $options[0];
     $feed->handle = $options[1];
     if (count($options) == 3) {
         $feed->type = $options[2];
     }
     $feed->save();
     $this->cli->positive('done');
 }
 public function idfeed_import(array $options)
 {
     if (count($options) < 1) {
         $this->cli->error('1 parameter required: handle');
         return;
     }
     $this->cli->message('starting import of handle: ' . $options[0]);
     $idfeed = Kingboard_IdFeed::findByHandle($options[0]);
     if (is_null($idfeed)) {
         $this->cli->error('no such handle');
         return;
     }
     $lastid = $idfeed->lastId;
     if (is_null($lastid)) {
         $lastid = 0;
     }
     if (!is_null($idfeed->type)) {
         $kidf = new Kingboard_IdFeed_Fetcher($idfeed->url, $idfeed->type);
     } else {
         $kidf = new Kingboard_IdFeed_Fetcher($idfeed->url);
     }
     try {
         $kills = $kidf->fetch($lastid)->kills;
         $kakp = new Kingboard_ApiKillParser();
         $info = $kakp->parseKills($kills);
         $total = $info['oldkills'] + $info['newkills'];
         $this->cli->message("fetched {$total} kills, " . $info['oldkills'] . " allready known, " . $info['newkills'] . " new");
         $this->cli->message("Last id was: " . $info['lastID'] . " internal: " . $info['lastIntID']);
         if (!is_null($idfeed->type) && $idfeed->type == "intid") {
             $idfeed->lastId = $info['lastIntID'];
         } else {
             $idfeed->lastId = $info['lastID'];
         }
         $idfeed->save();
     } catch (Exception $e) {
         $this->cli->error("idfetch exception occured: " . $e->getMessage());
     }
 }