# Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
#
# Copyright:: (C) 2007 Carter Parks
+# Copyright:: (C) 2007 Giuseppe Bilotta
#
# Users can setup their twitter username and password and then begin updating
# twitter whenever
# return a help string when the bot is asked for help on this plugin
def help(plugin, topic="")
- return "twitter status [status] => updates your status on twitter | twitter identify [username] [password] => ties your nick to your twitter username and password"
+ return "twitter status [nick] => show nick's (or your) status | twitter update [status] => updates your status on twitter | twitter identify [username] [password] => ties your nick to your twitter username and password"
end
# update the status on twitter
begin
rex = REXML::Document.new(response)
rex.root.elements.each("status") { |st|
- month, day, hour, min, sec, year = st.elements['created_at'].text.match(/\w+ (\w+) (\d+) (\d+):(\d+):(\d+) \S+ (\d+)/)[1..6]
- debug [year, month, day, hour, min, sec].inspect
- time = Time.local(year.to_i, month, day.to_i, hour.to_i, min.to_i, sec.to_i)
+ # month, day, hour, min, sec, year = st.elements['created_at'].text.match(/\w+ (\w+) (\d+) (\d+):(\d+):(\d+) \S+ (\d+)/)[1..6]
+ # debug [year, month, day, hour, min, sec].inspect
+ # time = Time.local(year.to_i, month, day.to_i, hour.to_i, min.to_i, sec.to_i)
+ time = Time.parse(st.elements['created_at'].text)
now = Time.now
delta = now - time
msg = st.elements['text'].to_s + " (#{Utils.secs_to_string(delta.to_i)} ago via #{st.elements['source'].to_s})"
m.reply "your status message is longer than 140 characters, which is not optimal, but I'm going to update anyway"
end
- body = "status=#{CGI.escape(msg)}"
+ source = "source=rbot"
+ msg = "status=#{CGI.escape(msg)}"
+ body = [source,msg].join("&")
response = @bot.httputil.post(uri, body, :headers => @header)
debug response