Skip to content

Commit

Permalink
waifu meter added, fixed compiler warnings
Browse files Browse the repository at this point in the history
removed the deploy badge because let's be honest
i deploy this like twice a year now
  • Loading branch information
chamik committed Jan 14, 2024
1 parent d02d416 commit 521f025
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
22 changes: 13 additions & 9 deletions thorn/Jobs/RssJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +16,6 @@
using Newtonsoft.Json;
using Quartz;
using thorn.Config;
using thorn.Services;

namespace thorn.Jobs;

Expand All @@ -24,7 +24,7 @@ public class RssJob : IJob
private readonly ILogger<ReminderJob> _logger;
private readonly List<FeedConfig> _configs;
private readonly Dictionary<ulong, SocketTextChannel> _channels;
private readonly WebClient _webClient;
private readonly HttpClient _webClient;
private readonly DiscordSocketClient _client;
private Dictionary<FeedConfig, DateTime?> _lastUpdates;

Expand All @@ -34,7 +34,7 @@ public RssJob(ILogger<ReminderJob> logger, DiscordSocketClient client)
_client = client;
_channels = new Dictionary<ulong, SocketTextChannel>();
_lastUpdates = new Dictionary<FeedConfig, DateTime?>();
_webClient = new WebClient();
_webClient = new HttpClient();

_configs = JsonConvert.DeserializeObject<List<FeedConfig>>(File.ReadAllText("Config/feeds.json"));

Expand Down Expand Up @@ -76,13 +76,17 @@ private async Task<List<FeedItem>> 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<FeedItem>();
// don't @ me

var lastUpdate = _lastUpdates[feedConfig];

Expand Down
25 changes: 23 additions & 2 deletions thorn/Services/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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!! ";
}
}
3 changes: 0 additions & 3 deletions thorn/thorn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" />
<PackageReference Include="Discord.Addons.Hosting" Version="5.2.0" />
<PackageReference Include="Discord.Addons.Preconditions" Version="2.2.0-dev3" />
<PackageReference Include="Discord.Net" Version="3.4.1" />

<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="4.0.2" />
<PackageReference Include="Discord.Net" Version="3.9.0" />
<PackageReference Include="GraphQL.Client" Version="6.0.0" />
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="5.1.1" />
Expand Down

0 comments on commit 521f025

Please sign in to comment.