core icon indicating copy to clipboard operation
core copied to clipboard

How to set parse_mode for the whole bot

Open iyamk opened this issue 2 years ago • 4 comments

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

iyamk avatar Aug 04 '23 15:08 iyamk

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

Hitmare avatar Aug 06 '23 15:08 Hitmare

@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:

noplanman avatar Aug 13 '23 21:08 noplanman

@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

iyamk avatar Aug 15 '23 23:08 iyamk

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.

m4n50n avatar Feb 19 '24 12:02 m4n50n