<commit_before>require 'discordrb/events/generic'
require 'discordrb/data'
require 'discordrb/games'

module Discordrb::Events
  # Event raised when a user's presence state updates (idle or online)
  class PresenceEvent
    attr_reader :server, :user, :status

    def initialize(data, bot)
      @user = bot.user(data['user']['id'].to_i)
      @status = data['status'].to_sym
      @server = bot.server(data['guild_id'].to_i)
    end
  end

  # Event handler for PresenceEvent
  class PresenceEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? PresenceEvent

      [
        matches_all(@attributes[:from], event.user) do |a, e|
          if a.is_a? String
            a == e.name
          elsif a.is_a? Fixnum
            a == e.id
          else
            a == e
          end
        end,
        matches_all(@attributes[:status], event.status) do |a, e|
          if a.is_a? String
            a == e.to_s
          else
            a == e
          end
        end
      ].reduce(true, &:&)
    end
  end

  # Event raised when a user starts or stops playing a game
  class PlayingEvent
    attr_reader :server, :user, :game

    def initialize(data, bot)
      @user = bot.user(data['user']['id'].to_i)
      @game = Discordrb::Games.find_game(data['game']['name'])
      @server = bot.server(data['guild_id'].to_i)
    end
  end

  # Event handler for PlayingEvent
  class PlayingEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? PlayingEvent

      [
        matches_all(@attributes[:from], event.user) do |a, e|
          if a.is_a? String
            a == e.name
          elsif a.is_a? Fixnum
            a == e.id
          else
            a == e<commit_msg>Properly handle when a user stops playing a game<commit_after>require 'discordrb/events/generic'
require 'discordrb/data'
require 'discordrb/games'

module Discordrb::Events
  # Event raised when a user's presence state updates (idle or online)
  class PresenceEvent
    attr_reader :server, :user, :status

    def initialize(data, bot)
      @user = bot.user(data['user']['id'].to_i)
      @status = data['status'].to_sym
      @server = bot.server(data['guild_id'].to_i)
    end
  end

  # Event handler for PresenceEvent
  class PresenceEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? PresenceEvent

      [
        matches_all(@attributes[:from], event.user) do |a, e|
          if a.is_a? String
            a == e.name
          elsif a.is_a? Fixnum
            a == e.id
          else
            a == e
          end
        end,
        matches_all(@attributes[:status], event.status) do |a, e|
          if a.is_a? String
            a == e.to_s
          else
            a == e
          end
        end
      ].reduce(true, &:&)
    end
  end

  # Event raised when a user starts or stops playing a game
  class PlayingEvent
    attr_reader :server, :user, :game

    def initialize(data, bot)
      @user = bot.user(data['user']['id'].to_i)

      if data['game']
        @game = Discordrb::Games.find_game(data['game']['name'])
      else
        @game = nil
      end

      @server = bot.server(data['guild_id'].to_i)
    end
  end

  # Event handler for PlayingEvent
  class PlayingEventHandler < EventHandler
    def matches?(event)
      # Check for the proper event type
      return false unless event.is_a? PlayingEvent

      [
        matches_all(@attributes[:from], event.user) do |a, e|
          if a.is_a? String
            a == e.name
          elsif a.is_a? Fixnum
            a == e.id
          else
            a == e
{'fraction_non_alphanumeric': 0.10610079575596817, 'fraction_numerical': 0.0, 'mean_word_length': 2.0559157212317665, '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': '5878147', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1153, 'n_words': 333}