/** * Returns Response object built from received data. Method should be used if * bot is running in webhook mode. * * @param string $receivedData Received data from Telegram's webhook call. Not required, but could * be passed manually. If not passed - php input will be used to get the data. * @param bool $silentMode If set to true then the events, mapped to * the entities in the result will not be triggered * @return Response */ public function webhook($receivedData = '', $silentMode = false) { if (empty($receivedData)) { $receivedData = file_get_contents("php://input"); } if (empty($receivedData)) { return null; } return $this->executor->getWebhookResponse($receivedData, $silentMode); }
public function getFullPath() { if (!$this->file_path) { return null; } $basePath = Handler::getInstance()->getConfig()->getFileBasePath(); if (!$basePath) { return null; } return $basePath . $this->file_path; }
/** * Tests getEntitiesChain() method which builds an event flow from received nested entities * * @dataProvider dataProviderGetEntitiesChain * * @param AbstractEntity $entity Entity * @param array $instancesFlow Instances flow */ public function testGetEntitiesChain($entity, $instancesFlow) { $flow = $this->handler->getEntitiesChain($entity); for ($i = 0; $i < count($flow); $i++) { $flowStep = $flow[$i]; $instancesStep = $instancesFlow[$i]; $this->assertCount(count($instancesStep), $flowStep); foreach ($instancesStep as $key => $class) { $this->assertArrayHasKey($key, $flowStep); $this->assertInstanceOf($class, $flowStep[$key]); } } }
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; } }
/** * 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); }