Add lmgtfy
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 16s

This commit is contained in:
Nexus 2024-05-12 17:59:56 +01:00
parent d610b8ba78
commit dc4364c9f3

View file

@ -6,7 +6,7 @@ import logging
import pathlib import pathlib
import subprocess import subprocess
import tempfile import tempfile
from urllib.parse import urlparse, ParseResult from urllib.parse import urlparse, ParseResult, quote_plus
import aiohttp import aiohttp
import discord import discord
@ -32,6 +32,7 @@ class AutoResponder(commands.Cog):
"overrule_offline_superiors is enabled, however presences intent is not!" "overrule_offline_superiors is enabled, however presences intent is not!"
) )
self.config.setdefault("transcoding", {"enabled": True, "hevc": True, "on_demand": True}) self.config.setdefault("transcoding", {"enabled": True, "hevc": True, "on_demand": True})
self.lmgtfy_cache = []
@property @property
def transcoding_enabled(self) -> bool: def transcoding_enabled(self) -> bool:
@ -365,6 +366,12 @@ class AutoResponder(commands.Cog):
extra = [attachment.url for attachment in reaction.message.attachments] extra = [attachment.url for attachment in reaction.message.attachments]
if self.allow_on_demand_transcoding: if self.allow_on_demand_transcoding:
await self.transcode_hevc_to_h264(reaction.message, additional=extra) await self.transcode_hevc_to_h264(reaction.message, additional=extra)
if isinstance(reaction.emoji, (discord.PartialEmoji, discord.Emoji)):
if reaction.emoji.name == "google_it" and reaction.message.id not in self.lmgtfy_cache:
await reaction.message.reply(
"https://letmegooglethat.com/?q=" + quote_plus(reaction.message.content)
)
self.lmgtfy_cache.append(reaction.message.id)
@commands.Cog.listener("on_raw_reaction_add") @commands.Cog.listener("on_raw_reaction_add")
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent): async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):