Skip to content

Commit 42df8a6

Browse files
committed
Merge branch 'master' of github.com:botman/driver-slack
2 parents 1e4c2fc + f376c81 commit 42df8a6

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/Extensions/Dialog.php

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
abstract class Dialog
88
{
9-
109
/** @var string */
1110
protected $title;
1211

@@ -15,7 +14,7 @@ abstract class Dialog
1514

1615
/** @var string */
1716
protected $callbackId;
18-
17+
1918
/** @var array */
2019
protected $elements = [];
2120

@@ -65,7 +64,7 @@ public function add(string $label, string $name, string $type, array $additional
6564
public function text(string $label, string $name, $value = null, $additional = [])
6665
{
6766
return $this->add($label, $name, 'text', array_merge([
68-
'value' => $value
67+
'value' => $value,
6968
], $additional));
7069
}
7170

@@ -79,7 +78,7 @@ public function text(string $label, string $name, $value = null, $additional = [
7978
public function textarea(string $label, string $name, $value = null, $additional = [])
8079
{
8180
return $this->add($label, $name, 'textarea', array_merge([
82-
'value' => $value
81+
'value' => $value,
8382
], $additional));
8483
}
8584

@@ -94,7 +93,7 @@ public function email(string $label, string $name, $value = null, $additional =
9493
{
9594
return $this->add($label, $name, 'text', array_merge([
9695
'subtype' => 'email',
97-
'value' => $value
96+
'value' => $value,
9897
], $additional));
9998
}
10099

@@ -109,7 +108,7 @@ public function number(string $label, string $name, $value = null, $additional =
109108
{
110109
return $this->add($label, $name, 'text', array_merge([
111110
'subtype' => 'number',
112-
'value' => $value
111+
'value' => $value,
113112
], $additional));
114113
}
115114

@@ -124,7 +123,7 @@ public function tel(string $label, string $name, $value = null, $additional = []
124123
{
125124
return $this->add($label, $name, 'text', array_merge([
126125
'subtype' => 'tel',
127-
'value' => $value
126+
'value' => $value,
128127
], $additional));
129128
}
130129

@@ -139,7 +138,7 @@ public function url(string $label, string $name, $value = null, $additional = []
139138
{
140139
return $this->add($label, $name, 'text', array_merge([
141140
'subtype' => 'url',
142-
'value' => $value
141+
'value' => $value,
143142
], $additional));
144143
}
145144

@@ -151,10 +150,10 @@ public function toArray()
151150
$this->buildForm();
152151

153152
return [
154-
"callback_id" => $this->callbackId,
155-
"title" => $this->title,
156-
"submit_label" => $this->submitLabel,
157-
"elements" => $this->elements
153+
'callback_id' => $this->callbackId,
154+
'title' => $this->title,
155+
'submit_label' => $this->submitLabel,
156+
'elements' => $this->elements,
158157
];
159158
}
160159
}

src/SlackDriver.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use Illuminate\Support\Collection;
77
use BotMan\BotMan\Drivers\HttpDriver;
88
use BotMan\Drivers\Slack\Extensions\User;
9-
use BotMan\Drivers\Slack\Extensions\Dialog;
109
use BotMan\BotMan\Messages\Incoming\Answer;
10+
use BotMan\Drivers\Slack\Extensions\Dialog;
1111
use BotMan\BotMan\Interfaces\VerifiesService;
1212
use BotMan\BotMan\Messages\Attachments\Image;
1313
use BotMan\BotMan\Messages\Outgoing\Question;
@@ -252,14 +252,14 @@ public function replyInThread($message, $additionalParameters, $matchingMessage,
252252
* @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage
253253
* @return array
254254
*/
255-
public function replyDialog(Dialog $dialog, $additionalParameters = [], $matchingMessage, BotMan $bot)
255+
public function replyDialog(Dialog $dialog, $additionalParameters, $matchingMessage, BotMan $bot)
256256
{
257257
$this->resultType = self::RESULT_DIALOG;
258258
$payload = [
259259
'trigger_id' => $this->payload->get('trigger_id'),
260260
'channel' => $matchingMessage->getRecipient() === '' ? $matchingMessage->getSender() : $matchingMessage->getRecipient(),
261261
'token' => $this->config->get('token'),
262-
'dialog' => json_encode($dialog->toArray())
262+
'dialog' => json_encode($dialog->toArray()),
263263
];
264264

265265
return $bot->sendPayload($payload);
@@ -430,13 +430,14 @@ private function getBotId()
430430
*/
431431
public function extendConversation()
432432
{
433-
Conversation::macro('sendDialog', function(Dialog $dialog, $next, $additionalParameters = []) {
433+
Conversation::macro('sendDialog', function (Dialog $dialog, $next, $additionalParameters = []) {
434434
$response = $this->bot->replyDialog($dialog, $additionalParameters);
435435

436-
$validation = function($answer) use ($dialog, $next, $additionalParameters) {
436+
$validation = function ($answer) use ($dialog, $next, $additionalParameters) {
437437
$errors = $dialog->errors(Collection::make($answer->getValue()));
438438
if (count($errors)) {
439439
$this->bot->touchCurrentConversation();
440+
440441
return Response::create(json_encode(['errors' => $errors]), 200, ['ContentType' => 'application/json'])->send();
441442
} else {
442443
if ($next instanceof \Closure) {
@@ -446,6 +447,7 @@ public function extendConversation()
446447
}
447448
};
448449
$this->bot->storeConversation($this, $validation, $dialog, $additionalParameters);
450+
449451
return $response;
450452
});
451453
}

0 commit comments

Comments
 (0)