Skip to content

Commit 8a5a5c5

Browse files
committed
Merge branch 'feature/smartinterface' of https://github.com/MBoretto/php-telegram-bot into feature/smartinterface
2 parents 0ae4fd1 + 291b90f commit 8a5a5c5

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

src/Commands/AdminCommands/SendtochannelCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function execute()
6969
// getConfig has not been configured asking for channel to administer
7070
if ($type != 'Message' || empty($text)) {
7171
$this->conversation->notes['state'] = -1;
72-
//$this->conversation->update();
72+
$this->conversation->update();
7373

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

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

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

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

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

183183
$data['text'] = 'Message will look like this:';
184184
$result = Request::sendMessage($data);

src/Commands/UserCommands/SurveyCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function execute()
7979
case 0:
8080
if (empty($text)) {
8181
$this->conversation->notes['state'] = 0;
82+
$this->conversation->update();
8283

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

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

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

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

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

162168
$data['text'] = 'Insert your picture:';
163169
$result = Request::sendMessage($data);

src/Conversation.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ public function __construct($user_id, $chat_id, $command = null)
8989
}
9090
}
9191

92-
/**
93-
* Conversation destructor updates the conversation
94-
*/
95-
public function __destruct()
96-
{
97-
//Perform the update when the object goes out of the stage and notes have changed after load()
98-
if ($this->command_is_provided && $this->notes !== $this->protected_notes) {
99-
$this->update();
100-
}
101-
}
102-
10392
/**
10493
* Load the conversation from the database
10594
*

0 commit comments

Comments
 (0)