WikipediaのURLを返すSkypebot

ひとまず作ってみたけどあまりよろしくないいろいろな意味で

require 'rubygems'
require 'skypeapi'
require 'uri'

SkypeAPI.init
SkypeAPI.attachWait

def Chatless(chatmessage)
  active_chat = SkypeAPI.searchActiveChats

  #w:ではじめるとwikipediaのURLを吐き出す(日本語は変換する)
  if chatmessage.getBody =~ /^w:/
    word = chatmessage.getBody[2,chatmessage.getBody.size]
    SkypeAPI::ChatMessage.create(active_chat, URI.escape("http://ja.wikipedia.org/wiki/#{word}"))
  end
end

SkypeAPI::ChatMessage.setNotify :Status, 'RECEIVED' do |chatmessage|
  Chatless(chatmessage)
end

SkypeAPI::ChatMessage.setNotify :Status, 'SENT' do |chatmessage|
  Chatless(chatmessage)
end

loop do
  SkypeAPI.polling
  sleep 0.123
end