Created
October 13, 2016 22:27
-
-
Save NotSoSuper/d6075f901cece6d16bbe443e65ed2f65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retro_regex = re.compile(r"((https)(\:\/\/|)?u3\.photofunia\.com\/.\/results\/.\/.\/.*(\.jpg\?download))") | |
@commands.command() | |
async def retro(self, *, text:str): | |
if len(text) >= 15: | |
text = [text[i:i + 15] for i in range(0, len(text), 15)] | |
else: | |
split = text.split() | |
if len(split) == 1: | |
text = [x for x in text] | |
else: | |
text = split | |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0'} | |
payload = aiohttp.FormData() | |
payload.add_field('current-category', 'all_effects') | |
payload.add_field('bcg', '5') | |
payload.add_field('txt', '4') | |
count = 1 | |
for s in text: | |
if count > 3: | |
break | |
payload.add_field('text'+str(count),s) | |
count += 1 | |
try: | |
with aiohttp.ClientSession() as session: | |
with aiohttp.Timeout(5): | |
async with session.post('https://photofunia.com/effects/retro-wave?server=3', data=payload, headers=headers) as r: | |
txt = await r.text() | |
except asyncio.TimeoutError: | |
return | |
match = self.retro_regex.findall(txt) | |
if match: | |
download_url = match[0][0] | |
b = await self.bytes_download(download_url) | |
await self.bot.upload(b, filename='retro.png') | |
else: | |
await self.bot.say('idk some error') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment