Giter Site home page Giter Site logo

telegram-bot's Introduction

telegram-bot

Будет бот для Telegram.

###Настройки:

Publishing Configs: php artisan vendor:publish --tag=config

In config/app.php add TelegramBot\Laravel\TelegramBotServiceProvider::class to 'providers' array In In config/app.php add 'TelegramBot' => TelegramBot\Laravel\Facades\TelegramBot::class to 'aliases' array

To get Updates with Webhook installed in Laravel

  • Cancel the csrf token check for the bot. In app/Http/Middleware/VerifyCsrfToken.php in the property $ except enter your token
    protected $except = [
        '000000000:*', // Or full
        '000000000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    ];
  • In order for your bot to receive Updates from the Telegram server, you need to specify the route to the getWebhookUpdates bot method.
Route::post('<bot_token>', function () {
   $updates = TelegramBot::getWebhookUpdates();

   return 'ok';
});

Пример использования

Standalone:

Laravel:

Set Webhook:

$setWebhook = TelegramBot::setWebhook([
    'url' => 'https://your.domain/BOT_TOKEN',
    'certificate'=> 'ssl/ssl.pem'
]);
// See result
var_dump($setWebhook);

Get webhook info:

$webhookInfo = TelegramBot::getWebhookInfo();

var_dump($webhookInfo->getResult());

Send message:

$firstMessage = TelegramBot::sendMessage([
    'chat_id'=> env('TELEGRAM_TEST_CHAT_ID'),
    'text' => 'Hello World!'
]);

var_dump($firstMessage->getResult());

telegram-bot's People

Contributors

tauweb avatar

Watchers

 avatar  avatar

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.