diff options
| author | salmonik <raisersoft@proton.me> | 2026-01-15 14:37:22 +0100 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-01-15 14:37:22 +0100 |
| commit | edff41f3468996dad5e66d34ac8ab1f5a238751f (patch) | |
| tree | 33a567cd202fedf010764c3e4b8cae8827851f7f /cogs/web.py | |
| parent | asyncio issues when starting (diff) | |
| download | senator-sperma-edff41f3468996dad5e66d34ac8ab1f5a238751f.tar.gz senator-sperma-edff41f3468996dad5e66d34ac8ab1f5a238751f.zip | |
minor improvements
Diffstat (limited to 'cogs/web.py')
| -rw-r--r-- | cogs/web.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cogs/web.py b/cogs/web.py index 9431e84..224df82 100644 --- a/cogs/web.py +++ b/cogs/web.py | |||
| @@ -24,7 +24,8 @@ class Web(commands.Cog): | |||
| 24 | ): | 24 | ): |
| 25 | await ctx.defer(ephemeral=True) | 25 | await ctx.defer(ephemeral=True) |
| 26 | headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} | 26 | headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} |
| 27 | url = f"https://duckduckgo.com/html/?q={query}" | 27 | encoded_query = urllib.parse.quote_plus(query) |
| 28 | url = f"https://duckduckgo.com/html/?q={encoded_query}" | ||
| 28 | response = requests.get(url, headers=headers) | 29 | response = requests.get(url, headers=headers) |
| 29 | 30 | ||
| 30 | logger.info(f"Query: {query}") | 31 | logger.info(f"Query: {query}") |
| @@ -47,8 +48,10 @@ class Web(commands.Cog): | |||
| 47 | title = yt.title | 48 | title = yt.title |
| 48 | except Exception: | 49 | except Exception: |
| 49 | pass | 50 | pass |
| 51 | |||
| 50 | embed.add_field(name=f"Result {i}", value=f"[{title}]({link.get('href')})", inline=False) | 52 | embed.add_field(name=f"Result {i}", value=f"[{title}]({link.get('href')})", inline=False) |
| 51 | button = discord.ui.Button(label=f"Send Result {i}") | 53 | button = discord.ui.Button(label=f"Send Result {i}") |
| 54 | |||
| 52 | async def button_callback(interaction: discord.Interaction, link=link): | 55 | async def button_callback(interaction: discord.Interaction, link=link): |
| 53 | await interaction.response.send_message(link.get('href')) | 56 | await interaction.response.send_message(link.get('href')) |
| 54 | button.callback = button_callback | 57 | button.callback = button_callback |
