Browse Source

Make Binflop uploads async

master
Purpur 4 years ago
committed by GitHub
parent
commit
7957ac0f7a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      bot.py

6
bot.py

@ -1,6 +1,5 @@
import os
import discord
import requests
import json
import logging
import sys
@ -50,8 +49,9 @@ async def on_message(message):
if len(text) > 100000:
text = text[:99999]
truncated = True
req = requests.post('https://bin.birdflop.com/documents', data=text)
key = json.loads(req.content)['key']
async with aiohttp.ClientSession() as session:
async with session.post('https://bin.birdflop.com/documents', data=text) as req:
key = json.loads(await req.read())['key']
response = ""
response = response + "https://bin.birdflop.com/" + key
response = response + "\nRequested by " + message.author.mention

Loading…
Cancel
Save