public async Task PublishPageInTelegraph(DownloadedPost post) { try { var result = new List <NodeElement>(); foreach (var paragraph in post.PostContents) { result.Add(paragraph); result.Add(new NodeElement("br", null)); } var operationResult = await _secureClient.CreatePageAsync(post.Title, result.ToArray(), returnContent : true); if (!string.IsNullOrWhiteSpace(operationResult.Path)) { _logger.LogInformation("Post was successfully saved on the API {0}", operationResult.Url); } else { _logger.LogInformation("Post was not saved on the API {0}", post.Title); } } catch (Exception e) { if (e.Message.Contains("FLOOD_WAIT_")) { _logger.LogError("Error while storing in the API {0}, waiting 30 seconds.", e.Message); Thread.Sleep(TimeSpan.FromSeconds(30)); } } }
internal static async Task <string> GetTelegraphPageAsync(Group page, Post post) { List <NodeElement> nodes = new List <NodeElement>(); NodeElement[] layout = PrepareLayout(nodes, page, post); Telegraph.Net.Models.Page newPage = await tokenClient.CreatePageAsync( page.Name, layout, returnContent : true ); return(newPage.Url); }