forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdns.py
More file actions
53 lines (46 loc) · 1.58 KB
/
dns.py
File metadata and controls
53 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""DA.GD helpers in @UniBorg
Available Commands:
.isup URL
.dns google.com
.url <long url>
.unshort <short url>"""
import requests
from userbot.utils import admin_cmd
@borg.on(admin_cmd("dns (.*)"))
async def _(event):
if event.fwd_from:
return
input_str = event.pattern_match.group(1)
sample_url = "https://da.gd/dns/{}".format(input_str)
response_api = requests.get(sample_url).text
if response_api:
await event.edit("DNS records of {} are \n{}".format(input_str, response_api))
else:
await event.edit("i can't seem to find {} on the internet".format(input_str))
@borg.on(admin_cmd("url (.*)"))
async def _(event):
if event.fwd_from:
return
input_str = event.pattern_match.group(1)
sample_url = "https://da.gd/s?url={}".format(input_str)
response_api = requests.get(sample_url).text
if response_api:
await event.edit("Generated {} for {}.".format(response_api, input_str))
else:
await event.edit("something is wrong. please try again later.")
@borg.on(admin_cmd("unshort (.*)"))
async def _(event):
if event.fwd_from:
return
input_str = event.pattern_match.group(1)
if not input_str.startswith("http"):
input_str = "http://" + input_str
r = requests.get(input_str, allow_redirects=False)
if str(r.status_code).startswith("3"):
await event.edit(
"Input URL: {}\nReDirected URL: {}".format(input_str, r.headers["Location"])
)
else:
await event.edit(
"Input URL {} returned status_code {}".format(input_str, r.status_code)
)