Skip to content

Commit b79975f

Browse files
committed
Need fix InputMessageFormatter
1 parent 55d64c8 commit b79975f

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/.root/routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Hopex\VkSdk\Services\ServerEventsService;
66
use Illuminate\Support\Facades\Route;
77

8-
Route::prefix('api')->name('vk.')->group(function () {
8+
Route::prefix('api')->name('vk-sdk.')->group(function () {
99

1010
Route::post(SdkConfig::routes('group'), function (CallbackEventsService $callback) {
1111
return response($callback->divide(), 200, [

src/Formatters/ClearInputMessageFormatter.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ class ClearInputMessageFormatter implements CanFormatContract
1212
{
1313
/**
1414
* @param $data
15-
* @return string
15+
* @return array
1616
*/
17-
public function format($data): string
17+
public function format($data): array
1818
{
19-
return explode(' ', preg_replace("~((^\[.*\])?\s*\!*)|(^\s*\!*)~", '', $data))[0];
19+
$input = explode(' ', preg_replace("~((^\[.*\])?\s*\!*)|(^\s*\!*)~", '$1', $data));
20+
return array_merge([
21+
$input[0]
22+
], [
23+
implode(' ', array_slice($input, 1, count($input)))
24+
]);
2025
}
2126
}

src/Foundation/Core/Entities/Messages/MessageFields.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\Carbon;
66
use Hopex\VkSdk\Exceptions\Api\ApiException;
7+
use Hopex\VkSdk\Facades\VkApi;
78
use Hopex\VkSdk\Foundation\Core\Entities\Users\UserProfileFields;
89
use Hopex\VkSdk\Foundation\Core\Entities\Users\UserRequestFields;
910
use Illuminate\Support\Collection;
@@ -52,20 +53,19 @@ public function getDate(): Carbon
5253

5354
/**
5455
* @param string $token
55-
* @param array $userProfileFields
56+
* @param UserRequestFields $userRequestFields
5657
* @return UserProfileFields
57-
* @throws ApiException
58-
* @throws Throwable
5958
*/
6059
public function getSender(string $token, UserRequestFields $userRequestFields): UserProfileFields
6160
{
62-
return new UserProfileFields([]);
61+
// return new UserProfileFields([]);
62+
return new UserProfileFields(collect(VkApi::user($token)->get($userRequestFields)));
6363
// return new UserProfileFields(collect(VkApi::user($token)
6464
// ->get((new UserRequestFields())
6565
// ->setUserIds([
6666
// $this->getSenderId()
6767
// ])
68-
// ->setProfileFields($userRequestFields->)
68+
// ->setProfileFields($userRequestFields->fields
6969
// )->first()));
7070
}
7171

0 commit comments

Comments
 (0)