-
Notifications
You must be signed in to change notification settings - Fork 1
/
extensions.py
36 lines (32 loc) · 1.12 KB
/
extensions.py
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
import requests
from bs4 import BeautifulSoup
from . import *
@bot.on(d3vil_cmd(pattern="fext (.*)"))
@bot.on(sudo_cmd(pattern="fext (.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
sample_url = "https://www.fileext.com/file-extension/{}.html"
input_str = event.pattern_match.group(1).lower()
response_api = requests.get(sample_url.format(input_str))
status_code = response_api.status_code
if status_code == 200:
raw_html = response_api.content
soup = BeautifulSoup(raw_html, "html.parser")
ext_details = soup.find_all("td", {"colspan": "3"})[-1].text
await edit_or_reply(
event,
"**File Extension**: `{}`\n**Description**: `{}`".format(
input_str, ext_details
),
)
else:
await edit_or_reply(
event,
"https://www.fileext.com/ responded with {} for query: {}".format(
status_code, input_str
),
)
CmdHelp("fileext").add_command(
"filext", "<extension name>", "Shows you the detailed information of that extension type."
).add()