From 28d4cf4f84de954c00e90d446c5db3db055bb525 Mon Sep 17 00:00:00 2001 From: insert-usernamehere Date: Tue, 26 Jan 2021 19:57:35 -0500 Subject: [PATCH] Update database bot.py --- database bot.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/database bot.py b/database bot.py index 868deeb..16b9aa0 100644 --- a/database bot.py +++ b/database bot.py @@ -4,9 +4,19 @@ from time import sleep import os import datetime import wget +import threading from zipfile import ZipFile +from pathlib import Path import shutil +def closefile(): + sleep(300) + if os.path.exists(finalfilepath): + os.remove(finalfilepath) + else: + pass + + client = commands.Bot(command_prefix='.') @@ -56,5 +66,40 @@ async def setip(ctx): with open("public/serverlist.txt", "w+") as hisc: hisc.write(str(ip)+":best bois courthouse") await ctx.send("changed ip to "+str(ip)) + +@client.command() +async def getchrasset(ctx): + weburl = ctx.message.content[13:] + await ctx.send("http://fierce-push.auto.playit.gg:53368/singlecharacter/"+str(weburl)) + +@client.command() +async def getsound(ctx): + sound = ctx.message.content[10:] + await ctx.send("http://fierce-push.auto.playit.gg:53368/singlesound/"+str(sound)) + +@client.command() +async def downloadcharacter(ctx): + filepath = ctx.message.content[19:] + fullfilepath = 'public/singlecharacter/'+str(filepath) + if os.path.isdir(fullfilepath): + shutil.make_archive(fullfilepath, 'zip', fullfilepath) + global finalfilepath + finalfilepath = str(fullfilepath)+'.zip' + if Path(fullfilepath).stat().st_size > 7823: + urlpath = finalfilepath.replace(" ", "_") + os.rename(finalfilepath,urlpath) + await ctx.send("http://fierce-push.auto.playit.gg:53368/"+str(urlpath)) + await ctx.send("note: this link will become invalid in 5 minutes") + delfile = threading.Thread(target=closefile) + delfile.start() + else: + await ctx.send(file=discord.File(str(finalfilepath))) + if os.path.exists(finalfilepath): + os.remove(finalfilepath) + else: + pass + else: + await ctx.send("sorry, but thats not a character in my database") + client.run('botid')