Skip to content

Commit 443b0e2

Browse files
authored
Merge pull request #1 from nutgram/update-nutgram-to-4.x
2 parents 58e2b24 + c33b136 commit 443b0e2

34 files changed

+947
-718
lines changed

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ ij_php_space_after_type_cast = false
2424
ij_php_concat_spaces = false
2525

2626
[*.json]
27-
indent_size = 2
27+
indent_size = 2
28+
29+
[src/Facades/Telegram.php]
30+
max_line_length = off
31+
ij_php_phpdoc_wrap_long_lines = false

README.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
# WIP - Do not use before Nutgram 4.0
2-
3-
#### TODO:
4-
- [ ] Replace namespace from "SergiX44\Nutgram" to "Nutgram"
5-
- [ ] Bump PHP version to 8.1
6-
- [ ] Bump Laravel version to 9.0
7-
- [ ] Update this README.md
8-
- [ ] Add github workflows for tests and changelog
1+
# Nugram Package for Laravel
2+
3+
[![Version](https://img.shields.io/packagist/v/nutgram/laravel?label=composer&logo=composer)](https://packagist.org/packages/nutgram/laravel)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/nutgram/laravel.svg)](https://packagist.org/packages/nutgram/laravel)
5+
![License](https://img.shields.io/github/license/nutgram/laravel)
6+
![PHP](https://img.shields.io/packagist/dependency-v/nutgram/laravel/php?logo=php)
7+
![Laravel](https://img.shields.io/packagist/dependency-v/nutgram/laravel/illuminate/support?label=laravel&logo=laravel)
8+
9+
![Tests](https://img.shields.io/github/actions/workflow/status/nutgram/laravel/php.yml?label=Test%20Suite&logo=github)
10+
[![Test Coverage](https://api.codeclimate.com/v1/badges/feaa33a8d1431d16998d/test_coverage)](https://codeclimate.com/github/nutgram/laravel/test_coverage)
11+
[![Maintainability](https://api.codeclimate.com/v1/badges/feaa33a8d1431d16998d/maintainability)](https://codeclimate.com/github/nutgram/laravel/maintainability)
12+
13+
[Nutgram](https://github.com/nutgram/nutgram) Package for Laravel 9.0+.
14+
15+
## Installation
16+
17+
You can install the package via composer:
18+
19+
```bash
20+
composer require nutgram/laravel
21+
```
22+
23+
## Usage
24+
25+
- [Official Documentation for Laravel](https://nutgram.dev/docs/configuration/laravel)
26+
27+
## Credits
28+
29+
- [Sergio Brighenti](https://github.com/SergiX44)
30+
- [Luca Patera](https://github.com/Lukasss93)
31+
- [All Contributors](../../contributors)
32+
33+
## License
34+
35+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
36+

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
"minimum-stability": "dev",
2929
"prefer-stable": true,
3030
"require": {
31-
"php": "^8.0",
32-
"nutgram/nutgram": "^3.13"
31+
"php": "^8.2",
32+
"nunomaduro/termwind": "^1.15",
33+
"nutgram/nutgram": "^4.0"
3334
},
3435
"require-dev": {
35-
"illuminate/testing": "^8.0|^9.0|^10.0",
36-
"orchestra/testbench": "^6.0|^7.0|^8.0",
36+
"illuminate/testing": "^9.0|^10.0",
37+
"orchestra/testbench": "^7.0|^8.0",
3738
"pestphp/pest": "^1.1",
3839
"pestphp/pest-plugin-mock": "^1.0",
3940
"roave/security-advisories": "dev-latest",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="text-red-500 mx-2 my-1">{{$value}}</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
<div class="mx-2 my-1">
4+
@foreach($items as $item)
5+
<div class="flex space-x-1">
6+
<span class="text-yellow">{{$item['handler']}}</span>
7+
<span class="text-gray">{{$item['pattern']}}</span>
8+
<span class="flex-1 content-repeat-['.']"></span>
9+
<span class="text-blue">{{$item['callable']}}</span>
10+
</div>
11+
@endforeach
12+
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="text-green-500 mx-2 my-1">{{$value}}</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="mx-2 my-1">
2+
@foreach($items as $key => $value)
3+
<div class="flex space-x-1">
4+
<span class="text-yellow">{{$key}}</span>
5+
<span class="flex-1 content-repeat-['.']"></span>
6+
<span class="text-blue">{{$value}}</span>
7+
</div>
8+
@endforeach
9+
</div>

routes/telegram.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2+
/** @var SergiX44\Nutgram\Nutgram $bot */
23

3-
use Nutgram\Laravel\Facades\Bot;
44
use SergiX44\Nutgram\Nutgram;
55

66
/*
@@ -13,6 +13,6 @@
1313
|
1414
*/
1515

16-
Bot::onCommand('start', function (Nutgram $bot) {
16+
$bot->onCommand('start', function (Nutgram $bot) {
1717
return $bot->sendMessage('Hello, world!');
1818
})->description('The start command!');

src/Console/HookInfoCommand.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use JsonException;
88
use SergiX44\Nutgram\Nutgram;
99
use SergiX44\Nutgram\Telegram\Exceptions\TelegramException;
10+
use function Termwind\{render};
11+
1012

1113
class HookInfoCommand extends Command
1214
{
@@ -24,7 +26,7 @@ public function handle(Nutgram $bot): int
2426
$webhookInfo = $bot->getWebhookInfo();
2527

2628
if ($webhookInfo === null) {
27-
$this->error('Unable to get webhook info');
29+
render(view('terminal::fail', ['value' => 'Unable to get webhook info']));
2830
return 1;
2931
}
3032

@@ -38,17 +40,19 @@ public function handle(Nutgram $bot): int
3840
$lastSynchronizationErrorDate = date('Y-m-d H:i:s', $webhookInfo->last_synchronization_error_date).' UTC';
3941
}
4042

41-
$this->table(['Info', 'Value'], [
42-
['url', $webhookInfo->url],
43-
['has_custom_certificate', $webhookInfo->has_custom_certificate ? 'true' : 'false'],
44-
['pending_update_count', $webhookInfo->pending_update_count],
45-
['ip_address', $webhookInfo->ip_address],
46-
['last_error_date', $lastErrorDate],
47-
['last_error_message', $webhookInfo->last_error_message],
48-
['last_synchronization_error_date', $lastSynchronizationErrorDate],
49-
['max_connections', $webhookInfo->max_connections],
50-
['allowed_updates', implode(', ', $webhookInfo->allowed_updates ?: [])],
51-
]);
43+
render(view('terminal::table', [
44+
'items' => [
45+
'url' => $webhookInfo->url,
46+
'has_custom_certificate' => $webhookInfo->has_custom_certificate ? 'true' : 'false',
47+
'pending_update_count' => $webhookInfo->pending_update_count,
48+
'ip_address' => $webhookInfo->ip_address,
49+
'last_error_date' => $lastErrorDate,
50+
'last_error_message' => $webhookInfo->last_error_message,
51+
'last_synchronization_error_date' => $lastSynchronizationErrorDate,
52+
'max_connections' => $webhookInfo->max_connections,
53+
'allowed_updates' => implode(', ', $webhookInfo->allowed_updates ?: []),
54+
]
55+
]));
5256

5357
return 0;
5458
}

0 commit comments

Comments
 (0)