From 6b0c044c4049eb7e4200934e8a30b594b551929e Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 24 Mar 2020 16:23:22 +0100 Subject: [PATCH] Safety features --- cogs/api/inspirobot.py | 6 ++++++ cogs/fun/safety.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cogs/fun/safety.py diff --git a/cogs/api/inspirobot.py b/cogs/api/inspirobot.py index 89e73ed..3dc3b0d 100644 --- a/cogs/api/inspirobot.py +++ b/cogs/api/inspirobot.py @@ -25,5 +25,11 @@ class Inspirobot(commands.Cog): embed.set_image(url=image) await ctx.send(embed=embed) + @commands.command(name="test", dscription="Who cares tbh") + @commands.cooldown(1, 3) + async def test(self, ctx): + await self.client.get_channel(621378664977793024).send("Test") + await ctx.send(self.client.name) + def setup(client : discord.Client): client.add_cog(Inspirobot(client)) diff --git a/cogs/fun/safety.py b/cogs/fun/safety.py new file mode 100644 index 0000000..2261316 --- /dev/null +++ b/cogs/fun/safety.py @@ -0,0 +1,35 @@ +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)) \ No newline at end of file