<commit_before># Description:
#   In which Hubot gives you bugzilla information
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot bug <number> - Shows bug summary
#
# Author:
#   greenb

QS      = require 'querystring'
Cheerio = require 'cheerio'

module.exports = (robot) ->

  domain = 'http://bugs.sfolab.ibm.com'
  makePath = (bug) ->
    '/bugzilla/show_bug.cgi?id=' + bug

  robot.hear /bug #?(\d+)/ig, (msg) ->
    notUniq = {}
    for b in msg.match
      bug = b.substr b.search /\d/
      if notUniq[bug]
        continue
      notUniq[bug] = true

      params =
        id: bug

      msg.http(domain)
        .path(makePath(bug))
        .header('Content-Type', 'application/x-www-form-urlencoded')
        .post(QS.stringify(params)) (err, res, body) ->
          if err
            msg.send 'Failed to query bug status. ' + err
            return

          if res.statusCode != 200
            msg.send 'Failed to query bug status. Got status ' + res.statusCode
            return

          $ = Cheerio.load body
          title = $('title').text()

          if title != 'Invalid Bug ID'
            msg.send "#{title} #{domain}#{makePath(bug)}"<commit_msg>Fix issue with incorrect bug links when multiple bug numbers given The "bug" variable was not closed over in the for loop. Fix is to move it out into a separate function.<commit_after># Description:
#   In which Hubot gives you bugzilla information
#
# Dependencies:
#   None
#
# Configuration:
#   None
#
# Commands:
#   hubot bug <number> - Shows bug summary
#
# Author:
#   greenb

QS      = require 'querystring'
Cheerio = require 'cheerio'

module.exports = (robot) ->

  domain = 'http://bugs.sfolab.ibm.com'
  makePath = (bug) ->
    '/bugzilla/show_bug.cgi?id=' + bug

  fetchBug = (msg, bug) ->
    params =
      id: bug

    msg.http(domain)
      .path(makePath(bug))
      .header('Content-Type', 'application/x-www-form-urlencoded')
      .post(QS.stringify(params)) (err, res, body) ->
        if err
          msg.send 'Failed to query bug status. ' + err
          return

        if res.statusCode != 200
          msg.send 'Failed to query bug status. Got status ' + res.statusCode
          return

        $ = Cheerio.load body
        title = $('title').text()

        if title != 'Invalid Bug ID'
          msg.send "#{title} #{domain}#{makePath(bug)}"

  robot.hear /bug #?(\d+)/ig, (msg) ->
    notUniq = {}
    for b in msg.match
      bug = b.substr b.search /\d/
      if notUniq[bug]
        continue
      notUniq[bug] = true

      fetchBug msg, bug
{'fraction_non_alphanumeric': 0.13346228239845262, 'fraction_numerical': 0.0023210831721470018, 'mean_word_length': 2.1383495145631066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4297598', 'n_tokens_mistral': 876, 'n_tokens_neox': 836, 'n_words': 236}