mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2025-01-03 15:55:43 +00:00
make more of the code dpy2 friendly
- robocronp is completely broken - The overall init should be unfucked, example here: https://discordpy.readthedocs.io/en/latest/migrating.html#extension-and-cog-loading-unloading-is-now-asynchronous
This commit is contained in:
parent
07f53753c3
commit
2d25ab5601
|
@ -236,4 +236,4 @@ for wanted_json in wanted_jsons:
|
|||
with open(wanted_json, "w") as f:
|
||||
f.write("{}")
|
||||
|
||||
bot.run(config.token, bot=True, reconnect=True)
|
||||
bot.run(config.token, reconnect=True)
|
||||
|
|
|
@ -172,5 +172,5 @@ class Admin(Cog):
|
|||
await ctx.send(f":white_check_mark: `{ext}` successfully reloaded.")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Admin(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Admin(bot))
|
||||
|
|
|
@ -63,5 +63,5 @@ class Basic(Cog):
|
|||
await tmp.edit(content=message_text)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Basic(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Basic(bot))
|
||||
|
|
|
@ -26,5 +26,5 @@ class BasicReswitched(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(BasicReswitched(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(BasicReswitched(bot))
|
||||
|
|
|
@ -191,5 +191,5 @@ class Common(Cog):
|
|||
return "No output."
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Common(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Common(bot))
|
||||
|
|
|
@ -194,5 +194,5 @@ class Err(Cog):
|
|||
await ctx.send("This doesn't look like typical hex!")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Err(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Err(bot))
|
||||
|
|
|
@ -83,5 +83,5 @@ class ImageManip(Cog):
|
|||
await ctx.send(content=f"{mention}: Enjoy.", file=discord.File(out_filename))
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ImageManip(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ImageManip(bot))
|
||||
|
|
|
@ -43,5 +43,5 @@ class Invites(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Invites(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Invites(bot))
|
||||
|
|
|
@ -33,5 +33,5 @@ class Legacy(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Legacy(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Legacy(bot))
|
||||
|
|
|
@ -76,5 +76,5 @@ class Links(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Links(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Links(bot))
|
||||
|
|
|
@ -389,5 +389,5 @@ class Lists(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Lists(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Lists(bot))
|
||||
|
|
|
@ -101,5 +101,5 @@ class Lockdown(Cog):
|
|||
await log_channel.send(msg)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Lockdown(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Lockdown(bot))
|
||||
|
|
|
@ -381,5 +381,5 @@ class Logs(Cog):
|
|||
await log_channel.send(msg)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Logs(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Logs(bot))
|
||||
|
|
|
@ -174,5 +174,5 @@ class Meme(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Meme(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Meme(bot))
|
||||
|
|
|
@ -697,5 +697,5 @@ class Mod(Cog):
|
|||
await ctx.send("Successfully set bot nickname.")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Mod(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Mod(bot))
|
||||
|
|
|
@ -26,5 +26,5 @@ class ModNote(Cog):
|
|||
await ctx.send(f"{ctx.author.mention}: noted!")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModNote(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModNote(bot))
|
||||
|
|
|
@ -118,5 +118,5 @@ class ModReact(Cog):
|
|||
await msg.edit(content=f"{msg_text} Done!")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModReact(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModReact(bot))
|
||||
|
|
|
@ -41,5 +41,5 @@ class ModReswitched(Cog):
|
|||
await ctx.send(f"{ctx.author.mention}: Gave you mod role.")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModReswitched(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModReswitched(bot))
|
||||
|
|
|
@ -156,5 +156,5 @@ class ModTimed(Cog):
|
|||
add_restriction(target.id, config.mute_role)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModTimed(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModTimed(bot))
|
||||
|
|
|
@ -244,5 +244,5 @@ class ModUserlog(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModUserlog(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModUserlog(bot))
|
||||
|
|
|
@ -42,5 +42,5 @@ class ModWatch(Cog):
|
|||
await ctx.send(f"{target.mention}: user is now not on watch.")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(ModWatch(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(ModWatch(bot))
|
||||
|
|
|
@ -157,5 +157,5 @@ def check(msg):
|
|||
return msg.type is MessageType.pins_add
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Pin(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Pin(bot))
|
||||
|
|
|
@ -73,5 +73,5 @@ class Remind(Cog):
|
|||
await msg.delete()
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Remind(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Remind(bot))
|
||||
|
|
|
@ -3,7 +3,7 @@ import config
|
|||
import time
|
||||
import discord
|
||||
import traceback
|
||||
from discord.ext import commands
|
||||
from discord.ext import commands, tasks
|
||||
from discord.ext.commands import Cog
|
||||
from helpers.robocronp import get_crontab, delete_job
|
||||
from helpers.restrictions import remove_restriction
|
||||
|
@ -13,9 +13,14 @@ from helpers.checks import check_if_staff
|
|||
class Robocronp(Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
bot.loop.create_task(self.minutely())
|
||||
bot.loop.create_task(self.hourly())
|
||||
bot.loop.create_task(self.daily())
|
||||
self.minutely.start()
|
||||
self.hourly.start()
|
||||
self.daily.start()
|
||||
|
||||
def cog_unload(self):
|
||||
self.minutely.cancel()
|
||||
self.hourly.cancel()
|
||||
self.daily.cancel()
|
||||
|
||||
async def send_data(self):
|
||||
data_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons]
|
||||
|
@ -113,10 +118,9 @@ class Robocronp(Cog):
|
|||
f"Cronclean has errored: ```{traceback.format_exc()}```"
|
||||
)
|
||||
|
||||
@tasks.loop(minutes=1)
|
||||
async def minutely(self):
|
||||
await self.bot.wait_until_ready()
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
while not self.bot.is_closed():
|
||||
try:
|
||||
ctab = get_crontab()
|
||||
timestamp = time.time()
|
||||
|
@ -133,18 +137,12 @@ class Robocronp(Cog):
|
|||
await log_channel.send(
|
||||
f"Cron-minutely has errored: ```{traceback.format_exc()}```"
|
||||
)
|
||||
await asyncio.sleep(60)
|
||||
|
||||
@tasks.loop(hours=1)
|
||||
async def hourly(self):
|
||||
await self.bot.wait_until_ready()
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
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()
|
||||
|
||||
# Handle clean channels
|
||||
for clean_channel in config.hourly_clean_channels:
|
||||
await self.clean_channel(clean_channel)
|
||||
|
@ -153,15 +151,10 @@ class Robocronp(Cog):
|
|||
await log_channel.send(
|
||||
f"Cron-hourly has errored: ```{traceback.format_exc()}```"
|
||||
)
|
||||
# Your stuff that should run an hour after boot
|
||||
# and after that every hour goes here
|
||||
|
||||
@tasks.loop(hours=24)
|
||||
async def daily(self):
|
||||
await self.bot.wait_until_ready()
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
while not self.bot.is_closed():
|
||||
# Your stuff that should run at boot
|
||||
# and after that every day goes here
|
||||
try:
|
||||
# Reset verification and algorithm
|
||||
if "cogs.verification" in config.initial_cogs:
|
||||
|
@ -172,10 +165,7 @@ class Robocronp(Cog):
|
|||
await log_channel.send(
|
||||
f"Cron-daily has errored: ```{traceback.format_exc()}```"
|
||||
)
|
||||
await asyncio.sleep(86400)
|
||||
# Your stuff that should run a day after boot
|
||||
# and after that every day goes here
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Robocronp(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Robocronp(bot))
|
||||
|
|
|
@ -44,5 +44,5 @@ class SAR(Cog):
|
|||
)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(SAR(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(SAR(bot))
|
||||
|
|
|
@ -218,5 +218,5 @@ class Verification(Cog):
|
|||
await chan.send("💢 I don't have permission to do this.")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Verification(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Verification(bot))
|
||||
|
|
|
@ -148,5 +148,5 @@ class YubicoOTP(Cog):
|
|||
await msg.delete()
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(YubicoOTP(bot))
|
||||
async def setup(bot):
|
||||
await bot.add_cog(YubicoOTP(bot))
|
||||
|
|
Loading…
Reference in a new issue