Explorar el Código

failed attempts at getting upload to work but I got closer so need to save that work.

tags/v1.7.0
Roxie Gibson hace 6 años
padre
commit
1f37ee1e8b
Se han modificado 2 ficheros con 11 adiciones y 12 borrados
  1. +8
    -9
      roxbot/cogs/util.py
  2. +3
    -3
      roxbot/http.py

+ 8
- 9
roxbot/cogs/util.py Ver fichero

@@ -1,4 +1,6 @@
import os
import json
import random
import discord
from discord.ext import commands
from discord.ext.commands import bot
@@ -140,17 +142,16 @@ class Util():
Uploads selected file to the host, thanks to the fact that
every pomf.se based site has pretty much the same architecture.
"""
# Fucking broke because uploading is impossible whyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
sites = [
"https://comfy.moe/",
"https://mixtape.moe/",
"https://doko.moe/",
#"https://pomfe.co/",
#"https://pomf.space/",
##"https://pomfe.co/",
##"https://pomf.space/",
"https://vidga.me/",
"https://pomf.pyonpyon.moe/"
] # List of pomf clone sites and upload limits
"""if ctx.message.attachments:
if ctx.message.attachments:
# Site choice, shouldn't need an upload size check since max upload for discord atm is 50MB
site = random.choice(sites)
urls = []
@@ -160,17 +161,15 @@ class Util():
name = attachment.url.split("/")[-1]
# Download File
await roxbot.http.download_file(attachment.url, name)
# Upload file
#with open(name, 'rb') as f:
# answer = requests.post(url=site + "upload.php", files={'files[]': (name, f.read())})
#response = answer.json()

response = await roxbot.http.upload_file(site+"upload.php", name)
file_name_1 = response["files"][0]["url"].replace("\\", "")
urls.append(file_name_1)
os.remove(name)
msg = "".join(urls)
return await ctx.send(msg)
else:
return await ctx.send("Send me stuff to upload.")"""
return await ctx.send("Send me stuff to upload.")

@upload.error
async def upload_err(self, ctx, error):

+ 3
- 3
roxbot/http.py Ver fichero

@@ -43,9 +43,9 @@ async def upload_file(url, file):
:return:
"""
async with aiohttp.ClientSession() as session:
with open(file, "rb") as f:
files = {file: f.read()}
return await session.post(url, data=files)
payload = {"files": open(file, "rb")}
resp = await session.post(url, headers={'User-agent': 'RoxBot Discord Bot', "content_type": "multipart/form-data"}, data=payload)
return await resp.json()


async def get_page(url):

Cargando…
Cancelar
Guardar