Skip to content

Commit 0f112bc

Browse files
Updates for v4 (#7)
1 parent a2868d4 commit 0f112bc

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

src/Console/Command/CommandRegisterCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Telegram\Bot\Commands\CommandHandler;
77
use Telegram\Bot\Exceptions\TelegramSDKException;
88
use Telegram\Bot\Laravel\Console\ConsoleBaseCommand;
9-
use Telegram\Bot\Objects\BotCommand;
9+
use Telegram\Bot\Objects\BotCommand\BotCommand;
1010

1111
class CommandRegisterCommand extends ConsoleBaseCommand
1212
{

src/Console/Webhook/WebhookInfoCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Symfony\Component\Console\Input\InputOption;
99
use Telegram\Bot\Exceptions\TelegramSDKException;
1010
use Telegram\Bot\Laravel\Console\ConsoleBaseCommand;
11-
use Telegram\Bot\Objects\WebhookInfo;
11+
use Telegram\Bot\Objects\ResponseObject;
1212
use Throwable;
1313

1414
class WebhookInfoCommand extends ConsoleBaseCommand
@@ -136,7 +136,7 @@ protected function getWebhookInfo(string $name): ?array
136136
/**
137137
* Present last error date unix time to readable.
138138
*/
139-
protected function presentLastErrorDate(WebhookInfo $webhook): ?Carbon
139+
protected function presentLastErrorDate(ResponseObject $webhook): ?Carbon
140140
{
141141
return $webhook->last_error_date !== 0
142142
? Carbon::createFromTimestamp($webhook->last_error_date, config('app.timezone'))

src/Console/Webhook/WebhookRemoveCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function removeWebhook(Bot $bot): void
4646
if ($this->confirm("Are you sure you want to remove the webhook for [{$bot->config('bot')}] bot?")) {
4747
$this->info('Removing webhook...');
4848

49-
if ($bot->removeWebhook()) {
49+
if ($bot->deleteWebhook()) {
5050
$this->info('Webhook removed successfully!');
5151

5252
return;

src/Events/WebhookFailed.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Telegram\Bot\Laravel\Events;
44

5+
use Telegram\Bot\Objects\ResponseObject;
56
use Telegram\Bot\Objects\Update;
67
use Throwable;
78

@@ -15,7 +16,7 @@ class WebhookFailed
1516
/**
1617
* Create a new event instance.
1718
*/
18-
public function __construct(public string $botname, public Update $update, public Throwable $exception)
19+
public function __construct(public string $botname, public ResponseObject $update, public Throwable $exception)
1920
{
2021
}
2122
}

stubs/app/Listeners/ProcessInboundPhoto.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Telegram\Bot\Events\UpdateEvent;
66
use Telegram\Bot\Exceptions\TelegramSDKException;
7-
use Telegram\Bot\Objects\PhotoSize;
87

98
/**
109
* Class ProcessInboundPhoto
@@ -23,14 +22,13 @@ public function handle(UpdateEvent $event)
2322
$bot = $event->bot;
2423

2524
// Download the largest image to the storage/app directory.
26-
/** @var PhotoSize $photo */
27-
$photo = collect($update->getMessage()->photo)->last();
25+
$photo = collect($update['message']['photo'])->last();
2826
$bot->downloadFile($photo, storage_path('app/photos'));
2927

3028
// Reply the user.
3129
$text = 'Thanks for uploading the pic!';
3230
$bot->sendMessage([
33-
'chat_id' => $update->getMessage()->chat->id,
31+
'chat_id' => $update['message']['chat']['id'],
3432
'text' => $text,
3533
]);
3634
}

stubs/app/Telegram/Commands/Start.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Start extends Command
1414
*/
1515
public function handle()
1616
{
17-
$message = $this->getUpdate()->getMessage();
17+
$message = $this->getUpdate()->message;
1818
$firstName = $message->from->first_name;
1919

2020
$text = "Hello, $firstName! Welcome to our bot!\nType /help to get a list of available commands.";

0 commit comments

Comments
 (0)