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:}


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!