Replies: 8 comments 6 replies
-
Hi, I made it a little dirty way but it works at least. 1st download all repositories that You need then I uploaded all in single folder(in my case "botman") to main laravel folder so in main folder i have: next i added in composer.json for every single repository downloaded this way: Then I replaced some code in every downloaded repository composer.json for example my botman/botman/composer.json (basicly i moved to php 8.1 and removed not used in laravel 9 repositories that was causing problems and finally: You can also make a fork of this repository and do it in simmilar way, for me better was local file based solution - i have repository sourcecode inside my project and i can easly update if needed. |
Beta Was this translation helpful? Give feedback.
-
Install Laravel
Install Botman
Configure Botman
Remember to setup the Telegram token in app\config\telegram.php Add in app\routes\web.phpRoute::any('telegram', [App\Http\Controllers\TelegramController::class, 'index'])->name('telegram'); Ignore CSRF token in app\Http\Middleware\VerifyCsrfToken.php protected $except = [
'/telegram',
]; Create file app\Http\Controllers\TelegramController.php<?php
namespace App\Http\Controllers;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Cache\LaravelCache;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Drivers\Telegram\TelegramContactDriver;
use BotMan\Drivers\Telegram\TelegramDriver;
use BotMan\Drivers\Telegram\TelegramLocationDriver;
use BotMan\Drivers\Telegram\TelegramPhotoDriver;
use Illuminate\Http\Request;
class TelegramController extends Controller
{
public function index(Request $request)
{
DriverManager::loadDriver(TelegramDriver::class);
DriverManager::loadDriver(TelegramPhotoDriver::class);
DriverManager::loadDriver(TelegramLocationDriver::class);
DriverManager::loadDriver(TelegramContactDriver::class);
$config = array_merge([
'config' => config('botman.config')
], [
'web' => config('botman.web', [])
]);
$botman = BotManFactory::create($config, new LaravelCache);
$botman->hears('Hi', function (BotMan $bot) {
$bot->reply('Hello!');
});
$botman->listen();
}
} |
Beta Was this translation helpful? Give feedback.
-
The TelegramController::index() method above is the webhook. |
Beta Was this translation helpful? Give feedback.
-
So I have setup webhook! When I message to bot for example "Hi". The bot doest not answer. In ngrok inspect the request like "419 unknown status" |
Beta Was this translation helpful? Give feedback.
-
Ignore CSRF token in app\Http\Middleware\VerifyCsrfToken.php protected $except = [
'/telegram',
]; |
Beta Was this translation helpful? Give feedback.
-
There is error about Loging laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [deprecations] is not defined. at /vendor/laravel/framework/src/Illuminate/Log/LogManager.php:207) |
Beta Was this translation helpful? Give feedback.
-
and also laravel.WARNING: Return type of BotMan\BotMan\Messages\Outgoing\Question::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/botman/botman/src/Messages/Outgoing/Question.php on line 116 |
Beta Was this translation helpful? Give feedback.
-
laravel.WARNING: strcmp(): Passing null to parameter #2 ($string2) of type string is deprecated in /vendor/botman/driver-telegram/src/TelegramDriver.php on line 163 |
Beta Was this translation helpful? Give feedback.
-
Helow, my name is Oscar Delgado, First of all I would like to thank you for such a good app. I need your help, I can't install botman in Laravel 9, mark error: Problem 1 - botman/botman[2.6.0, ..., 2.6.1] require symfony/http-foundation ^2.8 || ^3.0 || ^4.0 || ^5.0 And I can't find the solution. I would be very grateful if you could help me
Beta Was this translation helpful? Give feedback.
All reactions