<commit_before>class Service::IRC < Service
  def receive_push
    return if distinct_commits.empty?

    rooms   = data['room'].gsub(",", " ").split(" ").map{|room| room[0].chr == '#' ? room : "##{room}"}
    botname = data['nick'].to_s.empty? ? "GitHub#{rand(200)}" : data['nick']
    url     = data['long_url'].to_i == 1 ? summary_url : shorten_url(summary_url)

    messages = []
    messages << "#{summary_message}: #{url}"
    messages += commit_messages.first(3)

    self.puts "PASS #{data['password']}" if data['password'] && !data['password'].empty?
    self.puts "NICK #{botname}"
    self.puts "USER #{botname} 8 * :GitHub IRCBot"

    loop do
      case self.gets
      when / 00[1-4] #{botname} /
        break
      when /^PING\s*:\s*(.*)$/
        self.puts "PONG #{$1}"
      end
    end

    without_join = data['message_without_join'] == '1'
    rooms.each do |room|
      room, pass = room.split("::")
      self.puts "JOIN #{room} #{pass}" unless without_join

      messages.each do |message|
        self.puts "PRIVMSG #{room} :#{message}"
      end

      self.puts "PART #{room}" unless without_join
    end

    self.puts "QUIT"
    self.gets until self.eof?
  rescue SocketError => boom
    if boom.to_s =~ /getaddrinfo: Name or service not known/
      raise_config_error 'Invalid host'
    elsif boom.to_s =~ /getaddrinfo: Servname not supported for ai_socktype/
      raise_config_error 'Invalid port'
    else
      raise
    end<commit_msg>escape the irc bot name in the regex<commit_after>class Service::IRC < Service
  def receive_push
    return if distinct_commits.empty?

    rooms   = data['room'].gsub(",", " ").split(" ").map{|room| room[0].chr == '#' ? room : "##{room}"}
    botname = data['nick'].to_s.empty? ? "GitHub#{rand(200)}" : data['nick']
    url     = data['long_url'].to_i == 1 ? summary_url : shorten_url(summary_url)

    messages = []
    messages << "#{summary_message}: #{url}"
    messages += commit_messages.first(3)

    self.puts "PASS #{data['password']}" if data['password'] && !data['password'].empty?
    self.puts "NICK #{botname}"
    self.puts "USER #{botname} 8 * :GitHub IRCBot"

    loop do
      case self.gets
      when / 00[1-4] #{Regexp.escape(botname)} /
        break
      when /^PING\s*:\s*(.*)$/
        self.puts "PONG #{$1}"
      end
    end

    without_join = data['message_without_join'] == '1'
    rooms.each do |room|
      room, pass = room.split("::")
      self.puts "JOIN #{room} #{pass}" unless without_join

      messages.each do |message|
        self.puts "PRIVMSG #{room} :#{message}"
      end

      self.puts "PART #{room}" unless without_join
    end

    self.puts "QUIT"
    self.gets until self.eof?
  rescue SocketError => boom
    if boom.to_s =~ /getaddrinfo: Name or service not known/
      raise_config_error 'Invalid host'
    elsif boom.to_s =~ /getaddrinfo: Servname not supported for ai_socktype/
      raise_config_error 'Invalid port'
    else
      raise
    end
{'fraction_non_alphanumeric': 0.1613011401743796, 'fraction_numerical': 0.008718980549966466, 'mean_word_length': 2.8292682926829267, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 5, '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': '7610769', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1015, 'n_words': 250}