Compare commits

..

2 commits

Author SHA1 Message Date
e2059eac77
Merge branch 'main' of https://www.coastalcommits.com/Seaswimmer/SeaCogs
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 24s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 36s
2024-05-28 16:23:56 -04:00
e9c062afa9
feat(seautils): added dig command 2024-05-28 16:22:22 -04:00

View file

@ -5,6 +5,7 @@
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
import asyncio
import inspect
import operator
from functools import partial, partialmethod
@ -82,3 +83,22 @@ class SeaUtils(commands.Cog):
await ctx.send(embed=embed, reference=ctx.message.to_reference(fail_if_not_exists=False))
else:
await ctx.send(content="Object not found!", reference=ctx.message.to_reference(fail_if_not_exists=False))
@commands.command(name='dig', aliases=['dnslookup', 'nslookup'])
@commands.is_owner()
async def dig(self, ctx: commands.Context, name: str, type: str | None = 'A', server: str | None = None, port: int = 53) -> None:
"""Retrieve DNS information for a domain."""
command_opts: list[str | int] = ['dig']
if server:
command_opts.extend(['@', server])
command_opts.extend([name, type])
if port != 53:
command_opts.extend(['-p', port])
command_opts.extend(['+yaml'])
process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
stdout, stderr = await process.communicate()
if stderr:
await ctx.send(content=cf.box(text=stderr.decode()))
else:
await ctx.send(content=cf.box(text=stdout.decode(), lang='yaml'))