<commit_before>require 'open-uri'

class UsdToCopPlugin
  include NinjaPlugin

  match /usd2cop (\d+)/, method: :convert
  match /usd2cop$/, method: :trm

  def usage
    "!usd2cop [n] -- Convert US dollars to Colombian Pesos"
  end

  def convert(m, query)
    begin
      cop = open("http://usd2cop.heroku.com").read.to_i
      reply = cop * query.to_i
    rescue
      reply = "Error reading exchange rate :|"
    end
    m.reply "#{m.user.nick}: #{reply}"
  end

  def trm(m)
    convert(m, 1)
  end
end

register_plugin UsdToCopPlugin<commit_msg>Use other source for usd to cop convertion<commit_after>require 'open-uri'
require 'nokogiri'

class UsdToCopPlugin
  include NinjaPlugin

  match /usd2cop ([-+]?[0-9]*\.?[0-9]+)/, method: :convert
  match /usd2cop$/, method: :trm

  def usage
    "!usd2cop [n] -- Convert US dollars to Colombian Pesos"
  end

  def convert(m, query)
    begin
      doc = Nokogiri::HTML(open("http://www.colombia.com/colombiainfo/estadisticas/dolar.asp"))
      cop = doc.css('.trm').last.children.to_s.gsub(',','').to_f
      reply = cop * query.to_f
    rescue
      reply = "Error reading exchange rate :|"
    end
    m.reply "#{m.user.nick}: #{reply}"
  end

  def trm(m)
    convert(m, 1)
  end
end

register_plugin UsdToCopPlugin
{'fraction_non_alphanumeric': 0.139937106918239, 'fraction_numerical': 0.010220125786163521, 'mean_word_length': 3.00314465408805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '6848480', 'n_tokens_mistral': 490, 'n_tokens_neox': 482, 'n_words': 118}