Handle time innacuracy by warning owner (#2036)

* handle time innacuracy by warning owner

* Fix typo and add space
This commit is contained in:
Michael H
2018-08-22 21:28:05 -04:00
committed by Toby Harradine
parent aa69dd381f
commit bda7e08208
2 changed files with 15 additions and 0 deletions

View File

@@ -256,6 +256,20 @@ def init_events(bot, cli_flags):
async def on_message(message):
bot.counter["messages_read"] += 1
await bot.process_commands(message)
discord_now = message.created_at
if (
not bot.checked_time_accuracy
or (discord_now - timedelta(minutes=60)) > bot.checked_time_accuracy
):
system_now = datetime.datetime.utcnow()
diff = abs((discord_now - system_now).total_seconds)
if diff > 60:
log.warn(
"Detected significant difference (%d seconds) in system clock to discord's clock."
" Any time sensitive code may fail.",
diff,
)
bot.checked_time_accuracy = discord_now
@bot.event
async def on_resumed():