testscript

This commit is contained in:
H.J.A. Timmermans Timmermans 2022-03-17 13:13:52 +01:00
commit e5e9b61cc3

26
bing.coffee Normal file
View File

@ -0,0 +1,26 @@
# Description:
# Returns the URL of the first bing hit for a query
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot bing me <query> - Bings <query> & 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(/<div class="sb_tlst"><h3><a href="([^"]*)"/)?[1] || "Sorry, Bing had zero results for '#{query}'"