enwnbot

Converts MediaWiki [[links]] and {{templates}} to links on IRC
git clone http://git.hanabi.in/repos/enwnbot.git
Log | Files | Refs | README | LICENSE

commit 8905d73e61bf1aff3cfe2d07fb4d639384213575
parent 217fcaede5552fc150ec1de5c5e6920267ed0fb5
Author: Agastya Chandrakant <acagastya@outlook.com>
Date:   Thu, 28 May 2020 23:38:55 +0530

Missing POST req now fixed

Diffstat:
Mutils.js | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/utils.js b/utils.js @@ -45,12 +45,17 @@ async function urlShortener(URI, bot) { const req = `${shortURL}${URI}`; const res = {}; try { - const data = await bot.request({ + const data = await bot.rawRequest({ action: 'shortenurl', format: 'json', - url: req, + uri: req, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, }); - res.url = data.shortenurl.shorturl; + const parsed = JSON.parse(data); + res.url = parsed.shortenurl.shorturl; } catch (error) { res.err = true; console.warn('Error in urlShortener:', error);