public static function import($botConfig, $botId = 0) { try { if ($botId && is_int($botId)) { $config = $botConfig[$botId]; require_once SAYWUT_ROOT_PATH . DS . 'bots' . DS . $config['class'] . '.php'; $path = '\\Saywut\\' . $config['class']; $bot = new $path(Core::getBotKey($config), $config); if (method_exists($bot, 'import')) { $bot->import(); } return; } elseif ($botId) { throw new \Exception('Invalid Bot Id'); } foreach ($botConfig as $key => $botInfo) { if ($key == 0) { //Skip placeholder bot; continue; } require_once SAYWUT_ROOT_PATH . DS . 'bots' . DS . $botInfo['class'] . '.php'; $path = '\\Saywut\\' . $config['class']; $bot = new $path(Core::getBotKey($botInfo), $botInfo); if (method_exists($bot, 'import')) { $bot->import(); } } } catch (\Exception $e) { Event::write(0, Event::E_ERROR, $e->getMessage() . ' @ ' . $e->getFile() . ' L: ' . $e->getLine()); } }
public function run() { if ($this->runnable() && !$this->error) { $this->fetch(); if (empty($this->error)) { $this->store(); Event::write($this->provider_id, Event::E_SUCCESS, 'Number of Change - ' . $this->numberChanged); } } }
public function delete() { try { if ($this->id) { $this->resource->delete($this->id); Event::write($this->provider_id, Event::E_SUCCESS, 'Deleted ID:' . $this->id . ' - ' . Core::getBotName($this->provider_id) . ' - ' . $this->provider_cid); return true; } } catch (\Exception $e) { throw new \Exception($e->getMessage() . ' @ ' . $e->getLine() . ' in ' . $e->getFile()); } }
public function import() { try { $this->qurey_settings['count'] = 200; do { $this->data = null; $this->fetch(); $canContinue = empty($this->error) && !empty($this->data); if ($canContinue) { $this->store(); $lastUnit = $this->data[sizeof($this->data) - 1]; $newPage = $lastUnit->id_str; $this->qurey_settings['max_id'] = bcsub($newPage, '1'); } } while ($canContinue); Event::write($this->provider_id, Event::E_SUCCESS, 'Number of Change - ' . $this->numberChanged); echo Core::getBotName($this->provider_id) . ' imported:' . $this->numberChanged . "\n"; } catch (Exception $e) { Event::write(0, Event::E_ERROR, $e->getMessage() . ' @ ' . $e->getFile() . ' L: ' . $e->getLine()); } }