@@ -0,0 +1,1313 @@
+package org.transtruct.cmthunes.ircbot.applets;%0A%0Aimport java.io.*;%0Aimport java.net.*;%0Aimport java.util.*;%0A%0Aimport org.jsoup.*;%0Aimport org.jsoup.nodes.*;%0Aimport org.jsoup.select.*;%0A%0Aimport org.transtruct.cmthunes.irc.*;%0A%0Apublic class TumblrApplet implements BotApplet %7B%0A    public void run(IRCChannel channel, IRCUser from, String command, String%5B%5D args, String unparsed) %7B%0A        Document doc;%0A        String url;%0A%0A        if(unparsed.trim().length() == 0) %7B%0A            channel.write(%22Missing blog name%22);%0A            return;%0A        %7D%0A%0A        try %7B%0A            String encodedSearchTerm = URLEncoder.encode(unparsed, %22UTF8%22);%0A            Connection con;%0A%0A            url = String.format(%22http://%25s.tumblr.com/random%22, encodedSearchTerm);%0A%0A            con = Jsoup.connect(url);%0A            con.execute();%0A            url = con.response().header(%22Location%22);%0A            doc = con.response().parse();%0A%0A        %7D catch (IOException e) %7B%0A            channel.write(%22Error%22);%0A            return;%0A        %7D%0A%0A        Element div = doc.select(%22div.post-content%22).first();%0A        Element title = div.getElementsByTag(%22a%22).first();%0A        channel.write(title.text());%0A        Element content = div.getElementsByTag(%22pre%22).first();%0A        channel.writeMultiple(content.text().replaceAll(%22%5Ct%22,%22%22).split(%22%5Cn%22));%0A     %7D%0A%7D%0A

Add Tumblr