Added some more unloads, upped version to 2.0
This commit is contained in:
parent
33ac43e1b5
commit
72f36270dc
@ -20,7 +20,7 @@ namespace NadekoBot.Services.Impl
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly DateTime _started;
|
||||
|
||||
public const string BotVersion = "1.10.2";
|
||||
public const string BotVersion = "2.0.0-alpha";
|
||||
|
||||
public string Author => "Kwoth#2560";
|
||||
public string Library => "Discord.Net";
|
||||
|
@ -22,6 +22,7 @@ using NadekoBot.Common.TypeReaders.Models;
|
||||
using NadekoBot.Services.Database;
|
||||
using StackExchange.Redis;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Loader;
|
||||
|
||||
namespace NadekoBot
|
||||
{
|
||||
@ -418,7 +419,7 @@ namespace NadekoBot
|
||||
{
|
||||
if (_packageModules.ContainsKey(name))
|
||||
return false;
|
||||
|
||||
|
||||
var package = Assembly.LoadFile(Path.Combine(AppContext.BaseDirectory,
|
||||
"modules",
|
||||
$"NadekoBot.Modules.{name}",
|
||||
|
@ -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
|
||||
|
@ -12,7 +12,6 @@ namespace NadekoBot.Modules.Games
|
||||
{
|
||||
public partial class Games
|
||||
{
|
||||
//todo move games to service, unload
|
||||
[Group]
|
||||
public class TriviaCommands : NadekoSubmodule<GamesService>
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Music
|
||||
_db = db;
|
||||
}
|
||||
|
||||
//todo changing server region is bugged again
|
||||
//todo 50 changing server region is bugged again
|
||||
//private Task Client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState oldState, SocketVoiceState newState)
|
||||
//{
|
||||
// var t = Task.Run(() =>
|
||||
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Extensions;
|
||||
using System.Threading;
|
||||
using System.Collections.Concurrent;
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Common.Attributes;
|
||||
using NadekoBot.Common.Collections;
|
||||
@ -19,11 +18,6 @@ namespace NadekoBot.Modules.NSFW
|
||||
// thanks to halitalf for adding autoboob and autobutt features :D
|
||||
public class NSFW : NadekoTopLevelModule<SearchesService>
|
||||
{
|
||||
//todo clear when module unloaded
|
||||
private static readonly ConcurrentDictionary<ulong, Timer> _autoHentaiTimers = new ConcurrentDictionary<ulong, Timer>();
|
||||
private static readonly ConcurrentDictionary<ulong, Timer> _autoBoobTimers = new ConcurrentDictionary<ulong, Timer>();
|
||||
private static readonly ConcurrentDictionary<ulong, Timer> _autoButtTimers = new ConcurrentDictionary<ulong, Timer>();
|
||||
|
||||
private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new ConcurrentHashSet<ulong>();
|
||||
|
||||
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
||||
|
Loading…
Reference in New Issue
Block a user