forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shorturl.py
37 lines (30 loc) · 940 Bytes
/
shorturl.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
37
# from Freaky Userbot
# Ported for Ultroid Userbot
"""
✘ Commands Available -
• `{i}shorturl <url>`
Get the shorted form of given url.
"""
import pyshorteners
from . import *
@ultroid_cmd(pattern="shorturl ?(.*)")
async def vom(event):
a = await eor(event, "`Processing...`")
try:
link = event.pattern_match.group(1)
if not link:
return await a.edit("`Please Give me a Link to Shorten`")
txt = pyshorteners.Shortener()
if "http://tinyurl.com" in link.lower():
ok = txt.tinyurl.expand(link)
eu = "Expanded"
else:
ok = txt.tinyurl.short(link)
eu = "Shortned"
short = (
f"**Url {eu}**\n**Given Link** ➠ {link}\n"
f"**{eu} Link** ➠ [{eu} Link]({ok})"
)
await a.edit(short)
except Exception as e:
await a.edit("SomeThing Went Wrong. \n**ERROR** : " + str(e))