Stopped using random number file names
This commit is contained in:
parent
2c012faf73
commit
7c65e55d92
1 changed files with 5 additions and 12 deletions
|
|
@ -1026,8 +1026,6 @@ async def draw(ctx):
|
||||||
if url == "disabled":
|
if url == "disabled":
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir("tmp/draw/"):
|
|
||||||
os.makedirs("tmp/draw/")
|
|
||||||
if " " in ctx.message.content:
|
if " " in ctx.message.content:
|
||||||
amount = ctx.message.content.split(" ", maxsplit=1)[1]
|
amount = ctx.message.content.split(" ", maxsplit=1)[1]
|
||||||
if int(amount) > 4:
|
if int(amount) > 4:
|
||||||
|
|
@ -1057,7 +1055,7 @@ async def draw(ctx):
|
||||||
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
||||||
pnginfo = PngImagePlugin.PngInfo()
|
pnginfo = PngImagePlugin.PngInfo()
|
||||||
pnginfo.add_text("parameters", response2.json().get("info"))
|
pnginfo.add_text("parameters", response2.json().get("info"))
|
||||||
my_filename = "tmp/draw/" + prompt + str(random.randint(0,10000000)) + ".png"
|
my_filename = "tmp/" + str(len(os.listdir("tmp/"))) + ".png"
|
||||||
image.save(my_filename, pnginfo=pnginfo)
|
image.save(my_filename, pnginfo=pnginfo)
|
||||||
channel_vars = await get_channel_config(ctx.channel.id)
|
channel_vars = await get_channel_config(ctx.channel.id)
|
||||||
if channel_vars["ftp_enabled"]:
|
if channel_vars["ftp_enabled"]:
|
||||||
|
|
@ -1261,7 +1259,7 @@ async def imagine(ctx):
|
||||||
pnginfo = PngImagePlugin.PngInfo()
|
pnginfo = PngImagePlugin.PngInfo()
|
||||||
pnginfo.add_text("parameters", response2.json().get("info"))
|
pnginfo.add_text("parameters", response2.json().get("info"))
|
||||||
|
|
||||||
my_filename = "users/" + str(ctx.author.id) + '/' + prompt[0:15] + str(random.randint(0, 10000000)) + ".png"
|
my_filename = "users/" + str(ctx.author.id) + '/' + str(len(os.listdir("users/" + str(ctx.author.id) + '/'))) + ".png"
|
||||||
image.save(my_filename, pnginfo=pnginfo)
|
image.save(my_filename, pnginfo=pnginfo)
|
||||||
|
|
||||||
channel_vars = await get_channel_config(ctx.channel.id)
|
channel_vars = await get_channel_config(ctx.channel.id)
|
||||||
|
|
@ -1298,10 +1296,7 @@ async def describe(ctx):
|
||||||
|
|
||||||
r = requests.get(file_url, stream=True)
|
r = requests.get(file_url, stream=True)
|
||||||
|
|
||||||
if not os.path.isdir(f"tmp/clip/{ctx.author.id}"):
|
imageName = "tmp/" + str(len(os.listdir("tmp/"))) + ".png"
|
||||||
os.makedirs(f"tmp/clip/{ctx.author.id}")
|
|
||||||
|
|
||||||
imageName = f"tmp/clip/{ctx.author.id}/{random.randint(0,10000000)}.png"
|
|
||||||
|
|
||||||
with open(imageName, 'wb') as out_file:
|
with open(imageName, 'wb') as out_file:
|
||||||
print(f"Saving image: {imageName}")
|
print(f"Saving image: {imageName}")
|
||||||
|
|
@ -1342,9 +1337,7 @@ async def reimagine(ctx):
|
||||||
print("couldn't find image")
|
print("couldn't find image")
|
||||||
key_value_pairs, prompt = extract_key_value_pairs(prompt)
|
key_value_pairs, prompt = extract_key_value_pairs(prompt)
|
||||||
r = requests.get(file_url, stream=True)
|
r = requests.get(file_url, stream=True)
|
||||||
if not os.path.isdir("tmp/reimagining/"+ str(ctx.author.id)):
|
imageName = "tmp/" + str(len(os.listdir("tmp/"))) + ".png"
|
||||||
os.makedirs("tmp/reimagining/"+ str(ctx.author.id))
|
|
||||||
imageName = "tmp/reimagining/" + str(ctx.author.id) +"/"+ str(random.randint(0,10000000)) + '.png'
|
|
||||||
with open(imageName, 'wb') as out_file:
|
with open(imageName, 'wb') as out_file:
|
||||||
print('Saving image: ' + imageName)
|
print('Saving image: ' + imageName)
|
||||||
shutil.copyfileobj(r.raw, out_file)
|
shutil.copyfileobj(r.raw, out_file)
|
||||||
|
|
@ -1367,7 +1360,7 @@ async def reimagine(ctx):
|
||||||
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
||||||
pnginfo = PngImagePlugin.PngInfo()
|
pnginfo = PngImagePlugin.PngInfo()
|
||||||
pnginfo.add_text("parameters", response2.json().get("info"))
|
pnginfo.add_text("parameters", response2.json().get("info"))
|
||||||
my_filename = "tmp/reimagined/" + str(ctx.author.id) + '/' + prompt[0:15] + str(random.randint(0,10000000)) + ".png"
|
my_filename = "tmp/" + str(len(os.listdir("tmp/"))) + ".png"
|
||||||
image.save(my_filename, pnginfo=pnginfo)
|
image.save(my_filename, pnginfo=pnginfo)
|
||||||
with open(my_filename, "rb") as fh:
|
with open(my_filename, "rb") as fh:
|
||||||
f = discord.File(fh, filename=my_filename)
|
f = discord.File(fh, filename=my_filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue