Added some more unloads, upped version to 2.0
This commit is contained in:
@ -16,10 +16,11 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using AngleSharp;
|
||||
using System.Threading;
|
||||
|
||||
namespace NadekoBot.Modules.Searches.Services
|
||||
{
|
||||
public class SearchesService : INService
|
||||
public class SearchesService : INService, IUnloadableService
|
||||
{
|
||||
public HttpClient Http { get; }
|
||||
|
||||
@ -41,6 +42,11 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
|
||||
private readonly ConcurrentDictionary<ulong, SearchImageCacher> _imageCacher = new ConcurrentDictionary<ulong, SearchImageCacher>();
|
||||
|
||||
//todo clear when module unloaded
|
||||
public ConcurrentDictionary<ulong, Timer> _autoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||
public ConcurrentDictionary<ulong, Timer> _autoBoobTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||
public ConcurrentDictionary<ulong, Timer> _autoButtTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||
|
||||
private readonly ConcurrentDictionary<ulong, HashSet<string>> _blacklistedTags = new ConcurrentDictionary<ulong, HashSet<string>>();
|
||||
|
||||
public SearchesService(DiscordSocketClient client, IGoogleApiService google, DbService db, IEnumerable<GuildConfig> gcs)
|
||||
@ -222,6 +228,19 @@ namespace NadekoBot.Modules.Searches.Services
|
||||
var response = await Http.GetStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
|
||||
return JObject.Parse(response)["value"]["joke"].ToString() + " 😆";
|
||||
}
|
||||
|
||||
public Task Unload()
|
||||
{
|
||||
_autoBoobTimers.ForEach(x => x.Value.Change(Timeout.Infinite, Timeout.Infinite));
|
||||
_autoBoobTimers.Clear();
|
||||
_autoButtTimers.ForEach(x => x.Value.Change(Timeout.Infinite, Timeout.Infinite));
|
||||
_autoButtTimers.Clear();
|
||||
_autoHentaiTimers.ForEach(x => x.Value.Change(Timeout.Infinite, Timeout.Infinite));
|
||||
_autoHentaiTimers.Clear();
|
||||
|
||||
_imageCacher.Clear();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public struct UserChannelPair
|
||||
|
Reference in New Issue
Block a user