Ceil
Articles408
Tags211
Categories0
Ruby写简单的msn bot

Ruby写简单的msn bot

原来有个msn的lib,貌似最近用不了了,那么就从xmpp下手吧 首先找一个jabber server 注册个帐号,例如thiessen.im (如果用psi的话add ac的时候有很多可选的) 然后在Service Discover把MSN transpot加上 ,那么登录jabber server的时候就自动登录MSN了

require ‘rubygems’ require ‘xmpp4r-simple’ # Online status msg_history = “none” jabber = Jabber::Simple.new ‘YOUR_JABBER_ID’,’YOUR_JABBER_PSW’ jabber.status(nil,”Working!”) #Ctrl+C Disconnect Signal.trap(“INT”) { jabber.disconnect puts “### MSN-BOT logout” exit } # welcome message msg_welcome = “Hi, this is alice. Ceil is busy and no time to reply you.” loop do jabber.received_messages do |msg| puts “- #{msg.from}” puts “#{msg.body}” jabber.deliver(msg.from, msg_welcome) end end

还是Terminal msn舒服,占资源少不说,挂机啥的都很方便 {:c2:}

Author:Ceil
Link:http://ceilwoo.com/2010/10/12/msn-bot-in-ruby/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可