mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 10:30:51 +08:00
Revert "fix: escape Telegram Markdown special characters (fix #450)"
This reverts commit 23294c1f93.
This commit is contained in:
@@ -29,9 +29,7 @@ class TelegramService
|
||||
|
||||
public function sendMessage(int $chatId, string $text, string $parseMode = ''): void
|
||||
{
|
||||
if ($parseMode === 'markdown') {
|
||||
$text = $this->escapeMarkdown($text);
|
||||
}
|
||||
$text = $parseMode === 'markdown' ? str_replace('_', '\_', $text) : $text;
|
||||
|
||||
$this->request('sendMessage', [
|
||||
'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
|
||||
{
|
||||
$this->request('approveChatJoinRequest', [
|
||||
|
||||
Reference in New Issue
Block a user