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(int id, string text, ApiChat apiChat, EchoOptions echoOptions) { _apiChat = apiChat; _echoOptions = echoOptions; _id = id; Text = text; }
public Echo Echo(string str, long?replyTo = null, EchoOptions echoOptions = null) { string format; try { format = string.Format(str, _stack.Cast <object>().ToArray()); } catch (FormatException exception) { throw new FormatException("Seems stack misses values", exception); } return(_apiChat.Echo(format, replyTo ?? 0, echoOptions)); }
public Echo UpdateEchoInlineButtons(int messageId, EchoOptions echoOptions) { // ReSharper disable once JoinDeclarationAndInitializer long chatId; #if ONECHAT_DEBUG chatId = RealChat; #else chatId = _chat.Id; #endif TelemetryStatic.TelemetryClient.TrackEvent(TelemetryStatic.EditInlineKey, new Dictionary <string, string> { [TelemetryStatic.ToChatKey] = chatId.ToString() }); var result = _api.EditMessageReplyMarkup(chatId, messageId, echoOptions.ReplyMarkup).FromResult2(); return(EchoFromMessage(result, echoOptions)); }
public void ReplyEcho(string str, EchoOptions echoOptions = null) { switch (Update.Type) { case UpdateType.MessageUpdate: Echo(str, Update.Message.MessageId, echoOptions); break; case UpdateType.CallbackQueryUpdate: _apiChat.ReplyQuery(str, Update.CallbackQuery.Id); //Update.CallbackQuery.Id break; default: throw new InvalidOperationException("Message you are trying to reply to unsupported message"); } }
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); })); }
public Echo Update(EchoOptions echoInlineButtons) { _echoOptions = echoInlineButtons; return(_apiChat.UpdateEchoInlineButtons(Id, echoInlineButtons)); }
private Echo EchoFromMessage(Message result, EchoOptions echoOptions) { return(new Echo(result.MessageId, result.Text, this, echoOptions)); }
public Echo Echo(string text, long replyTo, EchoOptions echoOptions) { var result = SendMessage(_chat.Id, text, replyTo, ref echoOptions); return(EchoFromMessage(result, echoOptions)); }
public Echo PrivateEcho(long userId, string text, EchoOptions echoOptions = null) { var message = SendMessage(userId, text, 0, ref echoOptions); return(EchoFromMessage(message, echoOptions)); }