Tad Thorley

creative commons license rss feed comments feed powered by Howex valid xhtml Add to Technorati Favorites

My first rbot plugin

Here's a plugin for rbot that queries google's calculator.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'rubygems'
require 'hpricot'
require 'open-uri'

class GcalcPlugin < Plugin

  def help(plugin, topic="")
    "gcalc <statement> => do some conversions/calculations using Google's calculator"
  end

  def retrieve(m)
    request = m.params.gsub(" ", "+")
    doc = Hpricot(open("http://google.com/search?q=#{request}"))
    response = (doc/"h2.r").first.to_plain_text.gsub(/\[|\]/, "")
    m.reply response
  end

  def privmsg(m)
    request = m.params.gsub(" ", "+")
    doc = Hpricot(open("http://google.com/search?q=#{request}"))
    response = (doc/"h2.r").first.to_plain_text.gsub(/\[|\]/, "")
    m.reply response
  end 
end

plugin = GcalcPlugin.new
plugin.map "gcalc *request", :action => 'retrieve'

Let's try this again

I finally got the bad hardware in my desktop computer replaced. Now I have the means to write articles reliably again.

I have also switched my blogging software from Wordpress to Mephisto. Mephisto doesn’t have all of the plugins and themes that a more popular blog like Wordpress has, but it does the things I need it to do and want it to do. It doesn’t try to reformat my posts and works with me instead of against me. It is also written in Ruby so I can see the interesting tricks that they’ve done with it and extend it myself.