Skip to content

Commit 0ab3c5b

Browse files
committed
Update to .NET 5. Update packages. Remove APIs / scrapes that no longer work.
1 parent 9cfcd1a commit 0ab3c5b

6 files changed

+80
-727
lines changed

DiscordProtocol.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public override async Task<bool> Start()
3333
bot.MessageReceived += MessageReceived;
3434

3535
// Log in and start bot
36-
await bot.LoginAsync(TokenType.Bot, config.Keys.DiscordToken);
37-
await bot.StartAsync();
36+
await bot.LoginAsync(TokenType.Bot, config.Keys.DiscordToken).ConfigureAwait(false);
37+
await bot.StartAsync().ConfigureAwait(false);
3838

3939
// Wait forever
40-
await Task.Delay(-1);
40+
await Task.Delay(-1).ConfigureAwait(false);
4141
return true;
4242
}
4343

@@ -52,11 +52,11 @@ public async void OnTimerTick(object configObject)
5252
var writeConfig = false;
5353
for (var thisRss = 0; thisRss < config.Rss.Length; thisRss++)
5454
{
55-
if (config.Rss[thisRss].Protocol.ToUpperInvariant() == "DISCORD")
55+
if (string.Equals(config.Rss[thisRss].Protocol, "DISCORD", StringComparison.InvariantCultureIgnoreCase))
5656
{
5757
var newMostRecent = config.Rss[thisRss].MostRecent;
5858
var numFound = 0;
59-
if (config.Rss[thisRss].Format.ToUpperInvariant() == "RSS")
59+
if (string.Equals(config.Rss[thisRss].Format, "RSS", StringComparison.InvariantCultureIgnoreCase))
6060
{
6161
// Parse RSS Format
6262
try
@@ -90,13 +90,13 @@ public async void OnTimerTick(object configObject)
9090
}
9191
catch
9292
{
93-
try
93+
try
9494
{
9595
// Try RFC822 with 2 and 4 digit year
9696
var formats = new string[] {"ddd, dd MMM yyyy HH:mm:ss zzzzz", "ddd, dd MMM yy HH:mm:ss zzzzz", "ddd, dd MMM yyyy HH:mm:ss zzzz", "ddd, dd MMM yy HH:mm:ss zzzz"};
9797
rssItem.PubDate = DateTime.ParseExact(dateString, formats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
9898
}
99-
catch
99+
catch
100100
{
101101
// Everything failed. Give up.
102102
rssItem.PubDate = config.Rss[thisRss].MostRecent;
@@ -170,7 +170,7 @@ public async void OnTimerTick(object configObject)
170170
// Save Config
171171
if (writeConfig)
172172
{
173-
await System.IO.File.WriteAllTextAsync("config.json", JsonConvert.SerializeObject(config, Formatting.Indented));
173+
await System.IO.File.WriteAllTextAsync("config.json", JsonConvert.SerializeObject(config, Formatting.Indented)).ConfigureAwait(false);
174174
}
175175
}
176176

ProHttpClient.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ProHttpClient()
2626
public string BingHeader { get; set; }
2727

2828
public string ReferrerUri { get; set; }
29-
29+
3030
public Dictionary<string,string> CustomHeaders {get; set;}
3131

3232
public void AddHeader (string name, string value) {
@@ -38,7 +38,7 @@ public async Task<string> DownloadString(string uri)
3838
{
3939
BuildHeaders();
4040
try{
41-
var response = await GetStringAsync(uri);
41+
var response = await GetStringAsync(uri).ConfigureAwait(false);
4242
return response;
4343
}
4444
catch (System.Net.Http.HttpRequestException ex){
@@ -54,7 +54,7 @@ public async Task<Stream> DownloadData(string uri)
5454
{
5555
BuildHeaders();
5656
try{
57-
var response = await GetStreamAsync(uri);
57+
var response = await GetStreamAsync(uri).ConfigureAwait(false);
5858
return response;
5959
}
6060
catch (System.Net.Http.HttpRequestException ex){
@@ -66,9 +66,9 @@ public async Task<Stream> DownloadData(string uri)
6666
}
6767
}
6868

69-
void BuildHeaders()
69+
private void BuildHeaders()
7070
{
71-
if(ReferrerUri != string.Empty)
71+
if(ReferrerUri != string.Empty)
7272
{
7373
DefaultRequestHeaders.Referrer = new Uri(ReferrerUri);
7474
}
@@ -86,7 +86,7 @@ void BuildHeaders()
8686
}
8787
}
8888

89-
void CleanHeaders()
89+
private void CleanHeaders()
9090
{
9191
ReferrerUri = "https://duckduckgo.com";
9292
AuthorizationHeader = string.Empty;

0 commit comments

Comments
 (0)