예제 #1
0
 /**
  * Returns chat id if the type of calling entity or it's parent is Message
  *
  * @return null|int
  */
 public function getChatId()
 {
     if ($this->entity instanceof Message) {
         return $this->entity->getChatId();
     }
     $parent = $this->entity->getParent();
     if ($parent instanceof Message) {
         return $parent->getChatId();
     }
     return null;
 }
예제 #2
0
파일: Update.php 프로젝트: rudestan/teebot
 /**
  * @param AbstractEntity $object
  */
 public function setUpdateType($object)
 {
     $this->updateType = static::ENTITY_TYPE;
     if ($object instanceof AbstractEntity) {
         $this->updateType = $object->getEntityType();
     }
 }
예제 #3
0
 public function __construct(array $data)
 {
     if (empty($data)) {
         return;
     }
     $this->setEntities($data);
     parent::__construct($data);
 }
예제 #4
0
 public function __construct(array $data = [])
 {
     parent::__construct($data);
     $this->parseSource();
 }
예제 #5
0
파일: Handler.php 프로젝트: rudestan/teebot
 /**
  * Returns mapped event class from the configuration (if it was previously defined)
  *
  * @param AbstractEntity $entity    Entity for which the corresponding event should be triggered
  *                                  be treated as a command
  * @return null|string
  */
 protected function getEventClass(AbstractEntity $entity)
 {
     $preDefinedEvents = $this->config->getEvents();
     $entityEventType = $entity->getEntityType();
     if (!is_array($preDefinedEvents)) {
         return null;
     }
     foreach ($preDefinedEvents as $preDefinedEvent) {
         if ($preDefinedEvent['type'] == $entityEventType) {
             $className = $preDefinedEvent['class'];
             if ($entity instanceof MessageEntity && $entity->isCommand()) {
                 if (!$this->isCommandSupported($preDefinedEvent, $entity->getCommand())) {
                     continue;
                 }
             }
             if (class_exists($className)) {
                 return $className;
             }
         }
     }
     return null;
 }
예제 #6
0
파일: Message.php 프로젝트: rudestan/teebot
 public function __construct(array $data)
 {
     $data = isset($data['message']) ? $data['message'] : $data;
     parent::__construct($data);
 }