2017 © Pedro Peláez
 

library laravel-telegram-bot

Framework to build Telegram bots

image

pulpa/laravel-telegram-bot

Framework to build Telegram bots

  • Saturday, April 15, 2017
  • by pulpa
  • Repository
  • 0 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Laravel Telegram Bot

This is a work in progress, feel free to watch this repo to stay tuned., (*1)

Requirements

  • Laravel 5.4+

Installation

Install the package with composer:, (*2)

composer require pulpa/laravel-telegram-bot

Add this service provider to your config/app.php file:, (*3)

Pulpa\Telegram\Bot\Providers\ServiceProvider::class

Create a configuration file in config/bot.php and a controller in app\Http\Controllers\BotController.php by running the vendor:publish artisan command:, (*4)

php artisan vendor:publish --provider="Pulpa\Telegram\Bot\Providers\ServiceProvider"

Open config/bot.php and set up your bot's name and token., (*5)

Once you finish your configuration, your bot's webhook URL will be available at:, (*6)

yourdomain.com/<BotToken>

Where <BotToken> is obviously the bot token, duh! Open the URL in your web browser and you should see a friendly message., (*7)

Usage

The method catchAll() within your BotController class will receive all the updates coming from Telegram to your webhook, it will receive a parameter of type Pulpa\Telegram\Bot\Update that is just a simple wrapper of the original update object coming from Telegram., (*8)

use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // Log the text message
        \Log::info($update->message->text);
    }
}

Define methods in your BotController that will handle the incoming bot commands, for example, method myBotCommand will be called when the webhook recieves a command named my_bot_command., (*9)

use App\Chat;
use Pulpa\Telegram\Bot\Update;
use Pulpa\Telegram\Bot\Http\Controllers\Controller;

class BotController extends Controller
{
    public function catchAll(Update $update)
    {
        // ...
    }

    public function start(Update $update)
    {
        // Register a new chat when command "start" is received.
        Chat::register($update->message->chat->id);
    }
}

If no method is defined for a command then the method catchAll() will be called instead., (*10)

More documentation is in progress, (*11)

The Versions

15/04 2017

dev-master

9999999-dev

Framework to build Telegram bots

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pulpa

15/04 2017

0.1.2

0.1.2.0

Framework to build Telegram bots

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pulpa

14/04 2017

0.1.1

0.1.1.0

Framework to build Telegram bots

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pulpa

14/04 2017

0.1.0

0.1.0.0

Framework to build Telegram bots

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar pulpa