slight cleanup
This commit is contained in:
parent
263a95a6ad
commit
bf7585cd83
@ -22,18 +22,15 @@ namespace NadekoBot.Modules.Utility.Common
|
|||||||
private IUserMessage oldMsg = null;
|
private IUserMessage oldMsg = null;
|
||||||
private Timer _t;
|
private Timer _t;
|
||||||
|
|
||||||
public RepeatRunner(DiscordSocketClient client, Repeater repeater)
|
public RepeatRunner(DiscordSocketClient client, SocketGuild guild, Repeater repeater)
|
||||||
{
|
{
|
||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
Repeater = repeater;
|
Repeater = repeater;
|
||||||
|
Guild = guild;
|
||||||
//todo 40 @.@ fix all of this
|
|
||||||
Guild = client.GetGuild(repeater.GuildId);
|
|
||||||
|
|
||||||
InitialInterval = Repeater.Interval;
|
InitialInterval = Repeater.Interval;
|
||||||
|
|
||||||
if (Guild != null)
|
Run();
|
||||||
Run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Run()
|
private void Run()
|
||||||
|
@ -131,7 +131,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await uow.CompleteAsync().ConfigureAwait(false);
|
await uow.CompleteAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rep = new RepeatRunner(_client, toAdd);
|
var rep = new RepeatRunner(_client, (SocketGuild)Context.Guild, toAdd);
|
||||||
|
|
||||||
_service.Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] {rep}), (key, old) =>
|
_service.Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] {rep}), (key, old) =>
|
||||||
{
|
{
|
||||||
@ -179,7 +179,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
await uow.CompleteAsync().ConfigureAwait(false);
|
await uow.CompleteAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rep = new RepeatRunner(_client, toAdd);
|
var rep = new RepeatRunner(_client, (SocketGuild)Context.Guild, toAdd);
|
||||||
|
|
||||||
_service.Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] { rep }), (key, old) =>
|
_service.Repeaters.AddOrUpdate(Context.Guild.Id, new ConcurrentQueue<RepeatRunner>(new[] { rep }), (key, old) =>
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ using NadekoBot.Services.Database.Models;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Utility.Services
|
namespace NadekoBot.Modules.Utility.Services
|
||||||
{
|
{
|
||||||
//todo 50 rewrite
|
|
||||||
public class MessageRepeaterService : INService
|
public class MessageRepeaterService : INService
|
||||||
{
|
{
|
||||||
//messagerepeater
|
//messagerepeater
|
||||||
@ -24,10 +23,17 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
await bot.Ready.Task.ConfigureAwait(false);
|
await bot.Ready.Task.ConfigureAwait(false);
|
||||||
|
|
||||||
Repeaters = new ConcurrentDictionary<ulong, ConcurrentQueue<RepeatRunner>>(gcs
|
Repeaters = new ConcurrentDictionary<ulong, ConcurrentQueue<RepeatRunner>>(gcs
|
||||||
.ToDictionary(gc => gc.GuildId,
|
.Select(gc =>
|
||||||
gc => new ConcurrentQueue<RepeatRunner>(gc.GuildRepeaters
|
{
|
||||||
.Select(gr => new RepeatRunner(client, gr))
|
var guild = client.GetGuild(gc.GuildId);
|
||||||
.Where(x => x.Guild != null))));
|
if (guild == null)
|
||||||
|
return (0, null);
|
||||||
|
return (gc.GuildId, new ConcurrentQueue<RepeatRunner>(gc.GuildRepeaters
|
||||||
|
.Select(gr => new RepeatRunner(client, guild, gr))
|
||||||
|
.Where(x => x.Guild != null)));
|
||||||
|
})
|
||||||
|
.Where(x => x.Item2 != null)
|
||||||
|
.ToDictionary(x => x.Item1, x => x.Item2));
|
||||||
RepeaterReady = true;
|
RepeaterReady = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user