robot = $robot; if ($_ENV['ROBOT_TYPE']) { $this->robot->auth_type = 'user'; $this->user_id = $this->robot->request('users.get', [])['id']; } else { $this->robot->auth_type = 'group'; $this->group_id = $this->robot->request('groups.getById', [])['id']; $this->robot->request('groups.setLongPollSettings', [ 'group_id' => $this->group_id, 'enabled' => 1, 'api_version' => $this->robot->version, 'message_new' => 1, ]); } $this->getLongPollServer(); } public function getLongPollServer() { if ($this->robot->auth_type == 'user') { $data = $this->robot->request('messages.getLongPollServer', ['need_pts' => 1, 'lp_version' => 3]); } else { $data = $this->robot->request('groups.getLongPollServer', ['group_id' => $this->group_id]); } unset($this->key, $this->server, $this->ts); list($this->key, $this->server, $this->ts) = [$data['key'], $data['server'], $data['ts']]; } }