Skip to content

tohaosipow/telegram-common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Common for Laravel

How to install

   composer require antonosipov/telegram-common
 php artisan vendor:publish --provider="Antonosipov\TelegramCommon\Providers\TelegramCommonServiceProvider"

Add to .env

  TELEGRAM_TOKEN=<token_here>

or change env variable in config/telegram-common.php

Config

You can get telegram entities from Request easy, example echo-bot:

namespace App\Http\Controllers;

use Antonosipov\TelegramCommon\Message;
use Antonosipov\TelegramCommon\TelegramService;
use Illuminate\Http\Request;

class TelegramHookController extends Controller
{


    public function __construct(protected TelegramService $telegramService)
    {
    }

    public function hook(Request $request)
    {
        $message = Message::fromRequest($request);
        if($message){
            $this->telegramService->sendMessage($message->getChat()->getId(), $message->getText());
        }

    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages