getId() public method

Gets the user's ID.
public getId ( ) : string
return string The user's ID.
示例#1
0
 public function testGetCreator()
 {
     $creator = new User($this->client, ['id' => $this->faker->uuid]);
     $channel = new Channel($this->client, ['creator' => $creator->getId()]);
     $this->mockResponse(200, null, ['ok' => true, 'user' => ['id' => $creator->data['id']]]);
     $this->watchPromise($channel->getCreator()->then(function (User $user) use($creator) {
         $this->assertEquals($creator->data, $user->data);
     }));
 }
示例#2
0
 /**
  * Prepare onMessage handler
  */
 protected function prepareOnMessage()
 {
     $this->client->on('message', function (Payload $data) {
         /**
          * Skip self messages
          */
         if ($data['user'] === $this->botUser->getId()) {
             return;
         }
         $this->logger->info(sprintf("Message received: %s", json_encode($data->getData())));
         $message = new Message($this->client, $data->getData());
         $invokeResult = $this->invoker->execute($message);
         $this->sendMessageByDestId($invokeResult, $data['channel']);
         $this->logger->info(sprintf("Response sent: %s", $invokeResult));
     });
 }
示例#3
0
 /**
  * Welcomes a user to the team.
  *
  * @param array $data Event data.
  */
 protected function welcomeUser(User $user)
 {
     // Open a DM with the user and talk about the Slack team a bit.
     $this->client->getDMbyUserId($user->getId())->then(function (DirectMessageChannel $channel) {
         return $this->client->getDMById($channel->getId());
     })->then(function (DirectMessageChannel $channel) use($user) {
         return $this->client->send(sprintf("Hi there, %s! Thanks for signing up! I'm sure my friend <@USLACKBOT> is helping you set up your account right now.", $user->getUsername()), $channel)->then(function () use($user, $channel) {
             sleep(3);
             return $this->client->send("I just want to informally introduce you to the team." . " First, you will see a list of channels on the left. There's the <#C025YTX9D>" . " channel, which is a great place to discuss normal goings-on. If you want to just" . " hang out and talk about random things, the <#C025YTX9F> channel is perfect for that.", $channel);
         })->then(function () use($user, $channel) {
             sleep(6);
             return $this->client->send("If you're looking to start a group project, private groups are" . " perfect for that. You can create a new group by clicking on the \"+\" next to \"PRIVATE" . " GROUPS\" on the left.", $channel);
         })->then(function () use($user, $channel) {
             sleep(5);
             return $this->client->send("If you have any questions, feel free to ask one of the humans in <#C025YTX9D>.", $channel);
         });
     });
 }
示例#4
0
 /**
  * Sets the user the message is sent from.
  *
  * @param User $user A user.
  * @return $this
  */
 public function setUser(User $user)
 {
     $this->data['user'] = $user->getId();
     return $this;
 }
示例#5
0
 /**
  * Gets a direct message channel for a given user.
  *
  * @param User $user The user to get a DM for.
  *
  * @return \React\Promise\PromiseInterface A promise for a DM object.
  */
 public function getDMByUser(User $user)
 {
     return $this->getDMByUserId($user->getId());
 }
示例#6
0
 /**
  * If the lobby is open, adds a user to it.
  *
  * @param User $user
  *   The user to add to the lobby.
  *
  * @return bool
  *   If successful, returns TRUE, otherwise, FALSE.
  */
 public function addLobbyPlayer(User $user)
 {
     if ($this->state == GameState::LOBBY) {
         $player_id = $user->getId();
         if (!isset($this->lobbyPlayers[$player_id])) {
             $this->lobbyPlayers[$player_id] = $user;
             return TRUE;
         }
     }
 }
示例#7
0
 /**
  * Kicks a user from the channel.
  *
  * @param User The user to kick.
  *
  * @return \React\Promise\PromiseInterface
  */
 public function kickUser(User $user)
 {
     return $this->client->apiCall('channels.kick', ['channel' => $this->getId(), 'user' => $user->getId()])->then(function () use($user) {
         unset($this->data['members'][$user->getId()]);
     });
 }