2009-11-11

Skype mood to twitter by COM

Skype mood to twitter.
Skypeのムードをtwitterにpost。

on windowsXP
requirement

Useage
cmd.exe
>gem install twitter4r
>regsvr32 Skype4COM.dll <--when popup dialog,should 'OK'
>ruby mooding.rb
then every 5 sec. ruby check skype mood and updated at that time,post it to twitter.
だいたい5秒おきに、skypeのムードが更新されたか確認して、されてれば、twitterにポストします。下記コードのみ。
for stopping,止め方、Ctrl+C

#! ruby -Ku
require 'rubygems'
require 'win32ole'
require 'twitter'
require 'kconv'

$KCODE = 'UTF8'

@oTwitter = Twitter::Client.new
twit_id = ARGV[0]
twit_pwd = ARGV[1]
if @oTwitter.authenticate?(twit_id, twit_pwd) == true then
p 'OK auth'
else
raise 'ID,Passwd or both is not collect'
end

@oSkype=WIN32OLE.new('Skype4COM.skype')
mood = nil # Anyway 1st time twit mood
loop do
if @oSkype.Client.IsRunning != true then
raise "Please start skype"
else
end

if @oSkype.CurrentUserProfile.MoodText.toutf8 != mood then
mood = @oSkype.CurrentUserProfile.MoodText.toutf8
@oTwitter = Twitter::Client.new(:login => twit_id, :password => twit_pwd)
@oTwitter.status(:post, mood)
else
sleep(5) # check mood update every almost 5sec.
end
end

0 件のコメント:

BCM4321 on Latitude D430

At kernel 3 find wireless hardware lspci | grep -i wireless  check using current kernel module with PCI bus address lspci -vv -s 0c:...