<commit_before>Robot = require "robot"
Irc   = require "irc"

class IrcBot extends Robot
  send: (user, strings...) ->
    strings.forEach (str) =>
      console.log "#{user.name}: #{str}"
      @bot.say(user.room, str)

  reply: (user, strings...) ->
    strings.forEach (str) =>
      @send user, "#{user.name}: #{str}"

  run: ->
    self = @
    options =
      server:   process.env.HUBOT_IRC_SERVER
      rooms:   process.env.HUBOT_IRC_ROOMS.split(",")
      nick: process.env.HUBOT_IRC_NICK

    console.log options

    bot = new Irc.Client options.server, options.nick, {
      debug: true,
      channels: options.rooms,
    }

    next_id = 1
    user_id = {}

    bot.addListener 'message', (from, toRoom, message) ->
      console.log "From #{from} to #{toRoom}: #{message}"

      if message.match new RegExp "^#{options.nick}", "i"
        unless user_id[from]
          user_id[from] = next_id
          next_id = next_id + 1

        user = new Robot.User user_id[from], from || "user", {
          room: toRoom,
        }

      self.receive new Robot.Message(user, message)
<commit_msg>Fix for irc not replying #20<commit_after>Robot = require "robot"
Irc   = require "irc"

class IrcBot extends Robot
  send: (user, strings...) ->
    strings.forEach (str) =>
      console.log "#{user.name}: #{str}"
      @bot.say(user.room, str)

  reply: (user, strings...) ->
    strings.forEach (str) =>
      @send user, "#{user.name}: #{str}"

  run: ->
    self = @
    options =
      server:   process.env.HUBOT_IRC_SERVER
      rooms:   process.env.HUBOT_IRC_ROOMS.split(",")
      nick: process.env.HUBOT_IRC_NICK

    console.log options

    bot = new Irc.Client options.server, options.nick, {
      debug: true,
      channels: options.rooms,
    }

    next_id = 1
    user_id = {}

    bot.addListener 'message', (from, toRoom, message) ->
      console.log "From #{from} to #{toRoom}: #{message}"

      if message.match new RegExp "^#{options.nick}", "i"
        unless user_id[from]
          user_id[from] = next_id
          next_id = next_id + 1

      user = new Robot.User user_id[from], {
        room: toRoom,
      }

      self.receive new Robot.Message(user, message)

{'fraction_non_alphanumeric': 0.14798002723558784, 'fraction_numerical': 0.0027235587834770767, 'mean_word_length': 2.354642313546423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5483917', 'n_tokens_mistral': 779, 'n_tokens_neox': 753, 'n_words': 179}