Esempio n. 1
0
 /**
  * @param \TelegramBot\Api\Types\Update $update
  * @param string $eventName
  *
  * @throws \TelegramBot\Api\Exception
  */
 public function trackUpdate(Update $update, $eventName = 'Message')
 {
     if (!in_array($update->getUpdateId(), $this->trackedEvents)) {
         $this->trackedEvents[] = $update->getUpdateId();
         $this->track($update->getMessage(), $eventName);
         if (count($this->trackedEvents) > self::MAX_TRACKED_EVENTS) {
             $this->trackedEvents = array_slice($this->trackedEvents, round(self::MAX_TRACKED_EVENTS / 4));
         }
     }
 }
Esempio n. 2
0
 public function parseMessage($raw_post_data)
 {
     return Update::fromResponse(self::jsonValidate($raw_post_data, true))->getMessage();
 }
Esempio n. 3
0
 /**
  * Webhook handler
  *
  * @return array
  * @throws \TelegramBot\Api\InvalidJsonException
  */
 public function run()
 {
     if ($data = BotApi::jsonValidate($this->getRawBody(), true)) {
         $this->handle([Update::fromResponse($data)]);
     }
 }
Esempio n. 4
0
 /**
  * Webhook handler
  *
  * @return array
  * @throws \TelegramBot\Api\InvalidJsonException
  */
 public function run()
 {
     if ($data = BotApi::jsonValidate(file_get_contents('php://input'), true)) {
         $this->handle([Update::fromResponse($data)]);
     }
 }