<commit_before>module Skype

  def self.chats
    search("recentchats").
      scan(/(#[^\s,]+)[\s,]/).
      map{|i| Chat.new i[0] }
  end

  class Chat
    @@message_cache = TmpCache::Cache.new

    attr_reader :id, :topic, :members

    def initialize(id)
      @id = id
      @topic = ::Skype::exec("GET CHAT #{@id} TOPIC").scan(/TOPIC (.*)$/)[0][0].toutf8
      @members = ::Skype::exec("GET CHAT #{@id} MEMBERS").scan(/MEMBERS (.+)$/)[0][0].split(/\s/)
    end

    def messages
      ::Skype.exec("GET CHAT #{@id} RECENTCHATMESSAGES").
        split(/,? /).
        select{|i| i =~ /^\d+$/ }.
        map{|i| i.to_i }.
        map{|i| @@message_cache.get(i) || @@message_cache.set(i, Skype::Chat::Message.new(i), 3600*72) }.
        sort{|a,b| b.time <=> a.time }
    end

    def post(message)
      ::Skype.exec "CHATMESSAGE #{@id} #{message}"
    end

    class Message

      attr_reader :id, :user, :body, :time

      def initialize(id)
        @id = id
        @user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
        @body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^MESSAGE #{@id} BODY (.+)$/)[0][0] rescue @body = ""
        @time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
      end

      def to_s<commit_msg>fix chat wrapper for linux, all tests passed<commit_after>module Skype

  def self.chats
    search("recentchats").
      scan(/(#[^\s,]+)[\s,]/).
      map{|i| Chat.new i[0] }
  end

  class Chat
    @@message_cache = TmpCache::Cache.new

    attr_reader :id, :topic, :members

    def initialize(id)
      @id = id
      @topic = ::Skype::exec("GET CHAT #{@id} TOPIC").scan(/TOPIC (.*)$/)[0][0].toutf8
      @members = ::Skype::exec("GET CHAT #{@id} MEMBERS").scan(/MEMBERS (.+)$/)[0][0].split(/\s/)
    end

    def messages
      ::Skype.exec("GET CHAT #{@id} RECENTCHATMESSAGES").
        split(/,? /).
        select{|i| i =~ /^\d+$/ }.
        map{|i| i.to_i }.
        map{|i| @@message_cache.get(i) || @@message_cache.set(i, Skype::Chat::Message.new(i), 3600*72) }.
        sort{|a,b| b.time <=> a.time }
    end

    def post(message)
      ::Skype.exec "CHATMESSAGE #{@id} #{message}"
    end

    class Message

      attr_reader :id, :user, :body, :time

      def initialize(id)
        @id = id
        @user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
        @body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^(CHAT)?MESSAGE #{@id} BODY (.+)$/)[0][1] rescue @body = ""
        @time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
      end

      def to_s
{'fraction_non_alphanumeric': 0.2210604929051531, 'fraction_numerical': 0.010455563853622106, 'mean_word_length': 2.553050397877984, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2197535', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1001, 'n_words': 206}