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