php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.79k stars 949 forks source link

How to set parse_mode for the whole bot #1411

Open iyamk opened 10 months ago

iyamk commented 10 months ago

I don't see a setting for parse_mode, I need to switch to html. But it seems that the code is hardcoded in all files is markdown

Hitmare commented 10 months ago

Hello

You can set the parse_mode when sending a message

A function to set the parse_mode bot wide hasn't been implemented yet

noplanman commented 9 months ago

@iyamk The parse mode is only hardcoded for system commands, which shouldn't interfere.

You could write yourself a little helper class that does any parse_mode setting for you.

Feel free to suggest a way to do this, then you can create a PR for it :blush:

iyamk commented 9 months ago

@iyamk The parse mode is only hardcoded for system commands, which shouldn't interfere.

You could write yourself a little helper class that does any parse_mode setting for you.

Feel free to suggest a way to do this, then you can create a PR for it blush

There are two options: $this->replyToChat and Request::sendMessage It's not clear how to extend the class and replace replyToChat, I didn't even find replyToChat in the source code I decided to install everywhere manually

m4n50n commented 3 months ago

Hi @iyamk, I wasn't sure how to handle parse_mode either, so I decided to take a look at all the classes. It would look something like this:

TelegramBotRequest::sendToActiveChats( 'sendMessage', // Callback function to execute (see Request.php methods) ['text' => $messageToSend, "parse_mode" => "HTML"], [ 'groups' => false, 'supergroups' => false, 'channels' => false, 'users' => true, ] );

Hopefully it will help you.