<commit_before>class Bot
  def modules_reload
    @modules = []
    Dir.new(@modules_dir).entries.
      select { |m| m =~ /^module_.*\.rb$/ }.
      map { |m| 
        m =~ /^module_(.*)\.rb$/
        $1
      }.
      delete_if { |m| @excluded_modules.include?(m) }.each { |m|
        begin
          Kernel.load("#{@modules_dir}/module_#{m}.rb")
          @modules.push(m)
          puts "Registered module #{m}"
          begin
            init_method = "#{m}_initialize"
            method(init_method).call(self)
          rescue NoMethodError => nme
          rescue NameError => ne
          rescue Exception => e
            puts "Error initializing module #{m}: #{e}"
            print e.backtrace.join("\n")
          end
        rescue Exception => e
          puts "Error registering module #{m}: #{e.message}"
          print e.backtrace.join("\n")
        end
      }
  end

  def modules_privmsg(from, reply_to, msg)
    @modules.each { |m|
      begin
        name = "#{m}_privmsg"
        method(name).call(self, from, reply_to, msg)
      rescue NoMethodError => nme
      rescue Exception => e
        puts "Error calling privmsg for #{m}: #{e.message}"
        print e.backtrace.join("\n")
      end
    }
  end
end<commit_msg>Catch name errors for module privmsg calls also<commit_after>class Bot
  def modules_reload
    @modules = []
    Dir.new(@modules_dir).entries.
      select { |m| m =~ /^module_.*\.rb$/ }.
      map { |m| 
        m =~ /^module_(.*)\.rb$/
        $1
      }.
      delete_if { |m| @excluded_modules.include?(m) }.each { |m|
        begin
          Kernel.load("#{@modules_dir}/module_#{m}.rb")
          @modules.push(m)
          puts "Registered module #{m}"
          begin
            init_method = "#{m}_initialize"
            method(init_method).call(self)
          rescue NoMethodError => nme
          rescue NameError => ne
          rescue Exception => e
            puts "Error initializing module #{m}: #{e}"
            print e.backtrace.join("\n")
          end
        rescue Exception => e
          puts "Error registering module #{m}: #{e.message}"
          print e.backtrace.join("\n")
        end
      }
  end

  def modules_privmsg(from, reply_to, msg)
    @modules.each { |m|
      begin
        name = "#{m}_privmsg"
        method(name).call(self, from, reply_to, msg)
      rescue NoMethodError => nme
      rescue NameError => ne
      rescue Exception => e
        puts "Error calling privmsg for #{m}: #{e.message}"
        print e.backtrace.join("\n")
      end
    }
  end
end
{'fraction_non_alphanumeric': 0.14146150840171942, 'fraction_numerical': 0.0007815552950371239, 'mean_word_length': 1.8008752735229758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '5961555', 'n_tokens_mistral': 797, 'n_tokens_neox': 805, 'n_words': 195}