<commit_before>_ = require("underscore")
FuzzySearch = require('fuzzysearch-js')
levenshteinFS = require('fuzzysearch-js/js/modules/LevenshteinFS')

module.exports = {}

sassyMessages = [

  # English
  ["us", "Just a second"]
  ["us", "Thinking"]
  ["ca", "On it"]
  ["us", "Working on it"]
  ["gb", "Queueing"]
  ["gb", "Having a think"]
  ["ca", "One moment please"]
  ["in", "Give me a minute"]
  ["pk", "Hold on"]
  ["ng", "Looking into it"]
  ["ph", "One sec"]
  ["ph", "Working it out"]
  ["us", "Hold please"]
  ["eg", "Wait a moment"]
  ["eg", "Hmm"]

  # Cooler Languages
  ["es", "Un momento, por favor"]
  ["mx", "Por favor espera"]
  ["de", "Bitte warten Sie einen Augenblick"]
  ["jp", "お待ちください"]
  ["ca", "Un moment s'il vous plait"]
  ["cn", "稍等一會兒"]
  ["nl", "Even geduld aub"]
  ["so", "Ka shaqeeya waxaa ku"]
  ["th", "กรุณารอสักครู่"]
  ["ru", "один момент, пожалуйста"]
  ["fi", "Hetkinen"]
  ["ro", "De lucru pe ea"]
  ["is", "Eitt andartak"]
  ["az", "Bir dəqiqə zəhmət olmasa"]
  ["ie", "Fán le do thoil"]
  ["ne", "कृपया पर्खनुहोस्"]
  ["in", "कृपया एक क्षण के लिए"]

].map(([country, message] = pair) ->
  translate = "http://translate.google.com/#auto/auto/#{encodeURIComponent(message)}"
  "<#{translate}|:flag-#{country}:> _#{message}..._"
)

module.exports.FancyReplier = class FancyReplier

  constructor: (@replyContext) ->

  reply: (obj, cb) ->
    if @loadingMessage

      # Hacky stealth update of message to preserve chat order

      if typeof(obj) == 'string'
        obj = {text: obj, channel: @replyContext.sourceMessage.channel}

      params = {ts: @loadingMessage.ts, channel: @replyContext.sourceMessage.channel}

      update = _.extend(params, obj)
      update.attachments = if update.attachments then JSON.stringify(update.attachments) else null
      update.text = update.text || " "

      @replyContext.defaultBot.api.chat.update(update)

    else
      @replyContext.replyPublic(obj, cb)

  startLoading: (cb) ->

    sass = sassyMessages[Math.floor(Math.random() * sassyMessages.length)]

    if process.env.DEV
      sass = "[DEVELOPMENT] #{sass}"

    params =
      text: sass
      as_user: true
      attachments: [] # Override some Botkit stuff
      unfurl_links: false
      unfurl_media: false

    @replyContext.replyPublic(params, (error, response) =>
      @loadingMessage = response
      cb()
    )

  start: ->
    @replyContext.startTyping()
    if process.env.LOOKER_SLACKBOT_STEALTH_EDIT == "true"
      @startLoading(=>
        @replyContext.startTyping()
        @work()
      )
    else<commit_msg>no loading indicator for slash commands<commit_after>_ = require("underscore")
FuzzySearch = require('fuzzysearch-js')
levenshteinFS = require('fuzzysearch-js/js/modules/LevenshteinFS')

module.exports = {}

sassyMessages = [

  # English
  ["us", "Just a second"]
  ["us", "Thinking"]
  ["ca", "On it"]
  ["us", "Working on it"]
  ["gb", "Queueing"]
  ["gb", "Having a think"]
  ["ca", "One moment please"]
  ["in", "Give me a minute"]
  ["pk", "Hold on"]
  ["ng", "Looking into it"]
  ["ph", "One sec"]
  ["ph", "Working it out"]
  ["us", "Hold please"]
  ["eg", "Wait a moment"]
  ["eg", "Hmm"]

  # Cooler Languages
  ["es", "Un momento, por favor"]
  ["mx", "Por favor espera"]
  ["de", "Bitte warten Sie einen Augenblick"]
  ["jp", "お待ちください"]
  ["ca", "Un moment s'il vous plait"]
  ["cn", "稍等一會兒"]
  ["nl", "Even geduld aub"]
  ["so", "Ka shaqeeya waxaa ku"]
  ["th", "กรุณารอสักครู่"]
  ["ru", "один момент, пожалуйста"]
  ["fi", "Hetkinen"]
  ["ro", "De lucru pe ea"]
  ["is", "Eitt andartak"]
  ["az", "Bir dəqiqə zəhmət olmasa"]
  ["ie", "Fán le do thoil"]
  ["ne", "कृपया पर्खनुहोस्"]
  ["in", "कृपया एक क्षण के लिए"]

].map(([country, message] = pair) ->
  translate = "http://translate.google.com/#auto/auto/#{encodeURIComponent(message)}"
  "<#{translate}|:flag-#{country}:> _#{message}..._"
)

module.exports.FancyReplier = class FancyReplier

  constructor: (@replyContext) ->

  reply: (obj, cb) ->
    if @loadingMessage

      # Hacky stealth update of message to preserve chat order

      if typeof(obj) == 'string'
        obj = {text: obj, channel: @replyContext.sourceMessage.channel}

      params = {ts: @loadingMessage.ts, channel: @replyContext.sourceMessage.channel}

      update = _.extend(params, obj)
      update.attachments = if update.attachments then JSON.stringify(update.attachments) else null
      update.text = update.text || " "

      @replyContext.defaultBot.api.chat.update(update)

    else
      @replyContext.replyPublic(obj, cb)

  startLoading: (cb) ->

    # Slash commands responses at the moment can't get the responding message
    # so we won't be able to update or delete it.
    if @replyContext.isSlashCommand()
      return

    sass = sassyMessages[Math.floor(Math.random() * sassyMessages.length)]

    if process.env.DEV
      sass = "[DEVELOPMENT] #{sass}"

    params =
      text: sass
      as_user: true
      attachments: [] # Override some Botkit stuff
      unfurl_links: false
      unfurl_media: false

    @replyContext.replyPublic(params, (error, response) =>
      @loadingMessage = response
      cb()
    )

  start: ->
    @replyContext.startTyping()
    if process.env.LOOKER_SLACKBOT_STEALTH_EDIT == "true"
      @startLoading(=>
        @replyContext.startTyping()
        @work()
      )
    else
{'fraction_non_alphanumeric': 0.17725065371684723, 'fraction_numerical': 0.0, 'mean_word_length': 3.3643031784841075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3707397', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1971, 'n_words': 478}