private void DownloadUpdates() { try { var updates = _telegramMethods.GetUpdates(LastUpdateId + 1, null, null, AllowedUpdates).Result; if (updates.Count == 0) { return; } updates.ForEach(update => { Update = update; LastUpdateId = update.UpdateId; UpdatesArrivedEvent?.Invoke(this); }); } catch (TelegramMethodsException ex) { var message = "An error occurred while receiving the update"; UpdatesTracingStoppedEvent?.Invoke(this, new BotRequestErrorEventArgs(message, ex)); } finally { DownloadBotRequestsSemaphore.Release(); } }
public void HandleTelegramRequest(string update) { var obj = JsonConvert.DeserializeObject <Update>(update); LastUpdateId = obj.UpdateId; Update = obj; UpdatesArrivedEvent?.Invoke(this); }