public static void SendPreviewWall(Chat chat, int id, string category)
        {
            Bot.Methods.SendChatAction(chat, "upload_photo");
            Task.Factory.StartNew(delegate
            {
                var filename = _cacheDirectory + "s_" + id + ".jpg";
                var readyId = '_' + category.ToLower() + '_' +
                              Path.GetFileName(filename).Replace(".jpg", "").Replace("s_", "");
                if (!File.Exists(filename))
                {
                    var uri = $"http://hao.newtabplus.com/cloudWallpaper/{category}/s_{id}.jpg";
                    try
                    {
                        var wc = new WebClient();
                        wc.DownloadFile(uri, filename);
                    }
                    catch (WebException exc)
                    {
                        var errorResponse = exc.Response as HttpWebResponse;
                        if (errorResponse == null) return;
                        switch (errorResponse.StatusCode)
                        {
                            case HttpStatusCode.NotFound:
                                Bot.Methods.SendMessage(chat, "⚠️ This wallpaper not found.");
                                break;
                            default:
                                Bot.Methods.SendMessage(chat, "⚠️ Error, when get image. Try again in 5 seconds:\n"
                                                              + "/fullsize" + readyId);
                                break;
                        }
                        return;
                    }
                }
                var fileInfo = new FileInfo(filename);
                if (IsFileLocked(fileInfo))
                {
                    Bot.Methods.SendMessage(chat, "Please wait...");
                    while (IsFileLocked(fileInfo))
                    {
                        Thread.Sleep(1000);
                    }
                }
                // + "\n/wallpaper_" + category.ToLower() + " - next wallpaper from this category",
                var markup = new ReplyKeyboardMarkup()
                {
                    Keyboard = new[]
                    {
                        new[] {$"/wallpaper_{category.ToLower()}"},
                        new[] {$"/fullsize{readyId}"},
                        new[] { "🔠 Menu", "✌️ Ok, it's all" }
                    },
                    ResizeKeyboard = true,
                    OneTimeKeyboard = false
                };
                Bot.Methods.SendPhotoFile(chat, filename, $"/fullsize{readyId}", markup);

                GC.Collect();
            });
        }
 public override void Executed(Message message)
 {
     var markup = new ReplyKeyboardMarkup()
     {
         Keyboard = new[]
         {
             new [] {"/wallpaper_cartoon", "/wallpaper_classic"},
             new [] {"/wallpaper_scenery", "/wallpaper_movies"},
             new [] {"/wallpaper_games", "/wallpaper_sports"},
             new [] {"/wallpaper_holiday", "/wallpaper_beauty"},
             new [] {"/help"}
         },
         ResizeKeyboard = true
     };
     Bot.Methods.SendMessage(message.Chat, "Hello, i'm wallpaper bot.\n" +
                                           "I'll send randow wallpapers for these commands:\n" +
                                           "👻 /wallpaper_cartoon - favorite cartoons 😋\n" +
                                           "🎠 /wallpaper_classic\n" +
                                           "🗻 /wallpaper_scenery - Natural\n" +
                                           "📺 /wallpaper_movies\n" +
                                           "🎮 /wallpaper_games - Gamessssss*BOOM*👾\n" +
                                           "🏆 /wallpaper_sports\n" +
                                           "🎉 /wallpaper_holiday\n" +
                                           "👀 /wallpaper_beauty\n\n" +
                                           "If you want to get list of wallpapers (no random), visit:\n" +
                                           "🌎 http://www.like5.com/?tgbot", false, markup);
 }
 public static void SendFullWall(Message message, int id, string category)
 {
     var uploadDone = false;
     Task.Factory.StartNew(() =>
     {
         while (!uploadDone)
         {
             Bot.Methods.SendChatAction(message.Chat, "upload_document");
             Thread.Sleep(4999);
         }
     });
     Task.Factory.StartNew(delegate
     {
         var filename = _cacheDirectory + id + ".jpg";
         var readyId = '_' + category.ToLower() + '_' +
                       Path.GetFileName(filename).Replace(".jpg", "");
         if (!File.Exists(filename))
         {
             var uri = $"http://hao.newtabplus.com/cloudWallpaper/{category}/{id}.jpg";
             try
             {
                 var wc = new WebClient();
                 wc.DownloadFile(uri, filename);
             }
             catch (WebException exc)
             {
                 var errorResponse = exc.Response as HttpWebResponse;
                 if (errorResponse == null) return;
                 switch (errorResponse.StatusCode)
                 {
                     case HttpStatusCode.NotFound:
                         Bot.Methods.ReplyToMessage(message, "⚠️ This wallpaper not found.");
                         break;
                     default:
                         Bot.Methods.ReplyToMessage(message, "⚠️ Error, when download image. Try again in 5 seconds:\n"
                                                       + "/fullsize" + readyId);
                         break;
                 }
                 uploadDone = true;
                 return;
             }
         }
         var fileInfo = new FileInfo(filename);
         if (IsFileLocked(fileInfo))
         {
             Bot.Methods.SendMessage(message.Chat, "Please wait...");
             while (IsFileLocked(fileInfo)) { }
         }
         var markup = new ReplyKeyboardMarkup()
         {
             Keyboard = new[]
             {
                 new[] { $"/wallpaper_{category.ToLower()}" },
                 new[] { "🔠 Menu", "✌️ Ok, it's all" }
             },
             ResizeKeyboard = true,
             OneTimeKeyboard = true
         };
         var msg = Bot.Methods.ReplyToMessageWithDocumentFile(message, new FileInfo(filename), markup);
         uploadDone = true;
         if (msg != null)
         {
             Bot.Methods.SendMessage(message.Chat, "💡 If you like this wallpapers visit LIKE5:\nhttp://www.like5.com 😉",
                 true);
         }
         else
         {
             Bot.Methods.SendMessage(message.Chat, "We are sorry, but something went wrong.");
         }
         GC.Collect();
     });
 }