Revert "fix: escape Telegram Markdown special characters (fix #450)"

This reverts commit 23294c1f93.
This commit is contained in:
xboard
2026-03-29 17:48:49 +08:00
parent 76a800ddbb
commit 3744ebcd5a
+1 -23
View File
@@ -29,9 +29,7 @@ class TelegramService
public function sendMessage(int $chatId, string $text, string $parseMode = ''): void public function sendMessage(int $chatId, string $text, string $parseMode = ''): void
{ {
if ($parseMode === 'markdown') { $text = $parseMode === 'markdown' ? str_replace('_', '\_', $text) : $text;
$text = $this->escapeMarkdown($text);
}
$this->request('sendMessage', [ $this->request('sendMessage', [
'chat_id' => $chatId, 'chat_id' => $chatId,
@@ -40,26 +38,6 @@ class TelegramService
]); ]);
} }
/**
* 转义 Telegram Markdown 特殊字符
*/
protected function escapeMarkdown(string $text): string
{
$escapeChars = ['_', '*', '`', '['];
$escapedText = '';
for ($i = 0; $i < strlen($text); $i++) {
$char = $text[$i];
if (in_array($char, $escapeChars, true)) {
$escapedText .= '\\' . $char;
} else {
$escapedText .= $char;
}
}
return $escapedText;
}
public function approveChatJoinRequest(int $chatId, int $userId): void public function approveChatJoinRequest(int $chatId, int $userId): void
{ {
$this->request('approveChatJoinRequest', [ $this->request('approveChatJoinRequest', [