From 9faaeef68f68dfc410d0312edf4626871b107e22 Mon Sep 17 00:00:00 2001 From: Chris Plaatjes Date: Tue, 14 Feb 2023 14:48:47 -0500 Subject: [PATCH] Added try catch for URL parsing --- TelegramListener.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/TelegramListener.cs b/TelegramListener.cs index 3fb63f2..1c90eed 100644 --- a/TelegramListener.cs +++ b/TelegramListener.cs @@ -55,15 +55,22 @@ namespace TeleTok // Passes the url along to the video downloader if it is valid AND a tiktok link if (isUri) { - if(messageText.Contains("tiktok.com")) + try { - proxyUrl = VidDownload.TikTokURL(messageText); + if(messageText.Contains("tiktok.com")) + { + proxyUrl = VidDownload.TikTokURL(messageText); - Message ttVideo = await botClient.SendVideoAsync( - chatId: chatId, - video: proxyUrl, - cancellationToken: cancellationToken - ); + Message ttVideo = await botClient.SendVideoAsync( + chatId: chatId, + video: proxyUrl, + cancellationToken: cancellationToken + ); + } + } + catch + { + Console.WriteLine("Valid TikTok URI was sent, but was not a video!"); } } }