diff --git a/thorn/Jobs/RssJob.cs b/thorn/Jobs/RssJob.cs index b455006..213bc41 100644 --- a/thorn/Jobs/RssJob.cs +++ b/thorn/Jobs/RssJob.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Net; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -15,7 +16,6 @@ using Newtonsoft.Json; using Quartz; using thorn.Config; -using thorn.Services; namespace thorn.Jobs; @@ -24,7 +24,7 @@ public class RssJob : IJob private readonly ILogger _logger; private readonly List _configs; private readonly Dictionary _channels; - private readonly WebClient _webClient; + private readonly HttpClient _webClient; private readonly DiscordSocketClient _client; private Dictionary _lastUpdates; @@ -34,7 +34,7 @@ public RssJob(ILogger logger, DiscordSocketClient client) _client = client; _channels = new Dictionary(); _lastUpdates = new Dictionary(); - _webClient = new WebClient(); + _webClient = new HttpClient(); _configs = JsonConvert.DeserializeObject>(File.ReadAllText("Config/feeds.json")); @@ -76,13 +76,17 @@ private async Task> GetNewItems(FeedConfig feedConfig) { feed = await FeedReader.ReadAsync(feedConfig.Link); } + // TODO: I don't have time for a refactor now, but this whole section is broken anyway. Maintenance is in order here. + // else + // { + // // Basic HTTP auth + // _webClient.Credentials = new NetworkCredential(feedConfig.Username, feedConfig.Password); + // var response = _webClient.DownloadString(feedConfig.Link); + // feed = FeedReader.ReadFromString(response); + // } else - { - // Basic HTTP auth - _webClient.Credentials = new NetworkCredential(feedConfig.Username, feedConfig.Password); - var response = _webClient.DownloadString(feedConfig.Link); - feed = FeedReader.ReadFromString(response); - } + return new List(); + // don't @ me var lastUpdate = _lastUpdates[feedConfig]; diff --git a/thorn/Services/CommandHandler.cs b/thorn/Services/CommandHandler.cs index 1539f03..a6bf92d 100644 --- a/thorn/Services/CommandHandler.cs +++ b/thorn/Services/CommandHandler.cs @@ -83,8 +83,11 @@ await m.Channel.SendMessageAsync(_random.Next(2) == 0 else if (Regex.IsMatch(m.Content, @"pls penis")) await m.Channel.SendMessageAsync(GeneratePenis(m.Author)); - else if (Regex.IsMatch(m.Content, @":3")) - await m.Channel.SendMessageAsync(":33"); + else if (Regex.IsMatch(m.Content, @":3")) + await m.Channel.SendMessageAsync(":33"); + + else if (Regex.IsMatch(m.Content, @"how waifu[\?]?", RegexOptions.IgnoreCase)) + await m.Channel.SendMessageAsync(HowWaifu(m.Author)); else return false; return true; @@ -95,4 +98,22 @@ private string GeneratePenis(SocketUser usr) var len = _random.Next(15); return $"{usr.Mention} tvůj pele: `8{new string('=', len)}D`"; } + + private string HowWaifu(SocketUser usr) + { + var p = _random.Next(101); + + if (p == 0) + return $"Jsi druhý příchod kristova vědomí (0% waifu) \\o/"; + if (p < 15) + return $"Nic moc kamaráde, dnes jsi jen {p}% waifu :("; + else if (p < 50) + return $"Ujde to příteli! Jsi z {p}% waifu."; + else if (p < 80) + return $"Sluší ti to :) jsi {p} procentní waifu!"; + else if (p < 100) + return $"Neuvěřitelné! Jsi waifu ze skvělých {p}% :D"; + else + return $"Páni! Jsi úplný waifu materiál!! "; + } } diff --git a/thorn/thorn.csproj b/thorn/thorn.csproj index e1adc9b..397a516 100644 --- a/thorn/thorn.csproj +++ b/thorn/thorn.csproj @@ -9,9 +9,6 @@ - - -