Skip to content

Commit

Permalink
Fix missing SlackRTMDriver::typesAndWaits() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
filippotoso committed May 2, 2022
1 parent ee4320d commit e6e2a3f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.discovery/
.idea/
.DS_Store
composer.lock
.php_cs.cache
/vendor/
/vendor/
update.bat
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
"Slack"
],
"homepage": "http://github.com/botman/driver-slack",
"authors": [
{
"name": "Marcel Pociot",
"email": "[email protected]"
}
],
"authors": [{
"name": "Marcel Pociot",
"email": "[email protected]"
}],
"require": {
"php": ">=7.0",
"botman/botman": "~2.1",
Expand All @@ -24,7 +22,7 @@
"phpunit/phpunit": "~5.0",
"illuminate/console": "~5.0",
"illuminate/support": "~5.0",
"mockery/mockery": "dev-master",
"mockery/mockery": "^1.1",
"ext-curl": "*"
},
"suggest": {
Expand All @@ -51,4 +49,4 @@
]
}
}
}
}
26 changes: 19 additions & 7 deletions src/SlackRTMDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function matchesRequest()
*/
public function hasMatchingEvent()
{
if (! empty($this->slackEventData)) {
if (!empty($this->slackEventData)) {
list($type, $payload) = $this->slackEventData;
$event = new GenericEvent($payload);
$event->setName($type);
Expand Down Expand Up @@ -257,7 +257,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam
if ($message instanceof OutgoingMessage) {
$parameters['text'] = $message->getText();
$attachment = $message->getAttachment();
if (! is_null($attachment)) {
if (!is_null($attachment)) {
if ($attachment instanceof Image) {
$parameters['attachments'] = json_encode([
[
Expand All @@ -266,7 +266,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam
],
]);

// else check if is a path
// else check if is a path
} elseif ($attachment instanceof BotManFile && file_exists($attachment->getUrl())) {
$this->file = (new File())
->setTitle(basename($attachment->getUrl()))
Expand Down Expand Up @@ -305,7 +305,7 @@ public function sendPayload($payload)
*/
public function replyInThread($message, $additionalParameters, $matchingMessage)
{
$additionalParameters['thread_ts'] = ! empty($matchingMessage->getPayload()->get('thread_ts'))
$additionalParameters['thread_ts'] = !empty($matchingMessage->getPayload()->get('thread_ts'))
? $matchingMessage->getPayload()->get('thread_ts')
: $matchingMessage->getPayload()->get('ts');

Expand All @@ -317,7 +317,7 @@ public function replyInThread($message, $additionalParameters, $matchingMessage)
*/
public function isConfigured()
{
return ! is_null($this->config->get('slack_token'));
return !is_null($this->config->get('slack_token'));
}

/**
Expand All @@ -332,11 +332,23 @@ public function types(IncomingMessage $matchingMessage)
$channel = $_channel;
});

if (! is_null($channel)) {
if (!is_null($channel)) {
$this->client->setAsTyping($channel, false);
}
}

/**
* Send a typing indicator and wait for the given amount of seconds.
* @param IncomingMessage $matchingMessage
* @param float $seconds
* @return mixed
*/
public function typesAndWaits(IncomingMessage $matchingMessage, float $seconds)
{
$this->types($matchingMessage);
usleep($seconds * 1000000);
}

/**
* Retrieve User information.
* @param IncomingMessage $matchingMessage
Expand All @@ -348,7 +360,7 @@ public function getUser(IncomingMessage $matchingMessage)
$this->client->getUserById($matchingMessage->getSender())->then(function ($_user) use (&$user) {
$user = $_user;
});
if (! is_null($user) && $user instanceof SlackUser) {
if (!is_null($user) && $user instanceof SlackUser) {
return new User($this->client, $user->getRawUser());
}

Expand Down

0 comments on commit e6e2a3f

Please sign in to comment.