Пример #1
0
 /**
  * @param Dialog $dialog
  * @return Dialog
  */
 public function add(Dialog $dialog)
 {
     $dialog->setTelegram($this->telegram);
     // save new dialog
     $chatId = $dialog->getChat()->getId();
     $this->setField($chatId, 'next', $dialog->getNext());
     $this->setField($chatId, 'dialog', get_class($dialog));
     // @todo It's not safe. Need to define Dialogs registry with check of bindings
     return $dialog;
 }
 /**
  * @todo Replace basic Exception by the specific
  * @param Update $update
  * @throws DialogException
  */
 public function __construct(Update $update)
 {
     $username = $update->getMessage()->getFrom()->getUsername();
     if (!$username || !in_array($username, $this->allowedUsers)) {
         throw new DialogException('You have no access to start this dialog');
     }
     parent::__construct($update);
 }