php-telegram-bot / laravel

Laravel package for PHP Telegram Bot Library
Other
168 stars 50 forks source link

Can we have example into the line too.. #1

Closed ranrinc closed 4 years ago

ranrinc commented 6 years ago

Hi there,

Will support this project, however wondering how can I implement the commands etc..Maybe we can have example too for the laravel program.

Need to get more info on where we need to add TOKENBOT etc...

Thanks..

ranrinc commented 6 years ago

Hi there,

Is there away to get example? so at least I can begin testing it?

akalongman commented 6 years ago

@ranrinc we will write documentation soon, but now you can just install it and call in the controller needed methods:

<?php
namespace App\Http\Controllers;

use PhpTelegramBot\Laravel\PhpTelegramBotContract;

class CustomController extends Controller
{
    public function handle(PhpTelegramBotContract $telegram_bot)
    {
        // Call handle method
        $telegram_bot->handle();
    }

    public function setWebhook(PhpTelegramBotContract $telegram_bot)
    {
        // Set webhook 
        $telegram_bot->setWebhook($hook_url);
    }

}
ranrinc commented 6 years ago

Where should i put that script? And how to called it? I need the commands.. where should i put it and how to begin called it too? Still confuse with laravel at the moment.. help?

akalongman commented 6 years ago

@ranrinc you are a beginner in Laravel? You should create controller, e.g. TelegramController and put the code above in the controller. Also, create routes for your controller methods. If you want custom commands, create the folder Telegram/Commands and put your commands inside and specify commands path in the telegram bot config, like 'path' => app_path('Telegram/Commands')

ranrinc commented 6 years ago

Kind of laravel beginner.. ... will try... got it about telegram controller.. still confused on making the commands though.. cause i cant see relation in making a call /help from the telegram and trigger the HelpCommands...in laravel so far... maybe another hints? Sorry..

akalongman commented 6 years ago

You have to set up webhook as described here and specify your Laravel's handle url

ranrinc commented 6 years ago

So i need to create hook and set?? Again so sorry.. i have been confused for a long time for this and hoping to learn it from this fork..I hope you dont mind to teach nubie

akalongman commented 6 years ago

So i need to create hook and set??

Yes

ranrinc commented 6 years ago

Do u mind helping me for hook.php and where should i put it on?

akalongman commented 5 years ago

@ranrinc you should put hook.php under public folder

nullcookies commented 4 years ago

Using laravel, do you need to install hook on CustomController?