From e5e9b61cc34f08460ff1fc71a85c281b52b50ab7 Mon Sep 17 00:00:00 2001 From: henk Date: Thu, 17 Mar 2022 13:13:52 +0100 Subject: [PATCH] testscript --- bing.coffee | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bing.coffee diff --git a/bing.coffee b/bing.coffee new file mode 100644 index 0000000..5d743c3 --- /dev/null +++ b/bing.coffee @@ -0,0 +1,26 @@ + +# Description: +# Returns the URL of the first bing hit for a query +# +# Dependencies: +# None +# +# Configuration: +# None +# +# Commands: +# hubot bing me - Bings & returns 1st result's URL +# +# Author: +# Brandon Satrom + +module.exports = (robot) -> + robot.respond /(bing)( me)? (.*)/i, (msg) -> + bingMe msg, msg.match[3], (url) -> + msg.send url + +bingMe = (msg, query, cb) -> + msg.http('http://www.bing.com/search') + .query(q: query) + .get() (err, res, body) -> + cb body.match(/