<commit_before>module Telegram
  # Base class for Telegram models
  #
  # @see TelegramChat
  # @see TelegramRoom
  # @since [0.1.0]
  class TelegramBase
    include Logging

    # @return [Client] Root client instance
    attr_reader :client

    # @return [Integer] Identifier
    attr_reader :id

    # Return an instance if exists, or else create a new instance and return
    #
    # @param [Client] client Root client instance
    # @param [Integer] raw Raw data on either of telegram objects
    # @since [0.1.0]
    def self.pick_or_new(client, raw)
      # where to search for
      where = if self == TelegramChat
        client.chats
      elsif self == TelegramContact
        client.contacts
      end

      # pick a first item if exists, or else create
      where.find { |obj| obj.id == raw['id'] } or self.new(client, raw)
    end

    # Convert to telegram-cli target format from {TelegramChat} or {TelegramContact}
    #
    # @since [0.1.1]
    def targetize
      @type == 'encr_chat' ? @title : to_tg
    end

    # Execute a callback block with failure result
    #
    # @since [0.1.1]
    # @api private
    def fail_back(&callback)
      callback.call(false, {}) unless callback.nil?
    end

    # Send typing signal
    #
    # @param [Block] callback Callback block that will be called when finished
    # @since [0.1.1]
    def send_typing(&callback)
      if @type == 'encr_chat'
        logger.warn("Currently telegram-cli has a bug with send_typing, then prevent this for safety")
        return
      end
      @client.send_typing(targetize)
    end

    # Abort sending typing signal
    #
    # @param [Block] callback Callback block that will be called when finished
    # @since [0.1.1]
    def send_typing_abort(&callback)
      if @type == 'encr_chat'
        logger.warn("Currently telegram-cli has a bug with send_typing, then prevent this for safety")
        return
      end
      @client.send_typing_abort(targetize, &callback)
    end<commit_msg>Fix: no callback passed to the send_typing api<commit_after>module Telegram
  # Base class for Telegram models
  #
  # @see TelegramChat
  # @see TelegramRoom
  # @since [0.1.0]
  class TelegramBase
    include Logging

    # @return [Client] Root client instance
    attr_reader :client

    # @return [Integer] Identifier
    attr_reader :id

    # Return an instance if exists, or else create a new instance and return
    #
    # @param [Client] client Root client instance
    # @param [Integer] raw Raw data on either of telegram objects
    # @since [0.1.0]
    def self.pick_or_new(client, raw)
      # where to search for
      where = if self == TelegramChat
        client.chats
      elsif self == TelegramContact
        client.contacts
      end

      # pick a first item if exists, or else create
      where.find { |obj| obj.id == raw['id'] } or self.new(client, raw)
    end

    # Convert to telegram-cli target format from {TelegramChat} or {TelegramContact}
    #
    # @since [0.1.1]
    def targetize
      @type == 'encr_chat' ? @title : to_tg
    end

    # Execute a callback block with failure result
    #
    # @since [0.1.1]
    # @api private
    def fail_back(&callback)
      callback.call(false, {}) unless callback.nil?
    end

    # Send typing signal
    #
    # @param [Block] callback Callback block that will be called when finished
    # @since [0.1.1]
    def send_typing(&callback)
      if @type == 'encr_chat'
        logger.warn("Currently telegram-cli has a bug with send_typing, then prevent this for safety")
        return
      end
      @client.send_typing(targetize, &callback)
    end

    # Abort sending typing signal
    #
    # @param [Block] callback Callback block that will be called when finished
    # @since [0.1.1]
    def send_typing_abort(&callback)
      if @type == 'encr_chat'
        logger.warn("Currently telegram-cli has a bug with send_typing, then prevent this for safety")
        return
      end
      @client.send_typing_abort(targetize, &callback)
    end
{'fraction_non_alphanumeric': 0.0890818858560794, 'fraction_numerical': 0.008933002481389578, 'mean_word_length': 2.5452946350043977, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2812286', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1232, 'n_words': 417}