<commit_before># frozen_string_literal: true

require 'discordrb/events/generic'

# Event classes and handlers
module Discordrb::Events
  # Event raised when any dispatch is received
  class RawEvent < Event
    # @return [Symbol] the type of this dispatch.
    attr_reader :type
    alias_method :t, :type

    # @return [Hash] the data of this dispatch.
    attr_reader :data
    alias_method :d, :data

    def initialize(type, data, bot)
      @type = type
      @data = data
      @bot = bot
    end
  end

  # Event handler for {RawEvent}
  class RawEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? RawEvent

      [
        matches_all(@attributes[:t] || @attributes[:type], event.type) do |a, e|
          if a.is_a? Regexp
            # 24: update to matches?
            match = a.match(e)
            match ? (e == match[0]) : false
          else
            e.to_s.casecmp(a.to_s)
          end
        end
      ].reduce(true, &:&)
    end
  end
end
<commit_msg>Fix the comparison in RawEventHandler#matches?<commit_after># frozen_string_literal: true

require 'discordrb/events/generic'

# Event classes and handlers
module Discordrb::Events
  # Event raised when any dispatch is received
  class RawEvent < Event
    # @return [Symbol] the type of this dispatch.
    attr_reader :type
    alias_method :t, :type

    # @return [Hash] the data of this dispatch.
    attr_reader :data
    alias_method :d, :data

    def initialize(type, data, bot)
      @type = type
      @data = data
      @bot = bot
    end
  end

  # Event handler for {RawEvent}
  class RawEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? RawEvent

      [
        matches_all(@attributes[:t] || @attributes[:type], event.type) do |a, e|
          if a.is_a? Regexp
            # 24: update to matches?
            match = a.match(e)
            match ? (e == match[0]) : false
          else
            e.to_s.casecmp(a.to_s).zero?
          end
        end
      ].reduce(true, &:&)
    end
  end
end

{'fraction_non_alphanumeric': 0.09475150952159778, 'fraction_numerical': 0.002786809103576405, 'mean_word_length': 2.2439759036144578, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1851179', 'n_tokens_mistral': 669, 'n_tokens_neox': 657, 'n_words': 212}