-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI and Gifbomb Tweaks + Drops & Scrapper Gif Update (#465)
* using gpt-4 for aggy now with allowed replies in-channel with limit gifbomb uses timekeeper now * adding new drops / cleanup * bump version * give aggy access to chat history, timeout and forgetfulness * tweak timelimiter * tweak timelimiter * make badge scrapper final gif fade out the scrapped badges * few more minor tweaks * disclaimer tweak
- Loading branch information
1 parent
1de72b8
commit 4c46af3
Showing
10 changed files
with
248 additions
and
121 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,51 @@ | ||
import aiohttp | ||
from common import * | ||
from utils.check_role_access import role_check | ||
from utils.check_channel_access import access_check | ||
from utils.timekeeper import check_timekeeper, set_timekeeper | ||
|
||
@bot.slash_command( | ||
name="gifbomb", | ||
description="Send the 3 Gifs for your query to the channel" | ||
description="Send 3 randomized Gifs for your query to the channel" | ||
) | ||
@commands.check(access_check) | ||
@commands.check(role_check) | ||
async def gifbomb(ctx:discord.ApplicationContext, query:str): | ||
await ctx.defer(ephemeral=False) | ||
channel = ctx.interaction.channel | ||
|
||
async with aiohttp.ClientSession() as session: | ||
key = os.getenv('GOOGLE_API_KEY') | ||
ckey = os.getenv('GOOGLE_CX') | ||
async with session.get( | ||
"https://tenor.googleapis.com/v2/search?q=%s&key=%s&client_key=%s&limit=3&contentfilter=medium&random=true" % (query, key, ckey) | ||
) as response: | ||
if response.status == 200: | ||
await ctx.respond(embed=discord.Embed( | ||
title="GIF BOMB!", | ||
color=discord.Color.blurple() | ||
), ephemeral=False | ||
) | ||
data = json.loads(await response.text()) | ||
results = data['results'] | ||
for r in results: | ||
embed = discord.Embed(color=discord.Color.random()) | ||
image_url = r['media_formats']['gif']['url'] | ||
embed.set_image(url=image_url) | ||
embed.set_footer(text="via Tenor") | ||
await channel.send(embed=embed) | ||
else: | ||
await ctx.respond(embed=discord.Embed( | ||
title="Whoops", | ||
description="There was a problem requesting the Gifs from Tenor!", | ||
color=discord.Color.red() | ||
), ephemeral=True | ||
) | ||
allowed = await check_timekeeper(ctx, 120) | ||
|
||
if allowed: | ||
async with aiohttp.ClientSession() as session: | ||
key = os.getenv('GOOGLE_API_KEY') | ||
ckey = os.getenv('GOOGLE_CX') | ||
async with session.get( | ||
"https://tenor.googleapis.com/v2/search?q=%s&key=%s&client_key=%s&limit=20&contentfilter=medium" % (query, key, ckey) | ||
) as response: | ||
if response.status == 200: | ||
await ctx.respond(embed=discord.Embed( | ||
title="GIF BOMB!", | ||
color=discord.Color.blurple() | ||
) | ||
) | ||
data = json.loads(await response.text()) | ||
results = random.sample(data['results'], 3) | ||
for r in results: | ||
embed = discord.Embed(color=discord.Color.random()) | ||
image_url = r['media_formats']['gif']['url'] | ||
embed.set_image(url=image_url) | ||
embed.set_footer(text="via Tenor") | ||
await channel.send(embed=embed) | ||
set_timekeeper(ctx) | ||
else: | ||
await ctx.respond(embed=discord.Embed( | ||
title="Whoops", | ||
description="There was a problem requesting the Gifs from Tenor!", | ||
color=discord.Color.red() | ||
), ephemeral=True | ||
) | ||
else: | ||
await ctx.respond(embed=discord.Embed( | ||
title="Denied!", | ||
description="Too many gifbombs recently! Give it a minute, Turbo!", | ||
color=discord.Color.red() | ||
), ephemeral=True | ||
) |
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
Oops, something went wrong.