Created
February 2, 2012 03:01
-
-
Save dongyuwei/1721142 to your computer and use it in GitHub Desktop.
xmpp robot for weibo 微博XMPP私信机器人
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'xmpp4r-simple' | |
jabber = Jabber::Simple.new("[email protected]", "password_of_weibo") | |
#at_exit{jabber.status(:away, "jabot down")} | |
EM.run do | |
EM::PeriodicTimer.new(1) do | |
jabber.received_messages do |message| | |
case message.body | |
when "exit" : EM.stop | |
else jabber.deliver(message.from, "我收到你私信了: #{message.body}") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xmpp.weibo.com,email中的AT符号用“\40”替代即可
Ref: http://weibo.com/2758197137/zotjDgATb?type=comment#_rnd1491712190088
