2021-01-25 21:52:36 +00:00
|
|
|
import discord
|
|
|
|
from discord.ext import commands
|
|
|
|
from time import sleep
|
|
|
|
import os
|
|
|
|
import datetime
|
|
|
|
import wget
|
2021-01-27 00:57:35 +00:00
|
|
|
import threading
|
2021-01-25 21:52:36 +00:00
|
|
|
from zipfile import ZipFile
|
2021-01-27 00:57:35 +00:00
|
|
|
from pathlib import Path
|
2021-01-25 21:52:36 +00:00
|
|
|
import shutil
|
|
|
|
|
2021-01-27 00:57:35 +00:00
|
|
|
def closefile():
|
|
|
|
sleep(300)
|
|
|
|
if os.path.exists(finalfilepath):
|
|
|
|
os.remove(finalfilepath)
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2021-01-25 21:52:36 +00:00
|
|
|
|
|
|
|
client = commands.Bot(command_prefix='.')
|
|
|
|
|
|
|
|
|
|
|
|
@client.command()
|
2021-01-25 21:59:04 +00:00
|
|
|
async def addcharacter(ctx):
|
2021-01-26 01:07:02 +00:00
|
|
|
await ctx.send("adding to database please wait")
|
2021-01-27 17:16:39 +00:00
|
|
|
try:
|
|
|
|
await ctx.message.attachments[0].save("newcharacter.zip")
|
2021-01-25 21:52:36 +00:00
|
|
|
|
2021-01-27 17:16:39 +00:00
|
|
|
zf = ZipFile('newcharacter.zip', 'r')
|
|
|
|
zf.extractall('public/singlecharacter')
|
|
|
|
zf.close()
|
|
|
|
if os.path.exists("newcharacter.zip"):
|
|
|
|
os.remove("newcharacter.zip")
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
if os.path.exists("public/characters.zip"):
|
|
|
|
os.remove("public/characters.zip")
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
shutil.make_archive('public/characters', 'zip', 'public/singlecharacter')
|
|
|
|
await ctx.send("added to database")
|
|
|
|
except BaseException:
|
|
|
|
await ctx.send("something went wrong! this probably means you didn't attach a file or discord api is broken")
|
2021-01-26 01:07:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
@client.command()
|
2021-01-25 21:59:04 +00:00
|
|
|
async def addsound(ctx):
|
2021-01-26 01:07:02 +00:00
|
|
|
await ctx.send("adding to database please wait")
|
2021-01-27 17:16:39 +00:00
|
|
|
try:
|
|
|
|
await ctx.message.attachments[0].save("newsound.zip")
|
2021-01-25 21:59:04 +00:00
|
|
|
|
2021-01-27 17:16:39 +00:00
|
|
|
zf = ZipFile('newsound.zip', 'r')
|
|
|
|
zf.extractall('public/singlesound')
|
|
|
|
zf.close()
|
|
|
|
if os.path.exists("newsound.zip"):
|
|
|
|
os.remove("newsound.zip")
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
if os.path.exists("public/sounds.zip"):
|
|
|
|
os.remove("public/sounds.zip")
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
shutil.make_archive('public/sounds', 'zip', 'public/singlesound')
|
|
|
|
await ctx.send("added to database")
|
|
|
|
except BaseException:
|
|
|
|
await ctx.send("something went wrong! this probably means you didn't attach a file or discord api is broken")
|
2021-01-26 01:07:02 +00:00
|
|
|
|
|
|
|
@client.command()
|
|
|
|
async def setip(ctx):
|
|
|
|
ip = userInput = ctx.message.content[7:]
|
|
|
|
with open("public/serverlist.txt", "w+") as hisc:
|
|
|
|
hisc.write(str(ip)+":best bois courthouse")
|
|
|
|
await ctx.send("changed ip to "+str(ip))
|
2021-01-27 00:57:35 +00:00
|
|
|
|
|
|
|
@client.command()
|
|
|
|
async def getchrasset(ctx):
|
|
|
|
weburl = ctx.message.content[13:]
|
2021-01-27 17:16:39 +00:00
|
|
|
betterweburl = weburl.replace(" ", "%20")
|
|
|
|
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlecharacter/"+str(betterweburl))
|
2021-01-27 00:57:35 +00:00
|
|
|
|
|
|
|
@client.command()
|
|
|
|
async def getsound(ctx):
|
|
|
|
sound = ctx.message.content[10:]
|
2021-01-27 17:16:39 +00:00
|
|
|
bettersound = sound.replace(" ", "%20")
|
|
|
|
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlesound/"+str(bettersound))
|
2021-01-27 00:57:35 +00:00
|
|
|
|
|
|
|
@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")
|
|
|
|
|
2021-01-25 21:52:36 +00:00
|
|
|
|
2021-01-25 21:54:12 +00:00
|
|
|
client.run('botid')
|