mollsoft/web-telegram-bot

Create Telegram Bots in Laravel similar to creating a website.

v1.0.8 2024-04-08 11:25 UTC

This package is auto-updated.

Last update: 2024-04-08 11:25:21 UTC


README

Pest Laravel Expectations

Latest Version on Packagist Php Version Php Version Total Downloads Website Telegram

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 tag

Example:

<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>