diff --git a/README.md b/README.md index 07717db..2010f04 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,6 @@ - [ ] clock * - [ ] ytdiscover - [x] iplocalise - - [ ] getheaders + - [x] getheaders - [ ] git - [ ] quote \ No newline at end of file diff --git a/cogs/admin.py b/cogs/admin.py index 4bbb35b..cc7c42f 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -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)) diff --git a/cogs/basics.py b/cogs/basics.py index 3f43f06..ff41266 100644 --- a/cogs/basics.py +++ b/cogs/basics.py @@ -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'), diff --git a/cogs/utility.py b/cogs/utility.py index ecf6cb0..381894d 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -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)) diff --git a/extras/locales/en/LC_MESSAGES/utility.po b/extras/locales/en/LC_MESSAGES/utility.po index d72dedf..fb63db9 100644 --- a/extras/locales/en/LC_MESSAGES/utility.po +++ b/extras/locales/en/LC_MESSAGES/utility.po @@ -28,4 +28,10 @@ msgid "Is located at :" msgstr "" msgid "info not available" +msgstr "" + +msgid "Headers of" +msgstr "" + +msgid "Cannot connect to host" msgstr "" \ No newline at end of file diff --git a/extras/locales/fr/LC_MESSAGES/utility.mo b/extras/locales/fr/LC_MESSAGES/utility.mo index f5d6167..b39c851 100644 Binary files a/extras/locales/fr/LC_MESSAGES/utility.mo and b/extras/locales/fr/LC_MESSAGES/utility.mo differ diff --git a/extras/locales/fr/LC_MESSAGES/utility.po b/extras/locales/fr/LC_MESSAGES/utility.po index 3e740fb..84c8811 100644 --- a/extras/locales/fr/LC_MESSAGES/utility.po +++ b/extras/locales/fr/LC_MESSAGES/utility.po @@ -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" \ No newline at end of file +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"