Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 10 commits
  • 7 files changed
  • 0 comments
  • 1 contributor
28 bitcoin.rb
... ... @@ -0,0 +1,28 @@
  1 +require 'open-uri'
  2 +require 'json'
  3 +
  4 +class BitcoinPlugin < Plugin
  5 + def help(plugin, topic='')
  6 + "@bitcoin => owl's bitcoin mining status."
  7 + end # help
  8 +
  9 + def status(m, params)
  10 + json = open("http://mining.bitcoin.cz/accounts/profile/json/5339-b08a146b04934cec6e6d8041b014ec2f").read
  11 + profile = JSON.parse(json)
  12 + coins = profile['unconfirmed_reward'].to_f + profile['confirmed_reward'].to_f
  13 + m.reply "Balance: #{coins} BTC"
  14 +
  15 + #ticker_json = open('https://mtgox.com/code/data/ticker.php', {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}).read
  16 + #t = JSON.parse(ticker_json)
  17 + #t = t['ticker']
  18 + #coin_value = coins * t['buy'].to_f
  19 +
  20 + #values = [coins, coin_value]
  21 + #display = values.map {|f| sprintf('%.2f',f) }
  22 +
  23 + #m.reply "#{display[0]} BTC = #{display[1]} USD"
  24 + end # summon
  25 +end # BitcoinPlugin
  26 +plugin = BitcoinPlugin.new
  27 +plugin.map 'bitcoin', :action => 'status'
  28 +plugin.map 'riches and ores', :action => 'status'
6 holo.rb
@@ -26,6 +26,12 @@ def initialize
26 26 #"Overpriced HID" => {:number => '1Z4F37F10399609311', :courier => 'ups'}
27 27 #"魔法少女リリカルなのは The MOVIE 1st<初回限定版>" => {:number => '424981299085', :courier => 'fedex'}
28 28 #'Disk' => {:number => '1ZX799470342426740', :courier => 'ups'},
  29 + #'WiMAX CPE' => {:number => '485264002054', :courier => 'fedex'},
  30 + #'WiMAX CPE the 2nd' => {:number => '485264110765', :courier => 'fedex'},
  31 + #'WiMAX CPE - ODU ' => {:number => '1Z3X3F271343232801', :courier => 'ups'},
  32 + # 'Plus Headphones' => {:number => '1Z0X118A1210790602', :courier => 'ups'},
  33 + #'HD 280 Pro' => {:number => '1Z5993920144768026', :courier => 'ups'},
  34 + #'Gentech CPE' => {:number => '1Z07R37W9096472131', :courier => 'ups'},
29 35 }
30 36 super
31 37 end # initialize
9 iana.rb
@@ -7,9 +7,9 @@ def help(plugin, topic='')
7 7 "IANA depletion event utilities. @iana => current depletion date estimate. @iana remaining => the number of unallocated /8s."
8 8 end # help
9 9
10   - def iana(m, params)
  10 + def first_rir(m, params)
11 11 date = @bot.httputil.get('http://ipv4depletion.com/iana.js').gsub(/^.*?"(.*?)".*?$/, '\1')
12   - m.reply "Today's IANA depletion date estimate: #{date}"
  12 + m.reply "Today's RIPE estimated depletion date: #{date}"
13 13 end # iana
14 14
15 15 def remaining(m, params)
@@ -27,10 +27,13 @@ def rir_remaining(m, params)
27 27 end
28 28 m.reply "Remaining blocks per RIR (/8s): %s" % \
29 29 rir_remaining.map{|pair| "%s: %.3f" % pair }.join(" \00306**\003 ")
30   - end
  30 + end # rir_remaining
31 31 end # OwlPlugin
  32 +
  33 +
32 34 plugin = IanaPlugin.new
33 35 plugin.map 'iana', :action => 'remaining'
34 36 plugin.map 'iana remaining', :action => 'remaining'
  37 +plugin.map 'rir', :action => 'first_rir'
35 38 plugin.map 'rir remaining', :action => 'rir_remaining'
36 39
36 link_watch.rb
@@ -10,6 +10,11 @@ class ::Hyperlink < ActiveRecord::Base
@@ -39,10 +44,37 @@ def message(m)
10 shipment_tracker.rb
@@ -28,8 +28,11 @@ def ircify
28 28
29 29 def self.fetch_ups(number)
30 30 doc = Nokogiri::HTML(open("http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=#{number}&track.x=0&track.y=0"))
31   - latest_row = doc.search('fieldset[@id=showPackageProgress]//tr')[1]
  31 + latest_row = doc.search('div[@id=collapse3]').first
  32 +
32 33 if latest_row
  34 + latest_row = latest_row.next_sibling.next_sibling.next_sibling.next_sibling.next_sibling.next_sibling.search('tr')[1]
  35 +
33 36 status = ShipmentStatus.new(
34 37 :number => number,
35 38 :location => latest_row.children[0].children.first.content.ircify_html,
@@ -74,7 +77,10 @@ def self.fetch_fedex(number)
74 77 nil
75 78 end
76 79 end # fetch fedex
77   -
  80 +
  81 + def self.fetch_purolator(number)
  82 +
  83 + end # fetch purolator
78 84 end
79 85
80 86 class ShipmentTrackerPlugin < Plugin
149 starcraft.rb
... ... @@ -0,0 +1,149 @@
  1 +require 'rubygems'
  2 +require 'nokogiri'
  3 +require 'open-uri'
  4 +require 'chronic'
  5 +require 'active_support' # timezone fuckery
  6 +
  7 +class StarcraftPlugin < Plugin
  8 + EVENTS = {
  9 + :gsl => :until_gsl,
  10 + #:nasl => :until_nasl, # irrelevant
  11 + #:tsl => :until_tsl, # over
  12 + }
  13 +
  14 + def help(plugin, topic='')
  15 + "Available commands: @sc, @gsl, @nasl, @tsl"
  16 + end # help
  17 +
  18 + # Display thing.
  19 + def until(event)
  20 + at = StarcraftPlugin.send(EVENTS[event].to_s)
  21 +
  22 + if at == nil
  23 + return "Match not scheduled."
  24 + elsif at == 0
  25 + return "Live right now!"
  26 + elsif at > Time.now.to_i
  27 + return "Live in #{Utils.secs_to_string(at - Time.now.to_i)}."
  28 + else
  29 + return "Unknown error: time not handled!"
  30 + end
  31 + end # until
  32 +
  33 + def self.until_gsl
  34 + # p.n_main_gbn_liveicon a
  35 + doc = Nokogiri::HTML(open('http://gomtv.net'))
  36 + next_match = doc.search('p.n_main_gbn_liveicon a').first.attr('title').strip
  37 +
  38 + at = nil # holds the next match's time, if available.
  39 + if next_match =~ /^LIVE$/i
  40 + at = 0
  41 + log "[GSL] Live right now!"
  42 + elsif next_match =~ /Next LIVE starts in /i
  43 + next_match.gsub!(/Next LIVE starts in /i,'')
  44 + log "[GSL] Live starts in..."
  45 +
  46 + # -9 hours to undo the KST bullshit
  47 + at = (Chronic::parse(next_match) - (60 * 60 * 9)).to_i
  48 + end
  49 +
  50 + return at
  51 + end # until_gsl
  52 +
  53 + # Deprecated - GOM changed the website completely 2011-10-06.
  54 + def self.until_gsl_classicGOM
  55 + doc = Nokogiri::HTML(open('http://gomtv.net'))
  56 + next_match = doc.search('div[@id=mainMenu]//span[@class=tooltip]').last.content.rstrip.lstrip
  57 +
  58 + at = nil # holds the next match's time, if available.
  59 + if next_match =~ /Please tune in and enjoy/i
  60 + at = 0
  61 + log "[GSL] Live right now!"
  62 + elsif next_match =~ /Next LIVE starts in /i
  63 + next_match.gsub!(/Next LIVE starts in /i,'')
  64 + log "[GSL] Live starts in..."
  65 +
  66 + # -9 hours to undo the KST bullshit
  67 + at = (Chronic::parse(next_match) - (60 * 60 * 9)).to_i
  68 + else
  69 + # OK, no match in their scheduler. Let's fall back to the calendar.
  70 + log "[GSL] Checking schedule..."
  71 + schedule_js = nil
  72 + open('http://gomtv.net').each_line do |line|
  73 + schedule_js = line if line =~ /^viewDetail\(/
  74 + end
  75 +
  76 + if schedule_js
  77 + log "We are using this JS: #{schedule_js.class}"
  78 +
  79 + data = {}
  80 + schedule_js.gsub('viewDetail({','').gsub("})});\r\n",'').split("',").each do |line|
  81 + line = line.split " : '"
  82 + data[line[0]] = line[1]
  83 + end
  84 +
  85 + doc = Nokogiri::HTML(data['stime'])
  86 + next_match = doc.root.content.gsub('@ ','').gsub(/\(.*\)$/,'').split("\302\240").reverse.join
  87 + at = (Chronic::parse(next_match) - (60 * 60 * 9)).to_i
  88 + end
  89 + end
  90 +
  91 + return at
  92 + end # until_gsl
  93 +
  94 + def self.until_nasl
  95 + at = nil # holds the next match's time, if available.
  96 +
  97 + doc = Nokogiri::HTML(open('http://nasl.tv/Match'))
  98 + #return 0 if doc.search('//a[@id="live"]').size > 0 # Live right now! notice
  99 +
  100 + day = doc.search('li.group').first # assumption: old days will fall off the page
  101 +
  102 + time = day.search('div.day_details span.date', 'div.day_details span.time').map {|e| e.content.strip }.join(' ').gsub(' (PST)', '')
  103 + at = Chronic::parse(time)
  104 +
  105 + Time.zone = 'America/Los_Angeles'
  106 + at = Time.zone.at(at)
  107 + Time.zone = 'UTC'
  108 + at = Time.at(at.to_i - at.utc_offset).to_i
  109 +
  110 + return at
  111 + end # until_nasl
  112 +
  113 + def self.until_tsl
  114 + at = nil
  115 +
  116 + useful_line = nil
  117 + open('http://teamliquid.net').each_line do |line|
  118 + useful_line = line if line =~ /^\$\("#tslcountdown"\)\.countdown/
  119 + end # each_line
  120 +
  121 + if useful_line
  122 + horrible_time = useful_line.split('(').last.gsub("))});\n",'').split(', ').map {|i| i.split '-' }.flatten
  123 + horrible_time.delete_at(2) # for some fucking reason, the month is ``04-1'' which is obviously wrong...
  124 + date = horrible_time.slice!(0,3)
  125 +
  126 + at = Chronic::parse("#{date.join('-')} #{horrible_time.join(':')}").to_i
  127 + at = 0 if at < Time.now.to_i # handle live right now (poorly)
  128 + end # useful line
  129 +
  130 + return at
  131 + end # until_tsl
  132 +
  133 + def event(m, params)
  134 + m.reply self.until(params[:event])
  135 + end # event
  136 +
  137 + def list_events(m, params)
  138 + EVENTS.each do |name,method|
  139 + m.reply "\002#{name.to_s.upcase}\002: #{self.until(name)}"
  140 + end
  141 + end # list_events
  142 +
  143 +end # StarcraftPlugin
  144 +plugin = StarcraftPlugin.new
  145 +plugin.map 'sc', :action => 'list_events'
  146 +plugin.map 'gsl', :action => 'event', :defaults => {:event => :gsl}
  147 +plugin.map 'titty', :action => 'event', :defaults => {:event => :gsl} # legacy
  148 +plugin.map 'nasl', :action => 'event', :defaults => {:event => :nasl}
  149 +plugin.map 'tsl', :action => 'event', :defaults => {:event => :tsl}
69 titty.rb
... ... @@ -1,69 +0,0 @@
1   -require 'rubygems'
2   -require 'nokogiri'
3   -require 'open-uri'
4   -require 'chronic'
5   -
6   -class TittyPlugin < Plugin
7   - def help(plugin, topic='')
8   - "Usage: @titty => time until next broadcast. @titty stream (HD|SD) for stream URL."
9   - end # help
10   -
11   - def until(m, params)
12   - doc = Nokogiri::HTML(open('http://gomtv.net'))
13   - next_match = doc.search('div[@id=mainMenu]//span[@class=tooltip]').last.content.rstrip.lstrip
14   -
15   - at = nil # holds the next match's time, if available.
16   - if next_match =~ /Please tune in and enjoy/i
17   - m.reply "Live right now!"
18   - elsif next_match =~ /Next LIVE starts in /i
19   - next_match.gsub!(/Next LIVE starts in /i,'')
20   -
21   - # -9 hours to undo the KST bullshit
22   - at = Chronic::parse(next_match) - (60 * 60 * 9)
23   - else
24   - # OK, no match in their scheduler. Let's fall back to the calendar.
25   - schedule_js = nil
26   - open('http://gomtv.net').each_line do |line|
27   - schedule_js = line if line =~ /^viewDetail\(/
28   - end
29   -
30   - if schedule_js
31   - data = {}
32   - schedule_js.gsub('viewDetail({','').gsub("})});\r\n",'').split("',").each do |line|
33   - line = line.split " : '"
34   - data[line[0]] = line[1]
35   - end
36   -
37   - doc = Nokogiri::HTML(data['stime'])
38   - next_match = doc.root.content.gsub('@ ','').gsub(/\(.*\)$/,'').split("\302\240").reverse.join
39   - at = Chronic::parse(next_match) - (60 * 60 * 9)
40   - end
41   - end
42   -
43   - if at
44   - m.reply "Live in #{Utils.secs_to_string(at - Time.now)}."
45   - else
46   - m.reply "GOM has not scheduled a match."
47   - end
48   - end # until
49   -
50   - def stream_url(m, params)
51   - titty_ips = ['211.43.144.139','211.43.144.141','211.43.144.142','211.43.144.143',
52   - '211.43.144.144','211.43.144.145','211.43.144.151','211.43.144.152',
53   - '211.43.144.159','211.43.144.233','211.43.144.234','211.43.144.235',
54   - '211.43.144.236','211.43.144.238','211.43.144.239','211.43.144.241']
55   -
56   - quality = params[:quality].downcase
57   - if quality == 'hd'
58   - #m.reply "http://#{titty_ips.pick_one}:8902/view.cgi?hid=1&cid=21&nid=902&uno=14698"
59   - m.reply "Sorry, HD is unavailable. :("
60   - elsif quality == 'sd'
61   - m.reply "http://#{titty_ips.pick_one}:8900/view.cgi?hid=1&cid=21&nid=900&uno=11850"
62   - else
63   - m.reply "Sorry, I don't know anything about that quality. :("
64   - end
65   - end
66   -end # TittyPlugin
67   -plugin = TittyPlugin.new
68   -plugin.map 'titty', :action => 'until'
69   -plugin.map 'titty stream :quality', :action => 'stream_url'

No commit comments for this range

Something went wrong with that request. Please try again.