mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 01:27:00 +00:00
Fixed: Telegram notification with underscore and other special characters.
This commit is contained in:
parent
26935bd82f
commit
9a11b0fd7b
1 changed files with 4 additions and 3 deletions
|
@ -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 @@ public TelegramProxy(Logger logger)
|
|||
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 = $"<b>{HttpUtility.HtmlEncode(title)}</b>\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);
|
||||
|
|
Loading…
Reference in a new issue