mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-28 06:47:24 +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
|
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', [
|
||||||
|
|||||||
Reference in New Issue
Block a user