mollsoft / web-telegram-bot
Create Telegram Bots in Laravel similar to creating a website.
Requires
- php: >=8.2
- ext-redis: *
- defstudio/telegraph: ^1.42
- illuminate/contracts: ^10.0
- illuminate/support: ^10.0
- spatie/laravel-package-tools: ^1.16
- symfony/dom-crawler: ^6.4
README
Web Telegram Bot is a Laravel package for create Telegram Bots like Websites. Internal routing, sessions, forms, templates, layouts.
This module allows you to create Telegram bots using Laravel and Telegraph package similar to creating a website.
You can contact me for help.
Installation
You can install the package via composer:
composer require mollsoft/web-telegram-bot php artisan web-telegram-bot:install php artisan migrate
In file app/Providers/RouteServiceProvider.php
add lines in $this->routes(function () {
:
if( is_file(base_path('routes/telegraph.php')) ) { Route::middleware('telegraph') ->name('telegraph.') ->prefix('telegraph') ->group(base_path('routes/telegraph.php')); }
After you need create Telegram Bot using Telegraph instruction.
Commands
Add Telegram Bot
php artisan telegraph:new-bot
Manual polling updates from Telegram Bot:
php artisan telegraph:polling BOT_ID --debug
Manual live updates from Telegram Bot:
php artisan telegraph:live --debug
Views examples
<message> <video src="{{ resource_path("media/logo.mp4") }}" /> <reply-keyboard> <row> <columm>Menu 1</columm> <column>Menu 2</column> </row> <row> <columm>Menu 3</columm> <column>Menu 4</column> </row> </reply-keyboard> </message> <message> <p>Hello! Choice you language</p> <keyboard> <row> <column> <button value="language:en">English</button> </column> </row> <row> <column> <button value="language:ru">Russian</button> </column> </row> <row> <column> <a href="{{ route('contacts') }}">Support</a> </column> </row> </keyboard> </message>
How make 404 page?
Create file resources/views/telegraph/errors/404.blade.php
.
Autoclear dialog
If you want to create a message that will not be permanently deleted, use the
tag instead of the tagExample:
<main> <video src="{{ resource_path("media/logo.mp4") }}" /> <reply-keyboard> <row> <columm>Menu 1</columm> <column>Menu 2</column> </row> <row> <columm>Menu 3</columm> <column>Menu 4</column> </row> </reply-keyboard> </main>