2021-06-06 22:08:18 +02:00
|
|
|
#!/usr/bin/env python 3
|
|
|
|
|
|
|
|
|
|
from jeevesbot import env
|
2021-06-13 13:29:32 +02:00
|
|
|
import aiohttp
|
2021-06-06 22:08:18 +02:00
|
|
|
import dice
|
|
|
|
|
|
2021-06-13 13:29:32 +02:00
|
|
|
# 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
|
2021-06-13 14:01:23 +02:00
|
|
|
return str(message)
|
2021-06-06 22:08:18 +02:00
|
|
|
|
2021-06-07 17:10:47 +02:00
|
|
|
# use the dice module for rolling.
|
2021-06-06 22:08:18 +02:00
|
|
|
def roll(notation):
|
|
|
|
|
roll = dice.roll(notation)
|
|
|
|
|
result = int(roll)
|
|
|
|
|
return roll,result
|
|
|
|
|
|
2021-06-07 17:10:47 +02:00
|
|
|
# check if user has admin role and output True if it's the case.
|
2021-06-06 22:08:18 +02:00
|
|
|
def checkrole(roles):
|
|
|
|
|
for role in roles:
|
|
|
|
|
if str(role) == env.ADMIN_ROLE:
|
|
|
|
|
return True
|
|
|
|
|
|
2021-06-07 17:10:47 +02:00
|
|
|
# check if the source channel is in the list of channels that are watched by the bot.
|
2021-06-06 22:08:18 +02:00
|
|
|
def checkchannel(channelid):
|
2023-03-24 10:04:50 +01:00
|
|
|
if channelid in env.PREVIEWCHANNELS:
|
2021-06-06 22:08:18 +02:00
|
|
|
return True
|
|
|
|
|
else:
|
2021-07-09 11:11:09 +02:00
|
|
|
return False
|
|
|
|
|
|