Code Monkey home page Code Monkey logo

telebot-laravel's Introduction

Project Logo

Latest Stable Version Total Downloads License PHPUnit

TeleBot is a PHP library for telegram bots development. This project is a Laravel adapter for TeleBot

Documentation

Documentation for the library can be found on the website.

Features

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();
Automatic webhook generation

After you insert your bot token, to create a webhook you need only to fire the following command:

$ php artisan telebot:webhook --setup

Route for handling updates is generated automatically for your APP_URL

Long polling

If you are not using webhook, or want to use bot in local or test environment, you may start long polling by only firyng this command:

$ php artisan telebot:polling
Setup commands autocompletion

The following command will automatically setup autocompletion for all registered bot commands on Telegram servers:

$ php artisan telebot:commands --setup
Notification channel
<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use WeStacks\TeleBot\Laravel\TelegramNotification;

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

    public function toTelegram($notifiable)
    {
        return (new TelegramNotification)->bot('bot')
            ->sendMessage([
                'chat_id' => $notifiable->telegram_chat_id,
                'text'    => 'Hello, from Laravel\'s notifications!'
            ])
            ->sendMessage([
                'chat_id' => $notifiable->telegram_chat_id,
                'text'    => 'Second message'
            ]);
    }
}
Log driver

You may log your application errors by sending them to some Telegram chat. Simply add new log driver to a config/logging.php:

'telegram' => [
    'driver'    => 'custom',
    'via'       => \WeStacks\TeleBot\Laravel\Log\TelegramLogger::class,
    'level'     => 'debug',
    'bot'       => 'bot',
    'chat_id'   => env('TELEGRAM_LOG_CHAT_ID') // Any chat where bot can write messages.
]

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.

telebot-laravel's People

Contributors

punyflash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

r4f4dev

telebot-laravel's Issues

[BUG] Configuration of default in AuthorizeWebAppRequest is incorrect

Describe the bug

In Laravel:
If you want to make use of the AuthorizeWebAppRequest, then you need to set in the config telebot.bots.default
But if you set this, then the php artisan telebot:webhook will fail, because it looks like you have 2 bots:
default and bot

But in reality, of course, default is not a bot.

I believe the 'src/Middleware/AuthorizeWebAppRequest.php' requires a change to make use of: config('telebot.default')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.