forked from kappithannemo/WhatsAsenaDuplicated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitly.js
25 lines (23 loc) · 1.02 KB
/
bitly.js
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
/* Copyright (C) 2020 Yusuf Usta.
Licensed under the GPL-3.0 License;
you may not use this file except in compliance with the License.
WhatsAsena - Yusuf Usta
*/
const Asena = require('../events');
const {MessageType} = require('@adiwajshing/baileys');
const got = require('got');
const Config = require('../config');
const Language = require('../language');
const Lang = Language.getString('weather');
Asena.addCommand({pattern: 'bitly ?(.*)', fromMe: false, desc: Lang.BIT_DESC}, async (message, match) => {
if (match[1] === '') return await message.reply(Lang.NEED_LINK);
const url = `https://tobz-api.herokuapp.com/api/bitly?url=${match[1]}&apikey=${Config.TOBZ_API_KEY}`;
try {
const response = await got(url);
const json = JSON.parse(response.body);
if (response.statusCode === 200) return await message.client.sendMessage(message.jid,
'\n *🔗 ' + Lang.SLINK +'* ```' + json.result + '```\n\n', MessageType.text);
} catch {
return await message.client.sendMessage(message.jid, Lang.NOT_FOUNDLI, MessageType.text);
}
});