added .repinv

This commit is contained in:
Master Kwoth 2016-05-23 22:50:16 +02:00
parent 0855fa3022
commit a52108d32d
2 changed files with 48 additions and 29 deletions

View File

@ -4,6 +4,7 @@ using NadekoBot.Classes;
using NadekoBot.Modules.Permissions.Classes;
using System;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Timers;
namespace NadekoBot.Modules.Administration.Commands
@ -27,7 +28,11 @@ namespace NadekoBot.Modules.Administration.Commands
public Repeater Start()
{
MessageTimer = new Timer { Interval = Interval };
MessageTimer.Elapsed += async (s, e) =>
MessageTimer.Elapsed += async (s, e) => await Invoke();
return this;
}
public async Task Invoke()
{
var ch = RepeatingChannel;
var msg = RepeatingMessage;
@ -45,13 +50,27 @@ namespace NadekoBot.Modules.Administration.Commands
}
catch { }
}
};
return this;
}
}
internal override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Module.Prefix + "repeatinvoke")
.Alias(Module.Prefix + "repinv")
.Description("Immediately shows the repeat message and restarts the timer.")
.AddCheck(SimpleCheckers.ManageMessages())
.Do(async e =>
{
Repeater rep;
if (!repeaters.TryGetValue(e.Server, out rep))
{
await e.Channel.SendMessage("`No repeating message found on this server.`");
return;
}
await rep.Invoke();
});
cgb.CreateCommand(Module.Prefix + "repeat")
.Description("Repeat a message every X minutes. If no parameters are specified, " +
"repeat is disabled. Requires manage messages.\n**Usage**:`.repeat 5 Hello there`")