From 9a11b0fd7b8a8ff1f42a939487848881cfa8baa5 Mon Sep 17 00:00:00 2001 From: Qstick Date: Thu, 16 Nov 2017 13:37:08 -0500 Subject: [PATCH] Fixed: Telegram notification with underscore and other special characters. --- .../Notifications/Telegram/TelegramService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Telegram/TelegramService.cs b/src/NzbDrone.Core/Notifications/Telegram/TelegramService.cs index d0855ea43..8ab78ff36 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/TelegramService.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/TelegramService.cs @@ -1,5 +1,6 @@ -using System; +using System; using System.Net; +using System.Web; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; @@ -28,13 +29,13 @@ namespace NzbDrone.Core.Notifications.Telegram public void SendNotification(string title, string message, TelegramSettings settings) { //Format text to add the title before and bold using markdown - var text = $"*{title}*\n{message}"; + var text = $"{HttpUtility.HtmlEncode(title)}\n{HttpUtility.HtmlEncode(message)}"; var client = RestClientFactory.BuildClient(URL); var request = new RestRequest("bot{token}/sendmessage", Method.POST); request.AddUrlSegment("token", settings.BotToken); request.AddParameter("chat_id", settings.ChatId); - request.AddParameter("parse_mode", "Markdown"); + request.AddParameter("parse_mode", "HTML"); request.AddParameter("text", text); client.ExecuteAndValidate(request);