<commit_before>InputView = require '../views/input-view'
AlertView = require '../views/alert-view'
Slack = require 'slack-node'
_ = require 'underscore'

module.exports = SlackInvite =

  inviteOverSlack: ->
    @getKeysFromConfig()

    if @missingPusherKeys()
      new AlertView "Please set your Pusher keys."
    else if @missingSlackWebHook()
      new AlertView "Please set your Slack Incoming WebHook"
    else
      inviteView = new InputView("Please enter the Slack name of your pair partner (or channel name):")
      inviteView.miniEditor.focus()
      inviteView.on 'core:confirm', =>
        messageRcpt = inviteView.miniEditor.getText()
        @sendSlackMessageTo(messageRcpt)
        invitePanel.panel.hide()

  sendSlackMessageTo: (messageRcpt) ->
    #prepare the slack stuff
    slack = new Slack()
    slack.setWebhook @slack_url
    #generate the sessionid
    @generateSessionId()
    #create params
    params =
      text: "Hello there #{messageRcpt}. You have been invited to a pairing session. If you haven't installed the AtomPair plugin, type \`apm install atom-pair\` into your terminal. Go onto Atom, hit 'Join a pairing session', and enter this string: #{@sessionId}"
      channel: messageRcpt
      username: 'AtomPair'
      icon_emoji: ':couple_with_heart:'
    #send a message to the user
    slack.webhook params, (err, response) =>
      new AlertView "#{messageRcpt} has been sent an invitation. Hold tight!"
      @markerColour = @colours[0]
      @pairingSetup()
      return<commit_msg>Fixed issue with undefined slack invite panel<commit_after>InputView = require '../views/input-view'
AlertView = require '../views/alert-view'
Slack = require 'slack-node'
_ = require 'underscore'

module.exports = SlackInvite =

  inviteOverSlack: ->
    @getKeysFromConfig()

    if @missingPusherKeys()
      new AlertView "Please set your Pusher keys."
    else if @missingSlackWebHook()
      new AlertView "Please set your Slack Incoming WebHook"
    else
      inviteView = new InputView("Please enter the Slack name of your pair partner (or channel name):")
      inviteView.miniEditor.focus()
      inviteView.on 'core:confirm', =>
        messageRcpt = inviteView.miniEditor.getText()
        @sendSlackMessageTo(messageRcpt)
        inviteView.panel.hide()

  sendSlackMessageTo: (messageRcpt) ->
    #prepare the slack stuff
    slack = new Slack()
    slack.setWebhook @slack_url
    #generate the sessionid
    @generateSessionId()
    #create params
    params =
      text: "Hello there #{messageRcpt}. You have been invited to a pairing session. If you haven't installed the AtomPair plugin, type \`apm install atom-pair\` into your terminal. Go onto Atom, hit 'Join a pairing session', and enter this string: #{@sessionId}"
      channel: messageRcpt
      username: 'AtomPair'
      icon_emoji: ':couple_with_heart:'
    #send a message to the user
    slack.webhook params, (err, response) =>
      new AlertView "#{messageRcpt} has been sent an invitation. Hold tight!"
      @markerColour = @colours[0]
      @pairingSetup()
      return
{'fraction_non_alphanumeric': 0.09782960803368966, 'fraction_numerical': 0.0006478781988986071, 'mean_word_length': 3.3431786216596344, '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': '5372466', 'n_tokens_mistral': 938, 'n_tokens_neox': 922, 'n_words': 293}