Skip to content

Commit 5faf680

Browse files
committed
3.0.0-beta
1 parent f9ff55c commit 5faf680

File tree

30 files changed

+334
-173
lines changed

30 files changed

+334
-173
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
SKILL_ID=
22
OAUTH=
33

4+
TIMEZONE=Europe/Moscow
5+
46
DB_CONNECTION=sqlite
57
DB_HOST=127.0.0.1
68
DB_PORT=3306

alisa

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ switch ($argv[1] ?? null) {
1313
case 'serve':
1414
$port = $argv[2] ?? 8000;
1515

16-
echo shell_exec("php -S localhost:{$port} -t public");
16+
echo '[>] Вебхук: http://localhost:' . $port . '/webhook.php' . PHP_EOL;
17+
echo '[!] Необходимо дополнительно запустить тунель, если хотите тестировать в Диалогах.' . PHP_EOL . PHP_EOL;
18+
19+
shell_exec("php -S localhost:{$port} -t public");
1720

1821
break;
1922

@@ -42,14 +45,14 @@ switch ($argv[1] ?? null) {
4245

4346
case 'make:component':
4447
if (!isset($argv[2])) {
45-
die('[Ошибка] Укажите название компонента: php alisa make:component <name>.');
48+
die('[!] Укажите название компонента: php alisa make:component <name>.');
4649
}
4750

4851
$name = $argv[2];
4952
$path = project_path('app/Components/' . $name . '.php');
5053

5154
if (file_exists($path)) {
52-
die('[Ошибка] Компонент уже существует: ' . $path . '" ');
55+
die('[!] Компонент уже существует: ' . $path . '" ');
5356
}
5457

5558
$stub = file_get_contents(project_path('framework/stubs/component.stub'));
@@ -64,14 +67,14 @@ switch ($argv[1] ?? null) {
6467

6568
case 'make:controller':
6669
if (!isset($argv[2])) {
67-
die('[Ошибка] Укажите название контролера: php alisa make:controller <name>.');
70+
die('[!] Укажите название контролера: php alisa make:controller <name>.');
6871
}
6972

7073
$name = $argv[2];
7174
$path = project_path('app/Controllers/' . $name . '.php');
7275

7376
if (file_exists($path)) {
74-
die('[Ошибка] Контроллер уже существует: ' . $path . '" ');
77+
die('[!] Контроллер уже существует: ' . $path . '" ');
7578
}
7679

7780
$stub = file_get_contents(project_path('framework/stubs/controller.stub'));
@@ -86,14 +89,14 @@ switch ($argv[1] ?? null) {
8689

8790
case 'make:middleware':
8891
if (!isset($argv[2])) {
89-
die('[Ошибка] Укажите название мидлвари: php alisa make:middleware <name>.');
92+
die('[!] Укажите название мидлвари: php alisa make:middleware <name>.');
9093
}
9194

9295
$name = $argv[2];
9396
$path = project_path('app/Middlewares/' . $name . '.php');
9497

9598
if (file_exists($path)) {
96-
die('[Ошибка] Мидлваря уже существует: ' . $path . '" ');
99+
die('[!] Мидлваря уже существует: ' . $path . '" ');
97100
}
98101

99102
$stub = file_get_contents(project_path('framework/stubs/middleware.stub'));
@@ -108,14 +111,14 @@ switch ($argv[1] ?? null) {
108111

109112
case 'make:migration':
110113
if (!isset($argv[2])) {
111-
die('[Ошибка] Укажите название таблицы: php alisa make:migration <table>.');
114+
die('[!] Укажите название таблицы: php alisa make:migration <table>.');
112115
}
113116

114117
$table = $argv[2];
115118
$path = project_path('database/migrations/' . time() . '-table-' . $table . '.php');
116119

117120
if (file_exists($path)) {
118-
die('[Ошибка] Миграция уже существует: ' . $path . '" ');
121+
die('[!] Миграция уже существует: ' . $path . '" ');
119122
}
120123

121124
$stub = file_get_contents(project_path('framework/stubs/migration.stub'));
@@ -132,9 +135,7 @@ switch ($argv[1] ?? null) {
132135
case '--help':
133136
case '-h':
134137
default:
135-
echo "----------------------" . PHP_EOL;
136-
echo "| Доступные команды: |" . PHP_EOL;
137-
echo "----------------------" . PHP_EOL;
138+
echo "Доступные команды:" . PHP_EOL;
138139
echo " [Сервер]" . PHP_EOL;
139140
echo " - php alisa serve <port?> .................. Запустить сервер" . PHP_EOL;
140141
echo " [Создать]" . PHP_EOL;

app/Components/VersionComponent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
class VersionComponent extends Component
99
{
10-
public function register(string $version = null)
10+
public function register()
1111
{
12-
$this->alisa->onCommand(['версия', 'version'], function (Context $context) use ($version) {
13-
$context->reply("Версия навыка: {$version}");
12+
$this->alisa->onCommand(['версия', 'version'], function (Context $ctx) {
13+
$ctx->reply("Версия навыка: {$this->args['version']}");
1414
});
1515
}
1616
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Controllers;
4+
5+
use Alisa\Context;
6+
7+
class AudioPlayerController
8+
{
9+
public function onPlaybackStarted(Context $ctx)
10+
{
11+
//
12+
}
13+
14+
public function onPlaybackFinished(Context $ctx)
15+
{
16+
//
17+
}
18+
19+
public function onPlaybackNearlyFinished(Context $ctx)
20+
{
21+
//
22+
}
23+
24+
public function onPlaybackStopped(Context $ctx)
25+
{
26+
//
27+
}
28+
29+
public function onPlaybackFailed(Context $ctx)
30+
{
31+
//
32+
}
33+
}

app/Controllers/MainController.php

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,78 @@
77

88
class MainController
99
{
10-
public function start(Context $context)
10+
public function onStart(Context $ctx)
1111
{
1212
//
1313
}
1414

15-
public function help(Context $context)
15+
public function onHelp(Context $ctx)
1616
{
1717
//
1818
}
1919

20-
public function features(Context $context)
20+
public function onWhatCanYouDo(Context $ctx)
2121
{
2222
//
2323
}
2424

25-
public function fallback(Context $context)
25+
public function onFallback(Context $ctx)
2626
{
2727
//
2828
}
2929

30-
public function exception(Context $context, Throwable $exception)
30+
public function onRepeat(Context $ctx)
3131
{
32-
$dir = storage_path('logs/exceptions/' . date('Y-m-d'));
32+
//
33+
}
34+
35+
public function onError(Context $ctx, Throwable $th)
36+
{
37+
//
38+
}
39+
40+
public function onAny(Context $ctx)
41+
{
42+
//
43+
}
44+
45+
public function onCommand(Context $ctx)
46+
{
47+
//
48+
}
49+
50+
public function onIntent(Context $ctx)
51+
{
52+
//
53+
}
54+
55+
public function onAction(Context $ctx)
56+
{
57+
//
58+
}
3359

34-
if (!file_exists($dir)) {
35-
mkdir($dir, 0776, true);
36-
}
60+
public function onConfirm(Context $ctx)
61+
{
62+
//
63+
}
3764

38-
$file = $dir . '/exceptions.log';
65+
public function onReject(Context $ctx)
66+
{
67+
//
68+
}
3969

40-
file_put_contents($file, '[' . date('d.m.Y H:i:s') . "] \n[context] -> " . $context . "\n[exception] -> " . $exception . "\n\n", FILE_APPEND);
70+
public function onDangerous(Context $ctx)
71+
{
72+
//
73+
}
74+
75+
public function onPurchaseConfirmation(Context $ctx)
76+
{
77+
//
78+
}
79+
80+
public function onShowPull(Context $ctx)
81+
{
82+
//
4183
}
4284
}

app/Middlewares/.gitkeep

Whitespace-only changes.

app/Middlewares/RequestToLogMiddleware.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/Models/User.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,5 @@
66

77
class User extends Auth
88
{
9-
protected $fillable = [
10-
'id',
11-
'is_guest',
12-
'options',
13-
];
14-
15-
protected $casts = [
16-
'options' => 'array',
17-
];
9+
//
1810
}

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alisa/framework",
3-
"description": "Фреймворк для разработки навыков Алисы.",
3+
"description": "Базовый проект навыка Алисы для быстрого старта.",
44
"type": "project",
55
"keywords": [
66
"yandex",
@@ -17,18 +17,16 @@
1717
"Framework\\": "framework/core/"
1818
},
1919
"files": [
20+
"framework/helpers.php",
2021
"helpers.php"
2122
]
2223
},
2324
"require": {
24-
"vlucas/phpdotenv": "^5.6",
2525
"illuminate/database": "^11.14",
2626
"illuminate/events": "^11.14",
27-
"laravel/serializable-closure": "^1.3",
28-
"alisa/alisa": "^2.0"
29-
},
30-
"require-dev": {
31-
"symfony/var-dumper": "^7.1"
27+
"alisa/alisa": "^3.0.0-beta",
28+
"laravel/serializable-closure": "^2.0",
29+
"vlucas/phpdotenv": "^5.6"
3230
},
3331
"scripts": {
3432
"post-root-package-install": [
@@ -37,5 +35,8 @@
3735
"post-create-project-cmd": [
3836
"@php alisa migrate:up"
3937
]
38+
},
39+
"require-dev": {
40+
"symfony/var-dumper": "^7.2"
4041
}
41-
}
42+
}

config/app.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,24 @@
1515
*/
1616
'oauth' => env('OAUTH'),
1717

18+
/**
19+
* Временная зона.
20+
*/
21+
'timezone' => env('TIMEZONE', 'Europe/Moscow'),
22+
1823
/**
1924
* Хранилище.
2025
*
2126
* Используется для хранения данных, логов, кэширования изображений
2227
* и прочих файлов которые нужно хранить в навыке.
2328
*/
24-
'storage' => __DIR__ . '/../storage',
29+
'storage_path' => storage_path(),
2530

2631
/**
2732
* Тестовый запрос.
2833
*
2934
* Например, чтобы провести тестирование или отладку навыка
3035
* или для чего-то ещё.
3136
*/
32-
'payload' => null,
37+
'request' => null,
3338
];

0 commit comments

Comments
 (0)