cleaned up sparky folders

should have fixed generate blog in phixxycom
This commit is contained in:
phixxy 2024-01-25 00:13:16 -08:00
parent 7b5f7f630b
commit 5dd6018f41
2 changed files with 16 additions and 19 deletions

View file

@ -207,7 +207,6 @@ class PhixxyCom(commands.Cog):
current_struct_time = time.localtime(current_time) current_struct_time = time.localtime(current_time)
date = time.strftime("%B %d, %Y", current_struct_time) date = time.strftime("%B %d, %Y", current_struct_time)
if date in html_data: if date in html_data:
print("I already wrote a blog post today!")
return return
blogpost_file = f"{self.data_dir}blog_topics.txt" blogpost_file = f"{self.data_dir}blog_topics.txt"
if os.path.isfile(blogpost_file): if os.path.isfile(blogpost_file):
@ -254,7 +253,7 @@ class PhixxyCom(commands.Cog):
run_time = time.time() - start_time run_time = time.time() - start_time
print("It took " + str(run_time) + " seconds to generate the blog post!") print("It took " + str(run_time) + " seconds to generate the blog post!")
output = "Blog Updated! (" + str(run_time) + " seconds) https://ai.phixxy.com/ai-blog" output = "Blog Updated! (" + str(run_time) + " seconds) https://ai.phixxy.com/ai-blog"
print(output) return output
@commands.command( @commands.command(
description="Website", description="Website",
@ -296,18 +295,18 @@ class PhixxyCom(commands.Cog):
#await ctx.send("Failed, Try again.") #await ctx.send("Failed, Try again.")
print(error) print(error)
@tasks.loop(seconds=1) @tasks.loop(seconds=60)
async def phixxy_loop(self): async def phixxy_loop(self):
current_time = time.localtime() current_time = time.localtime()
#Run every minute
if current_time.tm_sec == 0:
await self.meme_handler('tmp/meme/') await self.meme_handler('tmp/meme/')
await self.upload_ftp_ai_images('tmp/stable_diffusion/sfw/') await self.upload_ftp_ai_images('tmp/stable_diffusion/sfw/')
if current_time.tm_hour == 17 and current_time.tm_min == 0 and current_time.tm_sec == 0:
bot_stuff_channel = self.bot.get_channel(544408659174883328) @tasks.loop(hours=1)
await bot_stuff_channel.send("Running Daily Tasks") async def blog_loop(self):
try: try:
await self.generate_blog() message = await self.generate_blog()
bot_stuff_channel = self.bot.get_channel(544408659174883328)
await bot_stuff_channel.send(message)
except Exception as error: except Exception as error:
print("Failed to generate blog") print("Failed to generate blog")

View file

@ -33,16 +33,15 @@ bot = commands.Bot(command_prefix='!', intents=intents)
async def folder_setup(): async def folder_setup():
# Only tmp, extensions and data are supported, all other folders only exist for backwards compatibility and will be removed soon! folder_names = ["tmp", "extensions", "data"]
folder_names = ["tmp", "extensions", "data", "channels","channels/config", "channels/logs"]
for folder_name in folder_names: for folder_name in folder_names:
if not os.path.exists(folder_name): if not os.path.exists(folder_name):
os.mkdir(folder_name) os.mkdir(folder_name)
return folder_names return folder_names
async def delete_all_files(path, safe_folders=None): async def delete_all_files(path):
for filename in os.listdir(path): for filename in os.listdir(path):
if os.path.isdir(path+filename) and not path+filename in safe_folders: if os.path.isdir(path+filename):
shutil.rmtree(path+filename) shutil.rmtree(path+filename)
elif os.path.isfile(path+filename): elif os.path.isfile(path+filename):
os.remove(path+filename) os.remove(path+filename)
@ -78,8 +77,7 @@ async def on_disconnect():
@bot.event @bot.event
async def on_ready(): async def on_ready():
folders_made = await folder_setup() await delete_all_files("tmp/")
await delete_all_files("tmp/", folders_made)
# Import plugins from extensions folder # Import plugins from extensions folder
for plugin_file in os.listdir('extensions/'): for plugin_file in os.listdir('extensions/'):
if plugin_file[0] != '_' and plugin_file[-3:] == '.py': if plugin_file[0] != '_' and plugin_file[-3:] == '.py':