Skip to content

Commit ebe87ec

Browse files
committed
Merge branch 'newsurvey' into develop
2 parents f5122a8 + 0d0bdb8 commit ebe87ec

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/Commands/UserCommands/SurveyCommand.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SurveyCommand extends UserCommand
2828
protected $name = 'survey';
2929
protected $description = 'Survery for bot users';
3030
protected $usage = '/survey';
31-
protected $version = '0.1.1';
31+
protected $version = '0.2.0';
3232
protected $need_mysql = true;
3333
/**#@-*/
3434

@@ -150,9 +150,15 @@ public function execute()
150150
if (is_null($message->getLocation())) {
151151
$this->conversation->notes['state'] = 4;
152152
$this->conversation->update();
153-
154-
$data['text'] = 'Insert your home location (need location object):';
155-
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
153+
$data['reply_markup'] = new ReplyKeyboardMarkup([
154+
'keyboard' => [[
155+
[ 'text' => 'Share Location', 'request_location' => true ],
156+
]],
157+
'resize_keyboard' => true,
158+
'one_time_keyboard' => true,
159+
'selective' => true,
160+
]);
161+
$data['text'] = 'Share your location:';
156162
$result = Request::sendMessage($data);
157163
break;
158164
}
@@ -167,13 +173,35 @@ public function execute()
167173
$this->conversation->update();
168174

169175
$data['text'] = 'Insert your picture:';
176+
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
170177
$result = Request::sendMessage($data);
171178
break;
172179
}
173180
$this->conversation->notes['photo_id'] = $message->getPhoto()[0]->getFileId();
174181

175182
// no break
176183
case 6:
184+
if (is_null($message->getContact())) {
185+
$this->conversation->notes['state'] = 6;
186+
$this->conversation->update();
187+
188+
$data['text'] = 'Share your contact information:';
189+
$data['reply_markup'] = new ReplyKeyboardMarkup([
190+
'keyboard' => [[
191+
[ 'text' => 'Share Contact', 'request_contact' => true ],
192+
]],
193+
'resize_keyboard' => true,
194+
'one_time_keyboard' => true,
195+
'selective' => true,
196+
]);
197+
$result = Request::sendMessage($data);
198+
break;
199+
}
200+
$this->conversation->notes['phone_number'] = $message->getContact()->getPhoneNumber();
201+
202+
// no break
203+
case 7:
204+
$this->conversation->update();
177205
$out_text = '/Survey result:' . "\n";
178206
unset($this->conversation->notes['state']);
179207
foreach ($this->conversation->notes as $k => $v) {

0 commit comments

Comments
 (0)