Started fix on imdb, fixed message repeater
This commit is contained in:
		@@ -46,12 +46,15 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                {
 | 
			
		||||
                    source = new CancellationTokenSource();
 | 
			
		||||
                    token = source.Token;
 | 
			
		||||
                    IUserMessage oldMsg = null;
 | 
			
		||||
                    try
 | 
			
		||||
                    {
 | 
			
		||||
                        while (!token.IsCancellationRequested)
 | 
			
		||||
                        {
 | 
			
		||||
                            await Task.Delay(Repeater.Interval, token).ConfigureAwait(false);
 | 
			
		||||
                            try { await Channel.SendMessageAsync("🔄 " + Repeater.Message).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); try { source.Cancel(); } catch { } }
 | 
			
		||||
                            if (oldMsg != null)
 | 
			
		||||
                                try { await oldMsg.DeleteAsync(); } catch { }
 | 
			
		||||
                            try { oldMsg = await Channel.SendMessageAsync("🔄 " + Repeater.Message).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); try { source.Cancel(); } catch { } }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    catch (OperationCanceledException) { }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
using NadekoBot.Modules.Searches.Models;
 | 
			
		||||
using NadekoBot.Extensions;
 | 
			
		||||
using NadekoBot.Modules.Searches.Models;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
@@ -71,7 +72,7 @@ namespace NadekoBot.Modules.Searches.IMDB
 | 
			
		||||
                mov.Status = true;
 | 
			
		||||
                mov.Title = Match(@"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
 | 
			
		||||
                mov.OriginalTitle = Match(@"title-extra"">(.*?)<", html);
 | 
			
		||||
                mov.Year = Match(@"<title>.*?\(.*?(\d{4}).*?).*?</title>", Match(@"(<title>.*?</title>)", html));
 | 
			
		||||
                mov.Year = Match(@"<title>.*?\(.*?(\d{4}).*?\).*?</title>", Match(@"(<title>.*?</title>)", html));
 | 
			
		||||
                mov.Rating = Match(@"<b>(\d.\d)/10</b>", html);
 | 
			
		||||
                mov.Genres = MatchAll(@"<a.*?>(.*?)</a>", Match(@"Genre.?:(.*?)(</div>|See more)", html)).Cast<string>().ToList();
 | 
			
		||||
                mov.Plot = Match(@"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
 | 
			
		||||
@@ -146,7 +147,7 @@ namespace NadekoBot.Modules.Searches.IMDB
 | 
			
		||||
        //Match single instance
 | 
			
		||||
        private static string Match(string regex, string html, int i = 1)
 | 
			
		||||
        {
 | 
			
		||||
            return new Regex(regex, RegexOptions.Multiline).Match(html).Groups[i].Value.Trim();
 | 
			
		||||
            return new Regex(regex, RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(html).Groups[i].ToString().Trim();
 | 
			
		||||
        }
 | 
			
		||||
        //Match all instances and return as List<string>
 | 
			
		||||
        private static List<string> MatchAll(string regex, string html, int i = 1)
 | 
			
		||||
@@ -162,12 +163,12 @@ namespace NadekoBot.Modules.Searches.IMDB
 | 
			
		||||
            return Regex.Replace(inputString, @"<.*?>", string.Empty);
 | 
			
		||||
        }
 | 
			
		||||
        //Get URL Data
 | 
			
		||||
        private static Task<string> GetUrlDataAsync(string url)
 | 
			
		||||
        private static async Task<string> GetUrlDataAsync(string url)
 | 
			
		||||
        {
 | 
			
		||||
            using (var http = new HttpClient())
 | 
			
		||||
            {
 | 
			
		||||
                http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
 | 
			
		||||
                return http.GetStringAsync(url);
 | 
			
		||||
                http.AddFakeHeaders();
 | 
			
		||||
                return await http.GetStringAsync(url);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -81,9 +81,10 @@ $@"🌍 **Weather for** 【{obj["target"]}】
 | 
			
		||||
                if (movie.Status) result = movie.ToString();
 | 
			
		||||
                else result = "Failed to find that movie.";
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                await channel.SendMessageAsync("Failed to find that movie.").ConfigureAwait(false);
 | 
			
		||||
                _log.Warn(ex);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user