SHARE
TWEET

Untitled

Nickster258 Dec 6th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function triggerLinkEvent(user, message) {
  2.     var messageUrl = message.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
  3.     if (messageUrl !== null) {
  4.         var domain = "";
  5.         var title = "";
  6.         var details = fetch(messageUrl[0])
  7.             .then(res => {
  8.                 if (!res.ok) {
  9.                     throw InvalidResponseCode(res.statusText);
  10.                 }
  11.                 domain = url.parse(res.url).hostname;
  12.                 return res;
  13.             })
  14.             .then(res => res.text())
  15.             .then(body => {
  16.                 const $ = cheerio.load(body);
  17.                 title = $('title').html();
  18.                 sendTo("irc", ircChannel, domain + " | " + entities.decode($('title').html()));
  19.             })
  20.             .catch();
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top