Skip to content

reintroduced update() #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Commands/AdminCommands/SendtochannelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function execute()
// getConfig has not been configured asking for channel to administer
if ($type != 'Message' || empty($text)) {
$this->conversation->notes['state'] = -1;
//$this->conversation->update();
$this->conversation->update();

$data['text'] = 'Insert the channel name: (@yourchannel)';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
Expand All @@ -88,7 +88,7 @@ public function execute()
// getConfig has been configured choose channel
if ($type != 'Message' || !in_array($text, $channels)) {
$this->conversation->notes['state'] = 0;
//$this->conversation->update();
$this->conversation->update();

$keyboard = [];
foreach ($channels as $channel) {
Expand Down Expand Up @@ -118,7 +118,7 @@ public function execute()
insert:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || ($type == 'Message' && empty($text))) {
$this->conversation->notes['state'] = 1;
//$this->conversation->update();
$this->conversation->update();

$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
$data['text'] = 'Insert the content you want to share: text, photo, audio...';
Expand All @@ -133,7 +133,7 @@ public function execute()
case 2:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) {
$this->conversation->notes['state'] = 2;
//$this->conversation->update();
$this->conversation->update();

// Execute this just with object that allow caption
if ($this->conversation->notes['message_type'] == 'Video' || $this->conversation->notes['message_type'] == 'Photo') {
Expand Down Expand Up @@ -165,7 +165,7 @@ public function execute()
case 3:
if (($this->conversation->notes['last_message_id'] == $message->getMessageId() || $type != 'Message' ) && $this->conversation->notes['set_caption']) {
$this->conversation->notes['state'] = 3;
//$this->conversation->update();
$this->conversation->update();

$data['text'] = 'Insert caption:';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
Expand All @@ -178,7 +178,7 @@ public function execute()
case 4:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) {
$this->conversation->notes['state'] = 4;
//$this->conversation->update();
$this->conversation->update();

$data['text'] = 'Message will look like this:';
$result = Request::sendMessage($data);
Expand Down
6 changes: 6 additions & 0 deletions src/Commands/UserCommands/SurveyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function execute()
case 0:
if (empty($text)) {
$this->conversation->notes['state'] = 0;
$this->conversation->update();

$data['text'] = 'Type your name:';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
Expand All @@ -91,6 +92,7 @@ public function execute()
case 1:
if (empty($text)) {
$this->conversation->notes['state'] = 1;
$this->conversation->update();

$data['text'] = 'Type your surname:';
$result = Request::sendMessage($data);
Expand All @@ -104,6 +106,7 @@ public function execute()
case 2:
if (empty($text) || !is_numeric($text)) {
$this->conversation->notes['state'] = 2;
$this->conversation->update();

$data['text'] = 'Type your age:';
if (!empty($text) && !is_numeric($text)) {
Expand All @@ -119,6 +122,7 @@ public function execute()
case 3:
if (empty($text) || !($text == 'M' || $text == 'F')) {
$this->conversation->notes['state'] = 3;
$this->conversation->update();

$keyboard = [['M','F']];
$reply_keyboard_markup = new ReplyKeyboardMarkup(
Expand All @@ -144,6 +148,7 @@ public function execute()
case 4:
if (is_null($message->getLocation())) {
$this->conversation->notes['state'] = 4;
$this->conversation->update();

$data['text'] = 'Insert your home location (need location object):';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
Expand All @@ -158,6 +163,7 @@ public function execute()
case 5:
if (is_null($message->getPhoto())) {
$this->conversation->notes['state'] = 5;
$this->conversation->update();

$data['text'] = 'Insert your picture:';
$result = Request::sendMessage($data);
Expand Down
11 changes: 0 additions & 11 deletions src/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ public function __construct($user_id, $chat_id, $command = null)
}
}

/**
* Conversation destructor updates the conversation
*/
public function __destruct()
{
//Perform the update when the object goes out of the stage and notes have changed after load()
if ($this->command_is_provided && $this->notes !== $this->protected_notes) {
$this->update();
}
}

/**
* Load the conversation from the database
*
Expand Down