small change to how .ropl works
This commit is contained in:
parent
d5c4d3f3d2
commit
d4e78aa8ef
@ -10,6 +10,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration
|
namespace NadekoBot.Modules.Administration
|
||||||
@ -22,8 +23,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
private static Logger _log { get; }
|
private static Logger _log { get; }
|
||||||
public static List<PlayingStatus> RotatingStatusMessages { get; }
|
public static List<PlayingStatus> RotatingStatusMessages { get; }
|
||||||
public static bool RotatingStatuses { get; private set; } = false;
|
public static bool RotatingStatuses { get; private set; } = false;
|
||||||
|
private static Timer _t { get; }
|
||||||
|
|
||||||
//todo wtf is with this while(true) in constructor
|
|
||||||
static PlayingRotateCommands()
|
static PlayingRotateCommands()
|
||||||
{
|
{
|
||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
@ -31,25 +32,25 @@ namespace NadekoBot.Modules.Administration
|
|||||||
RotatingStatusMessages = NadekoBot.BotConfig.RotatingStatusMessages;
|
RotatingStatusMessages = NadekoBot.BotConfig.RotatingStatusMessages;
|
||||||
RotatingStatuses = NadekoBot.BotConfig.RotatingStatuses;
|
RotatingStatuses = NadekoBot.BotConfig.RotatingStatuses;
|
||||||
|
|
||||||
var t = Task.Run(async () =>
|
|
||||||
|
|
||||||
|
_t = new Timer(async (_) =>
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
do
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!RotatingStatuses)
|
if (!RotatingStatuses)
|
||||||
continue;
|
return;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (index >= RotatingStatusMessages.Count)
|
if (index >= RotatingStatusMessages.Count)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
if (!RotatingStatusMessages.Any())
|
if (!RotatingStatusMessages.Any())
|
||||||
continue;
|
return;
|
||||||
var status = RotatingStatusMessages[index++].Status;
|
var status = RotatingStatusMessages[index++].Status;
|
||||||
if (string.IsNullOrWhiteSpace(status))
|
if (string.IsNullOrWhiteSpace(status))
|
||||||
continue;
|
return;
|
||||||
PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value()));
|
PlayingPlaceholders.ForEach(e => status = status.Replace(e.Key, e.Value()));
|
||||||
var shards = NadekoBot.Client.Shards;
|
var shards = NadekoBot.Client.Shards;
|
||||||
for (int i = 0; i < shards.Count; i++)
|
for (int i = 0; i < shards.Count; i++)
|
||||||
@ -67,12 +68,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
_log.Warn("Rotating playing status errored.\n" + ex);
|
_log.Warn("Rotating playing status errored.\n" + ex);
|
||||||
}
|
}
|
||||||
finally
|
}, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
|
||||||
{
|
|
||||||
await Task.Delay(TimeSpan.FromMinutes(1));
|
|
||||||
}
|
|
||||||
} while (true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } =
|
public static Dictionary<string, Func<string>> PlayingPlaceholders { get; } =
|
||||||
|
@ -222,6 +222,7 @@ namespace NadekoBot.Services
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// maybe this message is a custom reaction
|
// maybe this message is a custom reaction
|
||||||
|
// todo log custom reaction executions. return struct with info
|
||||||
var crExecuted = await Task.Run(() => CustomReactions.TryExecuteCustomReaction(usrMsg)).ConfigureAwait(false);
|
var crExecuted = await Task.Run(() => CustomReactions.TryExecuteCustomReaction(usrMsg)).ConfigureAwait(false);
|
||||||
if (crExecuted) //if it was, don't execute the command
|
if (crExecuted) //if it was, don't execute the command
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user