Skip to content

Commit 75876a1

Browse files
committed
Update for Laravel 10 and upcoming php-telegram-bot version
1 parent d90268e commit 75876a1

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

composer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"homepage": "https://github.com/php-telegram-bot/laravel",
1919
"keywords": ["laravel", "telegram", "bot"],
2020
"require": {
21-
"illuminate/support": "~7|~8|~9",
22-
"longman/telegram-bot": "^0.80",
21+
"illuminate/support": "~7|~8|~9|~10",
22+
"longman/telegram-bot": "^0.81",
2323
"ext-pcntl": "*"
2424
},
2525
"require-dev": {
@@ -32,6 +32,9 @@
3232
}
3333
},
3434
"extra": {
35+
"branch-alias": {
36+
"dev-main": "2.1.x-dev"
37+
},
3538
"laravel": {
3639
"providers": [
3740
"PhpTelegramBot\\Laravel\\TelegramServiceProvider"
@@ -41,5 +44,7 @@
4144
"Telegram": "PhpTelegramBot\\Laravel\\Facades\\Telegram"
4245
}
4346
}
44-
}
47+
},
48+
"minimum-stability": "dev",
49+
"prefer-stable": true
4550
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
return new class extends Migration {
7+
public function up()
8+
{
9+
DB::unprepared(file_get_contents(__DIR__ . '/sql/0.80.0-0.81.0.sql'));
10+
}
11+
12+
public function down()
13+
{
14+
//
15+
}
16+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ALTER TABLE `bot_message`
2+
ADD COLUMN `has_media_spoiler` TINYINT(1) DEFAULT 0 COMMENT 'True, if the message media is covered by a spoiler animation' AFTER `caption`,
3+
ADD COLUMN `write_access_allowed` TEXT DEFAULT NULL COMMENT 'Service message: the user allowed the bot added to the attachment menu to write messages' AFTER `connected_website`,
4+
ADD COLUMN `forum_topic_edited` TEXT DEFAULT NULL COMMENT 'Service message: forum topic edited' AFTER `forum_topic_created`,
5+
ADD COLUMN `general_forum_topic_hidden` TEXT DEFAULT NULL COMMENT 'Service message: the General forum topic hidden' AFTER `forum_topic_reopened`,
6+
ADD COLUMN `general_forum_topic_unhidden` TEXT DEFAULT NULL COMMENT 'Service message: the General forum topic unhidden' AFTER `general_forum_topic_hidden`,
7+
ADD COLUMN `user_shared` TEXT DEFAULT NULL COMMENT 'Optional. Service message: a user was shared with the bot' AFTER `successful_payment`,
8+
ADD COLUMN `chat_shared` TEXT DEFAULT NULL COMMENT 'Optional. Service message: a chat was shared with the bot' AFTER `user_shared`;

readme.md

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,38 @@ Install this package through Composer. Run this command in your project's termin
1010
``` bash
1111
composer require php-telegram-bot/laravel
1212
```
13+
14+
Execute the following command to publish the folder structure to your Laravel application:
15+
```bash
16+
php artisan telegram:publish
17+
```
18+
This also includes a dummy `/start` command to give you a quick start.
19+
20+
Since we're using the database part of php-telegram-bot you should run the migrations so the database schema gets installed:
21+
```bash
22+
php artisan migrate
23+
```
24+
25+
And add the following lines to your .env file:
26+
```dotenv
27+
TELEGRAM_API_TOKEN=
28+
TELEGRAM_BOT_USERNAME=
29+
TELEGRAM_API_URL=
30+
TELEGRAM_ADMINS=
31+
```
32+
33+
`TELEGRAM_API_TOKEN` and `TELEGRAM_BOT_USERNAME` should be filled with the corresponding data from [@BotFather](https://t.me/BotFather)
34+
35+
`TELEGRAM_API_URL` is optional and can be filled with the URL to your [custom Bot API Server](https://core.telegram.org/bots/api#using-a-local-bot-api-server) if you want to use one.
36+
37+
`TELEGRAM_ADMINS` is optional and a comma-separated list of Telegram User IDs that gets passed to the `enableAdmins` command of php-telegram-bot to enable admin commands for those users.
38+
39+
After that you can run `php artisan telegram:set-webhook` if your development server is reachable from the outside or you're using a custom bot api server.
40+
41+
Or `php artisan telegram:fetch` to start fetching your updates via polling.
42+
43+
⚠️ Be aware that you have to cancel and restart the `telegram:fetch` command, if you change your code.
44+
1345
## Usage
1446
For further basic configuration of this Laravel package you do not need to create any configuration files.
1547

src/Console/Commands/TelegramFetchCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function handle(Telegram $bot)
3939
$options['allowed_updates'] = Str::of($allowedUpdates)->explode(',');
4040
}
4141

42-
$this->info("Start fetching updates...\n<comment>(Exit with Ctrl + C.)</comment>");
42+
$this->info("Start fetching updates...\n<comment>(Exit with Ctrl + C)</comment>");
4343

4444
if ($this->childPid = pcntl_fork()) {
4545
// Parent process

0 commit comments

Comments
 (0)