-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47609b2
commit 245a6dd
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
let handler = async (m, { conn, args, text }) => { | ||
if (!text) throw '*Please provide a URL or link to shorten.*'; | ||
|
||
let shortUrl1 = await (await fetch(`https://tinyurl.com/api-create.php?url=${args[0]}`)).text(); | ||
|
||
if (!shortUrl1) throw `*Error: Could not generate a short URL.*`; | ||
|
||
let done = `*SHORT URL CREATED!!*\n\n*Original Link:*\n${text}\n*Shortened URL:*\n${shortUrl1}`.trim(); | ||
|
||
m.reply(done); | ||
}; | ||
|
||
handler.help = ['tinyurl', 'shorten'].map(v => v + ' <link>'); | ||
handler.tags = ['tools']; | ||
handler.command = /^(tinyurl|short|acortar|corto)$/i; | ||
handler.fail = null; | ||
|
||
export default handler; |