added .repinv
This commit is contained in:
parent
0855fa3022
commit
a52108d32d
@ -4,6 +4,7 @@ using NadekoBot.Classes;
|
|||||||
using NadekoBot.Modules.Permissions.Classes;
|
using NadekoBot.Modules.Permissions.Classes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Commands
|
namespace NadekoBot.Modules.Administration.Commands
|
||||||
@ -27,7 +28,11 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
public Repeater Start()
|
public Repeater Start()
|
||||||
{
|
{
|
||||||
MessageTimer = new Timer { Interval = Interval };
|
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 ch = RepeatingChannel;
|
||||||
var msg = RepeatingMessage;
|
var msg = RepeatingMessage;
|
||||||
@ -45,13 +50,27 @@ namespace NadekoBot.Modules.Administration.Commands
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
};
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void Init(CommandGroupBuilder cgb)
|
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")
|
cgb.CreateCommand(Module.Prefix + "repeat")
|
||||||
.Description("Repeat a message every X minutes. If no parameters are specified, " +
|
.Description("Repeat a message every X minutes. If no parameters are specified, " +
|
||||||
"repeat is disabled. Requires manage messages.\n**Usage**:`.repeat 5 Hello there`")
|
"repeat is disabled. Requires manage messages.\n**Usage**:`.repeat 5 Hello there`")
|
||||||
|
Loading…
Reference in New Issue
Block a user