Post a message to identi.ca using XMPP via HTTP
#!/usr/bin/ruby require 'rubygems' require 'socket' require 'open-uri' require 'xmpp4r-simple' server = TCPServer.new('127.0.0.1', 9090) messenger = Jabber::Simple.new('my-bot@gmail.com', "bot-password") while (session = server.accept) request = session.gets project = request[/(\w+)\?msg=(.*) HTTP\/1.1/,1] msg = URI.unescape($2) puts request session.print "HTTP/1.1 200/OK\rContent-type: text/html\r\n\r\n" session.print "<html><head><title>Response from Jeeves</title></head>\r\n" session.print "<body>" if project != '' and msg != '' then case project when 'identica' messenger.deliver("update@identi.ca", msg) else puts "Project #{project} wasn't found on this server" end end session.print URI.unescape(request) session.print "</body></html>" session.close end
To post the message you would type your message within the browser URL e.g. http://127.0.0.1:9090/identica?msg=just%20testing%20xmpp4r-simple%20from%20tcpserver1