<commit_before>Config = require "../config"
Octokat = require "octokat"
Utils = require "../utils"
PullRequest = require "./pullrequest"

octo = new Octokat token: Config.github.token

class Webhook
  constructor: (@robot) ->
    @robot.router.post "/hubot/github-events", (req, res) =>
      return unless req.body?
      event = req.body

      if req.body.pull_request
        @onPullRequest event

  onPullRequest: (event) ->
    return unless event.action is "assigned"
    return unless event.assignee?.url?

    user = null
    sender = null
    Utils.lookupUserWithGithub(octo.fromUrl(event.assignee.url))
    .then (u) ->
      user = u
      Utils.lookupUserWithGithub(octo.fromUrl(event.sender.url))<commit_msg>Add 200 okay to webhook response<commit_after>Config = require "../config"
Octokat = require "octokat"
Utils = require "../utils"
PullRequest = require "./pullrequest"

octo = new Octokat token: Config.github.token

class Webhook
  constructor: (@robot) ->
    @robot.router.post "/hubot/github-events", (req, res) =>
      return unless req.body?
      event = req.body

      if req.body.pull_request
        @onPullRequest event

      res.send 'OK'

  onPullRequest: (event) ->
    return unless event.action is "assigned"
    return unless event.assignee?.url?

    user = null
    sender = null
    Utils.lookupUserWithGithub(octo.fromUrl(event.assignee.url))
    .then (u) ->
      user = u
      Utils.lookupUserWithGithub(octo.fromUrl(event.sender.url))
{'fraction_non_alphanumeric': 0.12331536388140162, 'fraction_numerical': 0.0020215633423180594, 'mean_word_length': 3.057377049180328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '631834', 'n_tokens_mistral': 487, 'n_tokens_neox': 468, 'n_words': 114}