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 IBotCredentials _creds;
|
||||||
private readonly DateTime _started;
|
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 Author => "Kwoth#2560";
|
||||||
public string Library => "Discord.Net";
|
public string Library => "Discord.Net";
|
||||||
|
@ -22,6 +22,7 @@ using NadekoBot.Common.TypeReaders.Models;
|
|||||||
using NadekoBot.Services.Database;
|
using NadekoBot.Services.Database;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Runtime.Loader;
|
||||||
|
|
||||||
namespace NadekoBot
|
namespace NadekoBot
|
||||||
{
|
{
|
||||||
|
@ -16,10 +16,11 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using AngleSharp;
|
using AngleSharp;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Searches.Services
|
namespace NadekoBot.Modules.Searches.Services
|
||||||
{
|
{
|
||||||
public class SearchesService : INService
|
public class SearchesService : INService, IUnloadableService
|
||||||
{
|
{
|
||||||
public HttpClient Http { get; }
|
public HttpClient Http { get; }
|
||||||
|
|
||||||
@ -41,6 +42,11 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
|
|
||||||
private readonly ConcurrentDictionary<ulong, SearchImageCacher> _imageCacher = new ConcurrentDictionary<ulong, SearchImageCacher>();
|
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>>();
|
private readonly ConcurrentDictionary<ulong, HashSet<string>> _blacklistedTags = new ConcurrentDictionary<ulong, HashSet<string>>();
|
||||||
|
|
||||||
public SearchesService(DiscordSocketClient client, IGoogleApiService google, DbService db, IEnumerable<GuildConfig> gcs)
|
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);
|
var response = await Http.GetStringAsync("http://api.icndb.com/jokes/random/").ConfigureAwait(false);
|
||||||
return JObject.Parse(response)["value"]["joke"].ToString() + " 😆";
|
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
|
public struct UserChannelPair
|
||||||
|
@ -12,7 +12,6 @@ namespace NadekoBot.Modules.Games
|
|||||||
{
|
{
|
||||||
public partial class Games
|
public partial class Games
|
||||||
{
|
{
|
||||||
//todo move games to service, unload
|
|
||||||
[Group]
|
[Group]
|
||||||
public class TriviaCommands : NadekoSubmodule<GamesService>
|
public class TriviaCommands : NadekoSubmodule<GamesService>
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
_db = db;
|
_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)
|
//private Task Client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState oldState, SocketVoiceState newState)
|
||||||
//{
|
//{
|
||||||
// var t = Task.Run(() =>
|
// var t = Task.Run(() =>
|
||||||
|
@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
@ -19,11 +18,6 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
// thanks to halitalf for adding autoboob and autobutt features :D
|
// thanks to halitalf for adding autoboob and autobutt features :D
|
||||||
public class NSFW : NadekoTopLevelModule<SearchesService>
|
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 static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
||||||
|
Loading…
Reference in New Issue
Block a user