IRC「#サイドツー」で動いてます。しかし1ゲイツポイントは1.48円ではなく1.5円な気がする。しかも、ヨドバシで買うと10%引きな上にポイント還元だったりする。というわけでいじくってみた。
(karia2) 800gp (kar_bot) 800ゲイツポイント = 1,184円 (オンライン) / 1,078.88円 + 107.888p (ヨドバシ)
という感じで出ます。
require 'chokan/plugin_base' class GatesPointYodo < Chokan::PluginBase def initialize(config, chokan) super @suffix = @config['suffix'] || 'gp' end def on_privmsg(prefix, channel, message) case message when /^(\d+)#{@suffix}$/i notice(channel, exchange(Regexp.last_match[1])) end end private def exchange(gp) gyen = gp.to_i * 1.48 yyen = gp.to_i * 1.3486 yp = yyen * 0.1 "#{format(gp)}ゲイツポイント = #{format(gyen)}円 (オンライン) / #{format(yyen)}円 + #{format(yp)}p ( ヨドバシ)" end def format(i) i.to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/, '\1,').sub(/\.0+$/, '') end end
これをgates_point_yodo.rbとしてchokanのpluginsディレクトリに保存し、config.yamlに
GatesPointYodo:
という行を追加すれば動くはずです。小数点以下が出ちゃったりとかホントはヨドバシは13%還元だったりとか結構適当だけど、あまり突っ込まないで><
7月26日追記:1gp=1.48円というのはオンライン購入時のレートであることが判明しました。知らなかった!というわけで修正。ヨドバシが13%なのはキャンペーンで全商品がそうなっているだけでそのうち10%に戻るみたいです。