diff --git a/README.md b/README.md index 11ac495..85803db 100755 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Main goal of this project is to get Robocop functionality done, secondary goal i

[ ] Reduce code repetition on mod_timed.py +[ ] Allow non-hour values on timed bans the following require me to rethink some of the lockdown code, which I don't feel like diff --git a/Robocop.py b/Robocop.py index 6975099..3bfff8e 100755 --- a/Robocop.py +++ b/Robocop.py @@ -93,8 +93,8 @@ async def on_ready(): msg = f"{bot.user.name} has started! "\ f"{guild.name} has {guild.member_count} members!" - config_files = [discord.File(fpath) for fpath in wanted_jsons] - await log_channel.send(msg, files=config_files) + data_files = [discord.File(fpath) for fpath in wanted_jsons] + await log_channel.send(msg, files=data_files) await bot.change_presence(activity=discord.Game(name=game_name)) diff --git a/cogs/admin.py b/cogs/admin.py index 26c5fd1..ef459c0 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -47,8 +47,8 @@ class Admin: @commands.command() async def fetchdata(self, ctx): """Returns data files""" - config_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons] - await ctx.send("Here you go:", files=config_files) + data_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons] + await ctx.send("Here you go:", files=data_files) @commands.guild_only() @commands.check(check_if_bot_manager) diff --git a/cogs/robocronp.py b/cogs/robocronp.py index d92956b..8feb4d2 100644 --- a/cogs/robocronp.py +++ b/cogs/robocronp.py @@ -12,7 +12,12 @@ class Robocronp: def __init__(self, bot): self.bot = bot bot.loop.create_task(self.minutely()) - # bot.loop.create_task(self.hourly()) + bot.loop.create_task(self.hourly()) + + async def send_data(self): + data_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons] + log_channel = self.bot.get_channel(config.log_channel) + await log_channel.send("Hourly data backups:", files=data_files) @commands.guild_only() @commands.check(check_if_staff) @@ -81,11 +86,19 @@ class Robocronp: pass await asyncio.sleep(60) - # async def hourly(self): - # await self.bot.wait_until_ready() - # while not self.bot.is_closed(): - # # Your stuff goes here - # await asyncio.sleep(3600) + async def hourly(self): + await self.bot.wait_until_ready() + while not self.bot.is_closed(): + # Your stuff that should run at boot + # and after that every hour goes here + await asyncio.sleep(3600) + try: + await self.send_data() + except: + # Don't kill cronjobs if something goes wrong. + pass + # Your stuff that should run an hour after boot + # and after that every hour goes here def setup(bot):