Developer42

2009-11-23

Google Wave Robot :: Standard Commands

Filed under: Google, Technology, Wave — Tags: , , , , , , , , , , — Developer42 @ 19:57

Currently each programmer writing a bot for Google Wave is able to write whatever they want, sometimes providing support, but using their own, custom syntax. Having a set of commands which all (or many) bots implement would make the user experience far better, as users would then be able to easily find out how to use the bot, or where to find additional help.
e.g.
botName@appspot.com /? //see /help
botName@appspot.com /help //brings up a list of commands available
botName@appspot.com /about //displays a summary of what this robot does
botName@appspot.com /devsite //provides a link to the developer’s site
botName@appspot.com /mode private //the bot’s responses are only shown to the person who invited it
botName@appspot.com /mode public //everyone in the wave sees the bot’s responses

I’ve also made a summary of this post available on the Google Wave Bots site. Please can you post any responses to that site, as this will allow all communications to be kept in the same place.

2009-11-04

Ideas for Wave Robots

Filed under: Google, Ideas, Technology, Wave — Tags: , , , , , , , , , , , — Developer42 @ 21:32

One of the hardest things about developing a wave robot is coming up with an original idea. My smiley bot [smiley_wave@appspot.com] was just for me to play with wave & get used to uploading apps to App Engine / get back into java coding and using eclipse. Now that that’s done, it’s time to think of something useful; an application that people will actually want to use. The point of this post is partly a brainstorming session for myself, and partly to put these ideas out there to anyone stuck for ideas, who think they can code one of these, and finally, to encourage others to submit ideas.

Webby – The Web Service Robot
A robot which when added, detects any URLs pointing to web services, generates a form based on the parameters, then submits this data via SOAP, and puts the return value into a new blip.

Squely – A Database Query Bot
A robot which can run SQL statements against given connection strings. At present, this will only be possible if the database is publicly accessible, or if you have a wave server installed on the same network as your database.

QIFry – Interesting
This robot would monitor waves for key words, then on detection, pop in an interesting fact about that word (e.g. if it spots the word Banana, it says “did you know that bananas are herbs, and these shrubs can walk?”). It also monitors for boring words, and replaces them with more eloquent ones.

Pretty – Pretty Print
Detects common languages / markup & changes the layout to make it more readable.

Recipe
Finds recipes based on ingredients or dish names in the wave.

FindMe
Uses the GEO features of HTML 5 to locate where each wave user is and lets wavers know where their nearest wavers are. This could also take info about their interests to help match people up to folks whose hobbies they share.

2009-11-03

My First Wave Robot :: smiley-wave@appspot.com

Filed under: Google, Technology, Wave — Tags: , , , , , , , — Developer42 @ 00:34

smiley-wave@appspot.com first demo

appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
	<application>smiley-wave</application>
	<version>1</version>
</appengine-web-app>

web.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
	<servlet>
		<servlet-name>Smiley</servlet-name>
		<servlet-class>inverso.google.wave.robot.smiley.SmileyServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>Smiley</servlet-name>
		<url-pattern>/_wave/robot/jsonrpc</url-pattern>
	</servlet-mapping>
</web-app>

capabilities.xml

<?xml version="1.0" encoding="utf-8"?>
<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
  <w:capabilities>
    <w:capability name="blip_submitted" content="true" />
    <w:capability name="wavelet_self_added" content="true" />
  </w:capabilities>
  <w:version>1&lt/w:version>
</w:robot>

SmileyServlet.java

package inverso.google.wave.robot.smiley;
import com.google.wave.api.*;
import java.util.*;
		
//FIX FOR ISSUE 354 is used where the robot suffers from the bug mentioned in the below links
//http://code.google.com/p/google-wave-resources/issues/detail?id=373
//http://code.google.com/p/google-wave-resources/issues/detail?id=354
		
public class SmileyServlet extends AbstractRobotServlet {
		
       /**
	 * Robot's version id & usage info
	 */
	private static final long serialVersionUID = 1L;
	private static final long serialSubVersionUID = 2L; //this is to help me prove that my latest changes 
                                                            //have been uploaded correctly
	private static final String serialVersionID = "Version #" + new Long(serialVersionUID).toString() + "." + 
                                                      new Long(serialSubVersionUID).toString();
	private static final String helpInfo = "\nThis robot is my learning tool for wave development, " +
                                               "so may occasionally break!  Apologies if you're one of " +
                                               "the people for whom it doesn't work!";
	private static HashMap dictionary = null;
		
	/*
	 * Creates the images & registers them against their invoking smileys 
	 * */	
	static {
		final int width = 24;
		final int height = 24;
		//http://commons.wikimedia.org/wiki/Smiley
		dictionary = new HashMap();
		dictionary.put(":)",new Image("http://upload.wikimedia.org/wikipedia/commons/7/79/Face-smile.svg",width,height,":)"));
		dictionary.put(":(",new Image("http://upload.wikimedia.org/wikipedia/commons/0/06/Face-sad.svg",width,height,":("));
		dictionary.put(";)",new Image("http://upload.wikimedia.org/wikipedia/commons/5/57/Face-wink.svg",width,height,";)"));
		dictionary.put(":D",new Image("http://upload.wikimedia.org/wikipedia/commons/1/15/Face-smile-big.svg",width,height,":D"));
	}
	
   /**
     * Handles changes to the wave 
     **/
	@Override 
	public void processEvents(RobotMessageBundle bundle) {		
		
		if (bundle.wasSelfAdded()) {
			final Blip blip = bundle.getWavelet().appendBlip();
			blip.getDocument().delete(); //FIX FOR ISSUE 354
			final TextView textView = blip.getDocument();
			textView.append( serialVersionID );
			textView.append( helpInfo );
		}
		
		for (Event e: bundle.getEvents()) {
			if ((e.getType() == EventType.BLIP_SUBMITTED) || (e.getType() == EventType.WAVELET_SELF_ADDED)) {
				final Blip blip = e.getBlip();
				smile(blip.getDocument());
			}
		}
	    
	}
	
	private void smile(TextView textView){
		final String text = textView.getText();
		Iterator<Map.Entry> i = dictionary.entrySet().iterator();
		while(i.hasNext()){
			Map.Entry pic = i.next();
			String key = pic.getKey();
			int pos = -1;
			while((pos = text.indexOf(key,++pos))>-1){
				textView.delete(new Range(pos, pos + key.length()));
				textView.insertElement(pos,pic.getValue());
			}
		}	
	}
		
}

2009-10-28

Create a free website or blog at WordPress.com.

%d bloggers like this: