refactor(command|utility): rewrite getheaders
This commit is contained in:
parent
2d175b4453
commit
60f68f245d
7 changed files with 51 additions and 3 deletions
|
@ -76,6 +76,6 @@
|
|||
- [ ] clock *
|
||||
- [ ] ytdiscover
|
||||
- [x] iplocalise
|
||||
- [ ] getheaders
|
||||
- [x] getheaders
|
||||
- [ ] git
|
||||
- [ ] quote
|
|
@ -407,6 +407,13 @@ class Admin(commands.Cog):
|
|||
await ctx.send(f"{Texts('admin').get('Warn with id')} `{warn_id}`"
|
||||
f" {Texts('admin').get('successfully edited')}")
|
||||
|
||||
"""---------------------------------------------------------------------"""
|
||||
|
||||
@commands.command(name='set-language', aliases=['set-lang'])
|
||||
async def _set_language(self, ctx: commands.Context, lang):
|
||||
"""
|
||||
todo: set lang for guild
|
||||
"""
|
||||
|
||||
def setup(bot: TuxBot):
|
||||
bot.add_cog(Admin(bot))
|
||||
|
|
|
@ -139,7 +139,7 @@ class Basics(commands.Cog):
|
|||
|
||||
"""---------------------------------------------------------------------"""
|
||||
|
||||
@commands.command(name='credits', aliases=['contributors'])
|
||||
@commands.command(name='credits', aliases=['contributors', 'authors'])
|
||||
async def _credits(self, ctx: commands.Context):
|
||||
e = discord.Embed(
|
||||
title=Texts('basics').get('Contributors'),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from bot import TuxBot
|
||||
|
@ -70,6 +71,34 @@ class Utility(commands.Cog):
|
|||
content=f"{Texts('utility').get('info not available')}"
|
||||
f"``{response.get('query')}``")
|
||||
|
||||
"""---------------------------------------------------------------------"""
|
||||
|
||||
@commands.command(name='getheaders')
|
||||
async def _getheaders(self, ctx: commands.Context, addr: str):
|
||||
if (addr.startswith('http') or addr.startswith('ftp')) is not True:
|
||||
addr = f"http://{addr}"
|
||||
|
||||
try:
|
||||
async with self.bot.session.get(addr) as s:
|
||||
await ctx.trigger_typing()
|
||||
e = discord.Embed(
|
||||
title=f"{Texts('utility').get('Headers of')} {addr}",
|
||||
color=0xd75858
|
||||
)
|
||||
e.add_field(name="Status", value=s.status, inline=True)
|
||||
e.set_thumbnail(url=f"https://http.cat/{s.status}")
|
||||
|
||||
headers = dict(s.headers.items())
|
||||
headers.pop('Set-Cookie', headers)
|
||||
|
||||
for key, value in headers.items():
|
||||
e.add_field(name=key, value=value, inline=True)
|
||||
await ctx.send(embed=e)
|
||||
|
||||
except aiohttp.client_exceptions.ClientConnectorError:
|
||||
await ctx.send(f"{Texts('utility').get('Cannot connect to host')} "
|
||||
f"{addr}")
|
||||
|
||||
|
||||
def setup(bot: TuxBot):
|
||||
bot.add_cog(Utility(bot))
|
||||
|
|
|
@ -28,4 +28,10 @@ msgid "Is located at :"
|
|||
msgstr ""
|
||||
|
||||
msgid "info not available"
|
||||
msgstr ""
|
||||
|
||||
msgid "Headers of"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cannot connect to host"
|
||||
msgstr ""
|
Binary file not shown.
|
@ -28,4 +28,10 @@ msgid "Is located at :"
|
|||
msgstr "Se situe à :"
|
||||
|
||||
msgid "info not available"
|
||||
msgstr "Erreur, impossible d'obtenir des informations sur cette adresse IP"
|
||||
msgstr "Erreur, impossible d'obtenir des informations sur cette adresse IP"
|
||||
|
||||
msgid "Headers of"
|
||||
msgstr "Entêtes de"
|
||||
|
||||
msgid "Cannot connect to host"
|
||||
msgstr "Impossible de se connecter à l'hôte"
|
||||
|
|
Loading…
Reference in a new issue