/telebot

Easy way to create Telegram-bots in PHP

Primary LanguagePHPMIT LicenseMIT

Project Logo

Latest Stable Version Bot API Version Build Status Coverage Status Code quality Total Downloads License

TeleBot is a PHP library for telegram bots development. Rich Laravel support out of the box. Has an easy, clean, and extendable way to handle telegram Updates.

Documentation

Documentation for the library can be found on the website.

Features

Bot Manager

Work easily with multiple bots using BotManager:

$manager->getMe(); // Fired by default bot specified in BotManager
$manager->bot('bot2')->getMe(); // Fired by `bot2` specified in BotManager

Laravel Support

Library provides a Facade, artisan commands and notification channel to simplify the development process of your bot, if you are using Laravel:

Facade
TeleBot::getMe();
TeleBot::bot('bot2')->getMe(); 
Commands
# Fire command with `--help` flag to get command info
$ php artisan telebot:webhook --help
$ php artisan telebot:polling --help
$ php artisan telebot:commands --help
Notification channel
<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;

class TelegramNotification extends Notification
{
    public function via($notifiable)
    {
        return ['telegram'];
    }

    public function toTelegram($notifiable): array
    {
        return (new TelegramMessage)->bot('bot')->sendMessage([
            'chat_id'   => $notifiable->telegram_chat_id,
            'text'      => 'Hello, from Laravel\'s notifications!'
        ]);
    }
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.