more meme cleanup and added a function to upload memes to website

This commit is contained in:
phixxy 2024-01-17 19:46:10 -08:00
parent b2fb09e681
commit 60d12e388c
2 changed files with 31 additions and 17 deletions

View file

@ -43,20 +43,6 @@ async def handle_error(error):
brief="Generate a meme"
)
async def meme(ctx):
'''async def update_meme_webpage(filename):
server_folder = (os.getenv('ftp_public_html') + 'ai-memes/')
new_file_name = str(time.time_ns()) + ".png"
await upload_sftp(filename, server_folder, new_file_name)
print("Uploaded", new_file_name)
with open("phixxy.com/ai-memes/index.html", 'r') as f:
html_data = f.read()
html_insert = '<!--ADD IMG HERE-->\n <img src="' + new_file_name + '" loading="lazy">'
html_data = html_data.replace('<!--ADD IMG HERE-->',html_insert)
with open("phixxy.com/ai-memes/index.html", "w") as f:
f.writelines(html_data)
await upload_sftp("phixxy.com/ai-memes/index.html", server_folder, "index.html")'''
async def generate_random_meme(topic):
http_session = aiohttp.ClientSession()
async with http_session.get('https://api.imgflip.com/get_memes') as resp: