rewrite resolve() to use async instead on non-async, should fix #8

This commit is contained in:
2021-06-13 13:29:32 +02:00
parent 042a29f201
commit 4f0b7d7ef4
2 changed files with 14 additions and 5 deletions

View File

@@ -1,12 +1,20 @@
#!/usr/bin/env python 3
from jeevesbot import env
import urllib
# import urllib
import aiohttp
import dice
# This function is necessary for tenor, because they do not allow linking directly to the gif and need resolving.
def resolve(url):
return urllib.request.urlopen(url).url
#def resolve(url):
# return urllib.request.urlopen(url).url
# This function is necessary for tenor, because they do not allow linking directly to the gif and need resolving. ASYNC VERSION
async def resolve(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
message = response.url
return message
# use the dice module for rolling.
def roll(notation):
@@ -25,4 +33,4 @@ def checkchannel(channelid):
if channelid in env.GIFCHANNELS:
return True
else:
return False
return False