DeepBlue/cogs/fun/safety.py
2020-03-24 16:23:22 +01:00

35 lines
No EOL
1.2 KiB
Python

import discord
from discord.ext import commands
from util import embed, logging
import time
class Safety(commands.Cog):
def __init__(self, client):
self.client = client
self.msg_buffer = [".", ".", ".", ".", ".", "."]
self.ping = "<@&380535423233032193>"
self.channel = 439466964625391637
self.last_action = 0
@commands.Cog.listener()
async def on_message(self, message):
if message.channel.id != self.channel:
return
if (time.time() - self.last_action) < 10:
return
if self.ping in message.content:
for msg in self.msg_buffer:
if self.ping in msg:
# Ping not adequately spaced
await message.channel.send(embed=embed.make_embed("Coronavirus Safety Information", "Due to the ongoing pandemic, please remember to space your NaughtyStep pings at least six messages apart.\n Thank you."))
self.last_action = time.time()
break
self.msg_buffer.pop(0)
self.msg_buffer.append(message.content)
def setup(client):
client.add_cog(Safety(client))