「ぬるぽ」に反応して「ガッ」してくれるRobot

日本語を使った場合、unicodeでマッチし、unicodeでSetTextすれば普通に書き込んでくれるらしい。

#/usr/bin/env python
# -*- coding: utf-8 -*-

from waveapi import events 
from waveapi import robot


def blipSubmitted(properties, context):
    blip = context.GetBlipById(properties['blipId'])
    text = blip.GetDocument().GetText()
    if text == u'ぬるぽ\n':
        blip.CreateChild().GetDocument().SetText(u'ガッ')
        return

if __name__ == '__main__':
    sugyan_robot = robot.Robot(
        'sugyan_robot', 1.0,
        image_url = 'http://sugi1982.appspot.com/icon.png')
    sugyan_robot.RegisterHandler(events.BLIP_SUBMITTED, blipSubmitted)
    sugyan_robot.Run()