Skip to content

Commit

Permalink
implement caption command
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilgames32 committed Mar 30, 2024
1 parent 1123424 commit 92843f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ conf.json
gif-collections.json
__pycache__/
.venv/
.env
.env
.vscode/
2 changes: 1 addition & 1 deletion caption
18 changes: 13 additions & 5 deletions cogs/captioncog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@
from discord.ext import commands

from util.const import labowor
from util.msgutil import devcheck, errorembed

from caption.src.pipeline import caption

class CaptionCog(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
print("Loaded", __class__.__name__)

# rss feedparse for twokinds
# caption gifs and stuff
@app_commands.command(name="caption", description="caption media")
async def twokinds(self, interaction: discord.Interaction, link: str, caption: str):
await interaction.response.defer()
# TODO: make async
async def twokinds(self, interaction: discord.Interaction, link: str, text: str):
if not await devcheck(interaction):
return

await interaction.followup.send("", file=discord.File())
await interaction.response.defer()
try:
out = caption(link, text, silent=False)
await interaction.followup.send(text, file=discord.File(out))
except Exception as e:
await interaction.followup.send(embed=errorembed(str(e)))



async def setup(bot: commands.Bot) -> None:
Expand Down

0 comments on commit 92843f7

Please sign in to comment.