这是indexloc提供的服务,不要输入任何密码
Skip to content
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
26 changes: 26 additions & 0 deletions src/Dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ final public function proceed(Update $update): void
{
$currentStepIndex = $this->next;

if ($this->isStart()) {
$this->beforeAllStep($update);
}

if ($this->isEnd()) {
$this->afterAllStep($update);
return;
}

Expand Down Expand Up @@ -100,9 +105,22 @@ final public function proceed(Update $update): void
}
}

/** @experimental Run code before all step. */
protected function beforeAllStep(Update $update): void
{
// override the method to add your logic here
}

/** @experimental Run code after all step. */
protected function afterAllStep(Update $update): void
{
// override the method to add your logic here
}

/** @experimental Run code before every step. */
protected function beforeEveryStep(Update $update, int $step): void
{
// add experimental Dialog::beforeAllStep
// override the method to add your logic here
}

Expand Down Expand Up @@ -141,6 +159,14 @@ final protected function forget(string $key): void
unset($this->memory[$key]);
}


/** Check if Dialog started */
final public function isStart(): bool
{
return $this->next === 0;
}


/** Check if Dialog ended */
final public function isEnd(): bool
{
Expand Down
1 change: 1 addition & 0 deletions src/DialogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function proceed(Update $update): void

if ($dialog->isEnd()) {
$this->store->delete($dialog->getChatId());
$dialog->proceed($update);
} else {
$this->storeDialogState($dialog);
}
Expand Down