Wednesday, June 14, 2006

Ruby Skype Bot

Here is a very simple Ruby Script that will reply to anything anyone says to you.

require 'win32ole'

oSkype ='SKYPEAPI.Access')
puts "Version: #{oSkype.Version}"

puts "Getting events"
ev =, '_IAccessEvents')

ev.on_event('ChatMessageReceived') do |msg|
to = msg.MessageFrom.Handle
puts "#{to} said: #{msg.Body}"
if to != oSkype.CurrentUserHandle
response = "OMG, I can't believe you just said '#{msg.Body}'"
oSkype.SendMessage(to, response)

# infinite loop to keep the script alive
loop do

It requires the Skype ActiveS dll to be registered. The ActiveS site does not have the dll in the latest MSI so, I was able to download it here and make it available for people to register.

No comments: