예제 #1
0
파일: apiv1.php 프로젝트: ricberw/BotQueue
 public function api_grabjob()
 {
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     $bot = new Bot($this->args('bot_id'));
     if (!$bot->isHydrated()) {
         throw new Exception("Bot does not exist.");
     }
     if (!$bot->isMine()) {
         throw new Exception("This is not your bot.");
     }
     if (!$bot->canGrab($job)) {
         throw new Exception("You cannot grab this job.");
     }
     $bot->grabJob($job);
     $data = array();
     $data['job'] = $job->getAPIData();
     $data['bot'] = $bot->getAPIData();
     Activity::log($bot->getLink() . " bot grabbed the " . $job->getLink() . " job via the API.");
     return $data;
 }
예제 #2
0
파일: apiv1.php 프로젝트: eric116/BotQueue
 public function api_grabjob()
 {
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     $bot = new Bot($this->args('bot_id'));
     if (!$bot->isHydrated()) {
         throw new Exception("Bot does not exist.");
     }
     if (!$bot->isMine()) {
         throw new Exception("This is not your bot.");
     }
     if (!$bot->canGrab($job)) {
         throw new Exception("You cannot grab this job.");
     }
     //attempt to grab our job.  will throw exceptions on failure.
     $job = $bot->grabJob($job, (bool) $this->args('can_slice'));
     //okay, do we slice it?
     if ($job->get('status') == 'slicing' && $this->args('can_slice')) {
         $job->getSliceJob()->grab($this->args('_uid'));
     }
     //return the bot data w/ all our info.
     $bot = new Bot($bot->id);
     $data = $bot->getAPIData();
     Activity::log($bot->getLink() . " bot grabbed the " . $job->getLink() . " job via the API.");
     return $data;
 }