mirror of
https://github.com/Paillat-dev/presentator.git
synced 2026-01-02 01:06:20 +00:00
Update main.py
This commit is contained in:
31
main.py
31
main.py
@@ -164,42 +164,27 @@ class:
|
||||
with open(f'./data/{uid}/{b64}{datenow}/{images}.png', 'wb') as handler:
|
||||
handler.write(img_data)
|
||||
with open(f"./data/{uid}/{b64}{datenow}/{subject}.md", "w", encoding="utf8") as f: f.write(present)
|
||||
#cmd = f"./marp --pdf --allow-local-files data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
cmd = f"--pdf --allow-local-files ./data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
#we replace all the ' with \'
|
||||
#if the os is linux we replace the \ with /
|
||||
t = False
|
||||
try:
|
||||
if os.path.exists("./marp.exe"):
|
||||
os.system(f"marp.exe {cmd}")
|
||||
print("marp.exe")
|
||||
except:
|
||||
else:
|
||||
cmd = cmd.replace("'", "\\'")
|
||||
os.system(f"./marp {cmd}")
|
||||
print("marp")
|
||||
print(cmd)
|
||||
#cmd = f"./marp --image png -o ./data/{uid}/{b64}{datenow}/{subject}.png --allow-local-files data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
#the above command is not working in docker, so we use the following one
|
||||
cmd = f" --image png -o ./data/{uid}/{b64}{datenow}/{subject}.png --allow-local-files ./data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
#hopefully this will work in docker
|
||||
#try: os.system(f"marp.exe {cmd}")
|
||||
#except:
|
||||
if True:
|
||||
if os.path.exists("./marp.exe"):
|
||||
os.system(f"marp.exe {cmd}")
|
||||
else:
|
||||
cmd = cmd.replace("'", "\\'")
|
||||
os.system(f"./marp {cmd}")
|
||||
print(cmd)
|
||||
#cmd = f"./marp --html --allow-local-files data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
|
||||
cmd = f" --html --allow-local-files ./data/{uid}/{b64}{datenow}/{subject}.md"
|
||||
try : os.system(f"marp.exe {cmd}")
|
||||
except:
|
||||
if os.path.exists("./marp.exe"):
|
||||
os.system(f"marp.exe {cmd}")
|
||||
else:
|
||||
cmd = cmd.replace("'", "\\'")
|
||||
os.system(f"./marp {cmd}")
|
||||
print(cmd)
|
||||
#we create an embed with the first slide imageand send it with the pdf file and the markdown file
|
||||
embed = discord.Embed(title=subject2, description="Thanks for using presentator bot. You can download the presentation in different formats (pdf, markdown, html). The images are generated by an ai. If you want to modify your presentation you can use the markdown file. More information about how to modify the file [HERE](https://marp.app).", color=0xaaaaaa)
|
||||
files = [discord.File(f"./data/{uid}/{b64}{datenow}/{subject}.pdf"), discord.File(f"./data/{uid}/{b64}{datenow}/{subject}.md"), discord.File(f"./data/{uid}/{b64}{datenow}/{subject}.html"), discord.File(f"./data/{uid}/{b64}{datenow}/{subject}.png")]
|
||||
embed.set_image(url=f"attachment://{subject}.png")
|
||||
#now we send the embed and all the 4 files (pdf, markdown, html, png) at the same time
|
||||
await ctx.respond(embed=embed, files=files)
|
||||
|
||||
@bot.slash_command(name="list", description="List all the presentations you have created")
|
||||
|
||||
Reference in New Issue
Block a user