Esempio n. 1
0
 public function getFullPath()
 {
     if (!$this->file_path) {
         return null;
     }
     $basePath = Handler::getInstance()->getConfig()->getFileBasePath();
     if (!$basePath) {
         return null;
     }
     return $basePath . $this->file_path;
 }
Esempio n. 2
0
 /**
  * Initialises the client and loads Configuration.
  *
  * @param array $args Array of initialisation arguments
  */
 protected function init($args)
 {
     $botConfig = $this->getBotConfig($args);
     if (!$botConfig) {
         Output::log(new Fatal("Config should be specified!"));
     }
     $config = new Config($botConfig);
     $this->timeout = $config->getTimeout();
     $this->executor = Handler::getInstance();
     $this->executor->initWithConfig($config);
 }
Esempio n. 3
0
 public static function log($e)
 {
     $logFile = null;
     if (Handler::getInstance()->getConfig() instanceof Config) {
         $logFile = Handler::getInstance()->getConfig()->getLogFile();
     }
     $type = "\\Exception";
     $pattern = "%s";
     if ($e instanceof AbstractException) {
         $type = $e->getType();
         $pattern = $e->getColorMessagePattern();
     }
     if ($logFile !== null && is_writable($logFile)) {
         $fh = fopen($logFile, "a");
         $logString = sprintf("[%s] [%s] %s\n", date("H:i:s d.m.Y"), $type, $e->getMessage());
         fwrite($fh, $logString);
         fclose($fh);
     } else {
         echo sprintf($pattern, $e->getMessage()) . "\n";
     }
     if ($e instanceof Fatal) {
         exit;
     }
 }
Esempio n. 4
0
 /**
  * Triggers execution of the method
  *
  * @param bool $silentMode Execute method silently without processing the result
  *
  * @return \Teebot\Response
  */
 public function trigger($silentMode = true)
 {
     $executor = Handler::getInstance();
     return $executor->callRemoteMethod($this, $silentMode, $this->parent);
 }
Esempio n. 5
0
 public function setUp()
 {
     $config = $this->getConfigMock();
     $this->handler = Handler::getInstance();
     $this->handler->initWithConfig($config);
 }