botman / driver-telegram

BotMan Telegram Driver
MIT License
87 stars 75 forks source link

Can't sendRequest with custom chat_id #36

Closed decadence closed 5 years ago

decadence commented 6 years ago

Let's say I want sendRequest with custom chat_id like this without hears method:

$bot->sendRequest("pinChatMessage", [
        "chat_id" => $chatId,
        "message_id" => $messageId,
]);

This is not going to work because sendRequest always replaces my chat_id with Message.

$parameters = array_replace_recursive([
    'chat_id' => $matchingMessage->getRecipient(),
], $parameters);

In case we are not in hears method it will be null so nothing works. Can you provide a way to pass custom chat_id?

decadence commented 6 years ago

Ok, I forgot how array_replace_recursive works. So my chat_id will have priority. But there is another problem: we have to load driver manually (like say method does):

$bot->setDriver(DriverManager::loadFromName(TelegramDriver::class, $config));

$bot->sendRequest("pinChatMessage", [
  "chat_id" => $chatId,
  "message_id" => 40,
]);

Can you loadDriver inside sendRequest like in say method? Because by default it's NullDriver which does nothing and it was hard to debug.

kubk commented 6 years ago

You can call loadDriver in your bootstrap file. From the docs:

DriverManager::loadDriver(\BotMan\Drivers\Telegram\TelegramDriver::class);

// Create BotMan instance
BotManFactory::create($config);

https://botman.io/2.0/driver-telegram

decadence commented 6 years ago

It's different thing. You have to setDriver even if you loadDriver before (say method does it for example). Without loadDriver nothing is going to work at all.

dondap commented 5 years ago

anyone found a solution to this?