private Message SendMessage(long chatId, string text, long replyTo, ref EchoOptions echoOptions) { Trace.WriteLine(text); if (echoOptions == null) { echoOptions = EchoOptions.SimpleEcho(); } #if ONECHAT_DEBUG text = $"message to chat {chatId}: {text}"; chatId = RealChat; #endif var originalText = text; text = LS.Escape(text); //todo: çäåñü ïðîáëåìà, ïîòîìó ÷òî âåðí¸òñÿ unescaped è ïîòîì îïÿòü áóäåò escape ïðè îáíîâëåíèè EchoOptions options = echoOptions; return(_limiter.RespectLimitForChat(chatId, () => { TelemetryStatic.TelemetryClient.TrackEvent(TelemetryStatic.SendMessageKey, new Dictionary <string, string> { [TelemetryStatic.ToChatKey] = chatId.ToString() }); var result = _api.SendTextMessage(chatId, text, false, false, (int)replyTo, options.ReplyMarkup, ParseMode.Markdown).FromResult2(text); var textProperty = result.GetType().GetProperty("Text"); textProperty.SetValue(result, originalText);//todo: low dirty thing because escaping occure in wrong place return result; })); }
public Echo UpdateEchoText(int messageId, string newText, EchoOptions echoOptions = null) { Trace.WriteLine(newText); var chatId = _chat.Id; #if ONECHAT_DEBUG newText = $"echo update to chat {chatId} {newText}"; chatId = RealChat; #endif newText = LS.Escape(newText); return(_limiter.RespectLimitForChat(chatId, () => { TelemetryStatic.TelemetryClient.TrackEvent(TelemetryStatic.EditMessageKey, new Dictionary <string, string> { [TelemetryStatic.ToChatKey] = chatId.ToString() }); Message result = _api.EditMessageText(chatId, messageId, newText, ParseMode.Markdown, false, echoOptions?.ReplyMarkup).FromResult2(newText); return EchoFromMessage(result, null); })); }