Repeat won't repost if the last message is the same
This commit is contained in:
parent
6cdb441584
commit
ae10c92455
@ -695,6 +695,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
logSetting.LogUserPresenceId =
|
logSetting.LogUserPresenceId =
|
||||||
logSetting.LogVoicePresenceId =
|
logSetting.LogVoicePresenceId =
|
||||||
logSetting.LogVoicePresenceTTSId = (action.Value ? channel.Id : (ulong?)null);
|
logSetting.LogVoicePresenceTTSId = (action.Value ? channel.Id : (ulong?)null);
|
||||||
|
|
||||||
|
await uow.CompleteAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
if (action.Value)
|
if (action.Value)
|
||||||
await channel.SendMessageAsync("✅ Logging all events on this channel.").ConfigureAwait(false);
|
await channel.SendMessageAsync("✅ Logging all events on this channel.").ConfigureAwait(false);
|
||||||
|
@ -50,10 +50,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
while (!token.IsCancellationRequested)
|
while (!token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
var toSend = "🔄 " + Repeater.Message;
|
||||||
await Task.Delay(Repeater.Interval, token).ConfigureAwait(false);
|
await Task.Delay(Repeater.Interval, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var lastMsgInChannel = (await Channel.GetMessagesAsync(1)).FirstOrDefault();
|
||||||
|
if (lastMsgInChannel.Id == oldMsg.Id) //don't send if it's the same message in the channel
|
||||||
|
continue;
|
||||||
|
|
||||||
if (oldMsg != null)
|
if (oldMsg != null)
|
||||||
try { await oldMsg.DeleteAsync(); } catch { }
|
try { await oldMsg.DeleteAsync(); } catch { }
|
||||||
try { oldMsg = await Channel.SendMessageAsync("🔄 " + Repeater.Message).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); try { source.Cancel(); } catch { } }
|
try { oldMsg = await Channel.SendMessageAsync(toSend).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); try { source.Cancel(); } catch { } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) { }
|
catch (OperationCanceledException) { }
|
||||||
|
Loading…
Reference in New Issue
Block a user