<commit_before># -*- encoding : utf-8 -*-
module Linael
  class Modules::ModuleType
    
    attr_accessor :blackList,:whiteList

    def in_blacklist?(chan)
      @blackList.include?(chan.downcase) if blackList?
    end

    def in_whitelist?(chan)
        return @whiteList.include?(chan.downcase) if whiteList?
        true
    end

    def self.define_anylist color
      define_method color+"list?" do
          send(color+"List")
      end
      define_method color+"list" do |chan|
        send(color+"List").= [] unless send(color+"List?")
        send(color+"List").<< chan.downcase
      end
      define_method "un_"+color+"list" do |chan|
        send(color+"List").delete(chan)
        send(color+"List").= nil if send(color+"List").empty?
      end
    end

    define_anylist "black"
    define_anylist "white"

  end

  class ModuleIRC

    def act_authorized?(instance,msg)
      moduleAdmin = @runner.modules.detect {|mod| mod.class == Modules::Module}
      mod = moduleAdmin.modules[instance.class::Name]
      result = true
      result &= !mod.in_blacklist?(msg.place) 
      result &= mod.in_whitelist?(msg.place) 
      result
    end

  end

  class Modules::Blacklist < ModuleIRC

    Name="blacklist"

    def startMod
      add_module({cmdAuth: [:whiteList,
                            :blackList]})
    end
<commit_msg>supression d'un bout de code dupliqué<commit_after># -*- encoding : utf-8 -*-
module Linael
  class Modules::ModuleType
    
    attr_accessor :blackList,:whiteList

    def in_blacklist?(chan)
      @blackList.include?(chan.downcase) if blackList?
    end

    def in_whitelist?(chan)
        return @whiteList.include?(chan.downcase) if whiteList?
        true
    end
    
    ["black","white"].each do |color|
      define_method color+"list?" do
          send(color+"List")
      end
      define_method color+"list" do |chan|
        (send(color+"List")).= [] unless send(color+"List?")
        send(color+"List").<< chan.downcase
      end
      define_method "un_"+color+"list" do |chan|
        send(color+"List").delete(chan)
        send(color+"List").= nil if send(color+"List").empty?
      end
    end

  end

  class ModuleIRC

    def act_authorized?(instance,msg)
      moduleAdmin = @runner.modules.detect {|mod| mod.class == Modules::Module}
      mod = moduleAdmin.modules[instance.class::Name]
      result = true
      result &= !mod.in_blacklist?(msg.place) 
      result &= mod.in_whitelist?(msg.place) 
      result
    end

  end

  class Modules::Blacklist < ModuleIRC

    Name="blacklist"

    def startMod
      add_module({cmdAuth: [:whiteList,
                            :blackList]})
    end

{'fraction_non_alphanumeric': 0.12710280373831775, 'fraction_numerical': 0.0007476635514018691, 'mean_word_length': 2.563249001331558, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '3592129', 'n_tokens_mistral': 854, 'n_tokens_neox': 841, 'n_words': 175}