<commit_before>require 'blather/client/dsl'
require 'rest_client'
require 'json'
require 'time'
require_relative 'inc.rb'

class GoalBot
	extend Blather::DSL
	def self.run
        inc = Inc.new
        username = inc.username()
        password = inc.password()
        setup username,password 
		print "Connected to #{jid.stripped}\nGOAL Bot Initialized\n"
		EM.run { client.run }
	end

    def get_time(time)
    end


    users = []
	message :chat?, :body => "!goal" do |m|
        unless users.include?(m.from.to_s)
        say m.from, "You've been added to the event watcher!"
        users.push(m.from.to_s)
        threadName = m.from.to_s
        threadName = Thread.new do
            threadUser = m.from.to_s
            home_cache = ''
            away_cache = ''
            print "Thread started for #{threadUser}\n"
            start = 0
            start2 = 0
            loop do
                finalMessage = ''
                finalMessage2 = ''
                threadUser = m.from.to_s
                sleep(3)
                response = RestClient.get 'http://worldcup.sfg.io/matches/current', {:accept => :json}
                if response == "[]"
                   say threadUser, "No current game. Try again later."
                    users.delete(threadUser)
                    puts "Thread stopped for #{threadUser}\n"
                    Thread.stop
                    break
                end
                
                response = JSON.parse(response)
                if home_cache != response.first["home_team_events"] or start == 0
                    if start == 0
                    home_cache = response.first["home_team_events"]
                    home_cache.each do |x|
                      say threadUser, "#{response.first["home_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      sleep(1)
                      puts "Sending home to #{threadUser}"
                    end
                    start = 1
                    else
                      home_cache = response.first["home_team_events"]
                      home_cache.each do |x|
                          finalMessage = "#{response.first["home_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      end
                      puts "Sending #{finalMessage} to #{threadUser}"
                      say threadUser, "#{finalMessage}"
                    end
                end
                if away_cache != response.first["away_team_events"] or start2 == 0
                    if start2 == 0
                    away_cache = response.first["away_team_events"]
                    away_cache.each do |x|
                      say threadUser, "#{response.first["away_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      sleep(1)
                      puts "Sending away to #{threadUser}"
                    end
                    start2 = 1
                    else
                       away_cache = response.first["away_team_events"]
                       away_cache.each do |x|
                        finalMessage2 = "#{response.first["away_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | time: #{x["time"]}"
                       end
                       puts "Sending #{finalMessage2} to #{threadUser}"
                       say threadUser, "#{finalMessage2}"
                    end
                end

            end
        end
        threadName.join
        end
	end

    message :chat?, :body => "!today" do |m|
        response = RestClient.get 'http://worldcup.sfg.io/matches/today', {:accept => :json}
        response = JSON.parse(response)
        response.each do |x|
            parse_time = Time.parse(x["datetime"]) + Time.zone_offset('EDT')<commit_msg>Added some additional logging<commit_after>require 'blather/client/dsl'
require 'rest_client'
require 'json'
require 'time'
require_relative 'inc.rb'

class GoalBot
	extend Blather::DSL
	def self.run
        inc = Inc.new
        username = inc.username()
        password = inc.password()
        setup username,password 
		print "Connected to #{jid.stripped}\nGOAL Bot Initialized\n"
		EM.run { client.run }
	end

    def get_time(time)
    end


    users = []
	message :chat?, :body => "!goal" do |m|
        unless users.include?(m.from.to_s)
        say m.from, "You've been added to the event watcher!"
        users.push(m.from.to_s)
        threadName = m.from.to_s
        threadName = Thread.new do
            threadUser = m.from.to_s
            home_cache = ''
            away_cache = ''
            print "Thread started for #{threadUser}\n"
            start = 0
            start2 = 0
            loop do
                finalMessage = ''
                finalMessage2 = ''
                threadUser = m.from.to_s
                sleep(3)
                response = RestClient.get 'http://worldcup.sfg.io/matches/current', {:accept => :json}
                if response == "[]"
                   say threadUser, "No current game. Try again later."
                    users.delete(threadUser)
                    puts "Thread stopped for #{threadUser}\n"
                    Thread.stop
                    break
                end
                
                response = JSON.parse(response)
                if home_cache != response.first["home_team_events"] or start == 0
                    if start == 0
                    home_cache = response.first["home_team_events"]
                    home_cache.each do |x|
                      say threadUser, "#{response.first["home_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      sleep(1)
                      puts "Sending home to #{threadUser}"
                    end
                    start = 1
                    else
                      home_cache = response.first["home_team_events"]
                      home_cache.each do |x|
                          finalMessage = "#{response.first["home_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      end
                      puts "Sending #{finalMessage} to #{threadUser}"
                      say threadUser, "#{finalMessage}"
                    end
                end
                if away_cache != response.first["away_team_events"] or start2 == 0
                    if start2 == 0
                    away_cache = response.first["away_team_events"]
                    away_cache.each do |x|
                      say threadUser, "#{response.first["away_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | Time: #{x["time"]}"
                      sleep(1)
                      puts "Sending away to #{threadUser}"
                    end
                    start2 = 1
                    else
                       away_cache = response.first["away_team_events"]
                       away_cache.each do |x|
                        finalMessage2 = "#{response.first["away_team"]["country"]}| Event: #{x["type_of_event"]} | Player: #{x["player"]} | time: #{x["time"]}"
                       end
                       puts "Sending #{finalMessage2} to #{threadUser}"
                       say threadUser, "#{finalMessage2}"
                    end
                end

            end
        end
        threadName.join
        end
	end

    message :chat?, :body => "!today" do |m|
        puts "#{m.from} asked for Today's Matches"
        response = RestClient.get 'http://worldcup.sfg.io/matches/today', {:accept => :json}
        response = JSON.parse(response)
        response.each do |x|
            parse_time = Time.parse(x["datetime"]) + Time.zone_offset('EDT')
{'fraction_non_alphanumeric': 0.12036451082141501, 'fraction_numerical': 0.0048095177825591695, 'mean_word_length': 1.4261590420632484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '384041', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2070, 'n_words': 496}