Skip to content

Commit

Permalink
Fix auto stop
Browse files Browse the repository at this point in the history
  • Loading branch information
tanftw committed Apr 21, 2017
1 parent 27e4616 commit 6411f87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/Conversation/AutoStop.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static function run($event)
return false;

if ($event->sender->id == Conversation::get('page_id')) {

$administrator_text = null;
$lead_id = $event->recipient->id;

Expand Down
23 changes: 11 additions & 12 deletions src/MessengerBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,24 @@ public function processEvent($event)
if (isset($event->postback)) {
$this->postback = $event->postback;
}

// If auto stop is run and it return true. Terminate
if (AutoStop::run($event)) {
return null;
}

$this->conversation->set('lead_id', $event->sender->id);
$this->conversation->set('page_id', $event->recipient->id);

// If current message is sent from Lead
if ( ! isset($event->message->is_echo)) {

if (AutoStop::isStopped()) {
return null;
}
} else {
// If current message is sent from Page
if (isset($event->message->is_echo)) {
$this->conversation->set('lead_id', $event->recipient->id);
$this->conversation->set('page_id', $event->sender->id);
}

// If auto stop is run and it return true. Terminate
if (AutoStop::run($event)) {
return null;
}

if (AutoStop::isStopped()) {
return null;
}

$this->setAccessToken();

Expand Down

0 comments on commit 6411f87

Please sign in to comment.