mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2025-01-05 14:25:44 +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:
|
with open(wanted_json, "w") as f:
|
||||||
f.write("{}")
|
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.")
|
await ctx.send(f":white_check_mark: `{ext}` successfully reloaded.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Admin(bot))
|
await bot.add_cog(Admin(bot))
|
||||||
|
|
|
@ -63,5 +63,5 @@ class Basic(Cog):
|
||||||
await tmp.edit(content=message_text)
|
await tmp.edit(content=message_text)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Basic(bot))
|
await bot.add_cog(Basic(bot))
|
||||||
|
|
|
@ -26,5 +26,5 @@ class BasicReswitched(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(BasicReswitched(bot))
|
await bot.add_cog(BasicReswitched(bot))
|
||||||
|
|
|
@ -191,5 +191,5 @@ class Common(Cog):
|
||||||
return "No output."
|
return "No output."
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Common(bot))
|
await bot.add_cog(Common(bot))
|
||||||
|
|
|
@ -194,5 +194,5 @@ class Err(Cog):
|
||||||
await ctx.send("This doesn't look like typical hex!")
|
await ctx.send("This doesn't look like typical hex!")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Err(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))
|
await ctx.send(content=f"{mention}: Enjoy.", file=discord.File(out_filename))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ImageManip(bot))
|
await bot.add_cog(ImageManip(bot))
|
||||||
|
|
|
@ -43,5 +43,5 @@ class Invites(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Invites(bot))
|
await bot.add_cog(Invites(bot))
|
||||||
|
|
|
@ -33,5 +33,5 @@ class Legacy(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Legacy(bot))
|
await bot.add_cog(Legacy(bot))
|
||||||
|
|
|
@ -76,5 +76,5 @@ class Links(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Links(bot))
|
await bot.add_cog(Links(bot))
|
||||||
|
|
|
@ -389,5 +389,5 @@ class Lists(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Lists(bot))
|
await bot.add_cog(Lists(bot))
|
||||||
|
|
|
@ -101,5 +101,5 @@ class Lockdown(Cog):
|
||||||
await log_channel.send(msg)
|
await log_channel.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Lockdown(bot))
|
await bot.add_cog(Lockdown(bot))
|
||||||
|
|
|
@ -381,5 +381,5 @@ class Logs(Cog):
|
||||||
await log_channel.send(msg)
|
await log_channel.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Logs(bot))
|
await bot.add_cog(Logs(bot))
|
||||||
|
|
|
@ -174,5 +174,5 @@ class Meme(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Meme(bot))
|
await bot.add_cog(Meme(bot))
|
||||||
|
|
|
@ -697,5 +697,5 @@ class Mod(Cog):
|
||||||
await ctx.send("Successfully set bot nickname.")
|
await ctx.send("Successfully set bot nickname.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Mod(bot))
|
await bot.add_cog(Mod(bot))
|
||||||
|
|
|
@ -26,5 +26,5 @@ class ModNote(Cog):
|
||||||
await ctx.send(f"{ctx.author.mention}: noted!")
|
await ctx.send(f"{ctx.author.mention}: noted!")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModNote(bot))
|
await bot.add_cog(ModNote(bot))
|
||||||
|
|
|
@ -118,5 +118,5 @@ class ModReact(Cog):
|
||||||
await msg.edit(content=f"{msg_text} Done!")
|
await msg.edit(content=f"{msg_text} Done!")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModReact(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.")
|
await ctx.send(f"{ctx.author.mention}: Gave you mod role.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModReswitched(bot))
|
await bot.add_cog(ModReswitched(bot))
|
||||||
|
|
|
@ -156,5 +156,5 @@ class ModTimed(Cog):
|
||||||
add_restriction(target.id, config.mute_role)
|
add_restriction(target.id, config.mute_role)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModTimed(bot))
|
await bot.add_cog(ModTimed(bot))
|
||||||
|
|
|
@ -244,5 +244,5 @@ class ModUserlog(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModUserlog(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.")
|
await ctx.send(f"{target.mention}: user is now not on watch.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(ModWatch(bot))
|
await bot.add_cog(ModWatch(bot))
|
||||||
|
|
|
@ -157,5 +157,5 @@ def check(msg):
|
||||||
return msg.type is MessageType.pins_add
|
return msg.type is MessageType.pins_add
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Pin(bot))
|
await bot.add_cog(Pin(bot))
|
||||||
|
|
|
@ -73,5 +73,5 @@ class Remind(Cog):
|
||||||
await msg.delete()
|
await msg.delete()
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Remind(bot))
|
await bot.add_cog(Remind(bot))
|
||||||
|
|
|
@ -3,7 +3,7 @@ import config
|
||||||
import time
|
import time
|
||||||
import discord
|
import discord
|
||||||
import traceback
|
import traceback
|
||||||
from discord.ext import commands
|
from discord.ext import commands, tasks
|
||||||
from discord.ext.commands import Cog
|
from discord.ext.commands import Cog
|
||||||
from helpers.robocronp import get_crontab, delete_job
|
from helpers.robocronp import get_crontab, delete_job
|
||||||
from helpers.restrictions import remove_restriction
|
from helpers.restrictions import remove_restriction
|
||||||
|
@ -13,9 +13,14 @@ from helpers.checks import check_if_staff
|
||||||
class Robocronp(Cog):
|
class Robocronp(Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
bot.loop.create_task(self.minutely())
|
self.minutely.start()
|
||||||
bot.loop.create_task(self.hourly())
|
self.hourly.start()
|
||||||
bot.loop.create_task(self.daily())
|
self.daily.start()
|
||||||
|
|
||||||
|
def cog_unload(self):
|
||||||
|
self.minutely.cancel()
|
||||||
|
self.hourly.cancel()
|
||||||
|
self.daily.cancel()
|
||||||
|
|
||||||
async def send_data(self):
|
async def send_data(self):
|
||||||
data_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons]
|
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()}```"
|
f"Cronclean has errored: ```{traceback.format_exc()}```"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@tasks.loop(minutes=1)
|
||||||
async def minutely(self):
|
async def minutely(self):
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||||
while not self.bot.is_closed():
|
|
||||||
try:
|
try:
|
||||||
ctab = get_crontab()
|
ctab = get_crontab()
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
|
@ -133,18 +137,12 @@ class Robocronp(Cog):
|
||||||
await log_channel.send(
|
await log_channel.send(
|
||||||
f"Cron-minutely has errored: ```{traceback.format_exc()}```"
|
f"Cron-minutely has errored: ```{traceback.format_exc()}```"
|
||||||
)
|
)
|
||||||
await asyncio.sleep(60)
|
|
||||||
|
|
||||||
|
@tasks.loop(hours=1)
|
||||||
async def hourly(self):
|
async def hourly(self):
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
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:
|
try:
|
||||||
await self.send_data()
|
await self.send_data()
|
||||||
|
|
||||||
# Handle clean channels
|
# Handle clean channels
|
||||||
for clean_channel in config.hourly_clean_channels:
|
for clean_channel in config.hourly_clean_channels:
|
||||||
await self.clean_channel(clean_channel)
|
await self.clean_channel(clean_channel)
|
||||||
|
@ -153,15 +151,10 @@ class Robocronp(Cog):
|
||||||
await log_channel.send(
|
await log_channel.send(
|
||||||
f"Cron-hourly has errored: ```{traceback.format_exc()}```"
|
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):
|
async def daily(self):
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
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:
|
try:
|
||||||
# Reset verification and algorithm
|
# Reset verification and algorithm
|
||||||
if "cogs.verification" in config.initial_cogs:
|
if "cogs.verification" in config.initial_cogs:
|
||||||
|
@ -172,10 +165,7 @@ class Robocronp(Cog):
|
||||||
await log_channel.send(
|
await log_channel.send(
|
||||||
f"Cron-daily has errored: ```{traceback.format_exc()}```"
|
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):
|
async def setup(bot):
|
||||||
bot.add_cog(Robocronp(bot))
|
await bot.add_cog(Robocronp(bot))
|
||||||
|
|
|
@ -44,5 +44,5 @@ class SAR(Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(SAR(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.")
|
await chan.send("💢 I don't have permission to do this.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Verification(bot))
|
await bot.add_cog(Verification(bot))
|
||||||
|
|
|
@ -148,5 +148,5 @@ class YubicoOTP(Cog):
|
||||||
await msg.delete()
|
await msg.delete()
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(YubicoOTP(bot))
|
await bot.add_cog(YubicoOTP(bot))
|
||||||
|
|
Loading…
Reference in a new issue