Skip to content

Commit 0018abe

Browse files
committed
3.0.10-beta
1 parent d9ea913 commit 0018abe

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

examples/counter.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@
22

33
use Alisa\Alisa;
44
use Alisa\Context;
5+
use Alisa\Sessions\Session;
6+
use Alisa\Types\Button;
57

68
require __DIR__ . '/../vendor/autoload.php';
79

8-
$alisa = new Alisa;
10+
$alisa = new Alisa([
11+
'buttons' => [
12+
'incrementAndDecrement' => [
13+
new Button('-', 'decrement'),
14+
new Button('+', 'increment'),
15+
],
16+
],
17+
]);
918

1019
$alisa->onStart(function (Context $ctx) {
11-
20+
$ctx->reply(
21+
'Счетчик: ' . Session::get('counter', 0),
22+
buttons: 'incrementAndDecrement'
23+
);
1224
});
1325

14-
$alisa->onAny(function (Context $ctx) {
26+
$alisa->onAction('increment', function (Context $ctx) {
27+
$ctx->reply(
28+
'Счетчик: ' . Session::increment('counter'),
29+
buttons: 'incrementAndDecrement'
30+
);
31+
});
1532

33+
$alisa->onAction('decrement', function (Context $ctx) {
34+
$ctx->reply(
35+
'Счетчик: ' . Session::decrement('counter'),
36+
buttons: 'incrementAndDecrement'
37+
);
1638
});
1739

1840
$alisa->run();

0 commit comments

Comments
 (0)