UPDATE: Prologuer v0.2 is out, with cool new features.
So, I got pretty excited when Matt Mullenweg introduced Prologue, a Twitter-inspired theme for Wordpress. It got even better when the theme was updated a little (from community requests), as to bear more resemblance with the Twitter experience.
I’ve been playing with Twitter-likes for a while (Noumba while I worked at af83, there’s this idea, coded one from scratch a few months ago, recently made a little toy I hope to publish soon enough, now this), exploring other ways to use the “micro-blogging / post-from-anywhere / push-and-pull equilibrium / social network” thing.
So I ran to write a bot that would make use of the oh-so-beautifully-simple Prologue interface combined with its WordPress goodness (read “available XML-RPC, tagging, easy to deploy, includes an admin interface, out-of-the-box!”) and give me the Twitter confort of having a easily accessible interface from where to post information.
Using Ruby’s XML-RPC client, the “made in Twitter” xmpp4r-simple gem and WP’s XML-RPC support of tags (through “mt_keywords”) it’s a piece of cake. You can even use daemons and have a start|stop|restart interface. Yawn! (almost).
What the Prologuer Bot does
Once you’ve added it to your buddy list, it’ll sit there waiting for you to tell him things. As soon as you do, it parses your message, scans it for hashtags and publishes it to your Prologue URL, with the hashtags as tags (works with more than one hashtag).
How it does it
If you’re looking for an IM (Jabber) bot that will post to Wordpress’s Prologue, you can start here.
Warning: The following code should not be used as is! It’s just an idea, and it works as is, but!! It lacks many a security feature, it won’t degrade gracefully at all, etc. I’m giving no further details as of how it works because if you don’t know it by reading the code you should consult all the links above. I’m a lousy dev. You’re warned.
Request:Please let me know of all things that could be enhanced (regex, logic, rescues, etc.)! Thanks
The code:
You can download it here: prologuer-01.rb.zip. Notice that the regexp is pretty dumb and you should adapt it to your own needs.
## Prologuer.rb # This simple code, meant to be used with WP's Prologue theme, creates a Jabber bot that will # 1) publish received messages to your WP account as new posts # 2) detect hastags (e.g #tag) and tag your new post with them # It's like having your own Twitter bot for your own Twitter # you need the xmpp4r-simple gem (sudo gem install xmpp4r-simple --include-dependencies) # you need a Jabber account and a WordPress install with the Prologue theme ## require 'rubygems' require 'xmlrpc/client' require 'xmpp4r-simple' ## Wordpress user config @wpuser = '' #your WP username @wppass = '' #your WP password @wpRPCurl = '' #example = 'http://yoursite.com/wordpress/xmlrpc.php ## Jabber user config @jabuser = '' # Your Jabber username: 'you@jabber.org', 'you@gmail.com', etc. @jabpass = '' # your Jabber account password ## @client = Jabber::Simple.new(@jabuser, @jabpass) @server = XMLRPC::Client.new2(@wpRPCurl) def get_messages @client.received_messages.each do |msg| desc = msg.body from = msg.from.strip.to_s wptags = Array.new hashtags = desc.scan(/#[a-zA-Z]+/i) hashtags.each do |w| b = w.to_s.split(/#/) c = b[1].to_s.downcase wptags.push c end newPost = {} newPost['description'] = desc.to_s newPost['mt_keywords'] = wptags.join(', ').to_s @server.call('metaWeblog.newPost','unused_blogid',@wpuser,@wppass,newPost,true) @client.deliver(from, 'OK') end rescue end loop do get_messages sleep(5) end
OK, have fun!


Comments (2)
Useful ideas:
Let one specify an “anchor category” that all bot inputs get categoried as.
Use APP instead of XML-RPC to make the bot extensible beyond Wordpress.
@ Stephen:
An “anchor category” as in a default category? Useful and easy, I like it
APP versus XML-RPC: good point, although most blog engines have an XML-RPC API but not APP. I looked into it and went with XML-RPC because it was far easier. Will look into it.
Thanks for your input!
Trackbacks/Pingbacks (4)
[...] The Prologuer Bot @ Webcracy - Some basic IM and Prologue integration Tags: im bot prologue wordpress [...]
[...] tipper om en WordPress-udvidelse, der gør det muligt at poste til WordPress-temaet Prologue (som vi bruger her på Online Minds [...]
[...] The Prologuer Bot @ Webcracy Post from IM to Prologue (tags: im xmpp wordpress prologue microblogging theme) [...]
[...] amazing, I wish I had a virtual team to use Prologue with, and someone already came up with a chat bot for Prologue. Amazing. You can add this functionality to your WordPress site as well, by simply [...]