Update database bot.py

This commit is contained in:
insert-usernamehere 2021-01-26 19:57:35 -05:00 committed by GitHub
parent 9132b79ff7
commit 28d4cf4f84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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')