Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created December 1, 2009 09:55
Show Gist options
  • Select an option

  • Save hakobe/246195 to your computer and use it in GitHub Desktop.

Select an option

Save hakobe/246195 to your computer and use it in GitHub Desktop.
# coding:utf-8
from waveapi import events
from waveapi import model
from waveapi import robot
import re
import time
class Dispatcher(object):
def __init__(self, properties, context):
self.properties = properties
self.context = context
def say(self, message):
self.context.GetRootWavelet().CreateBlip().GetDocument().SetText(message)
def dispatch(self, message):
if re.search(r'^\s*bus', message):
self.say('bus!!')
if re.search(r'^\s*time', message):
self.say(time.ctime())
if re.search(r'hakobot', message):
self.say('呼びましたか?')
def blipSubmitted(properties, context):
blip = context.GetBlipById(properties['blipId'])
message = blip.GetDocument().GetText()
Dispatcher(properties, context).dispatch(message)
if __name__ == '__main__':
robo = robot.Robot('hakobot', 3, image_url='http://www.cs.ritsumei.ac.jp/lib/tpl/arctic-mouri/images/logo.png')
robo.RegisterHandler(events.BLIP_SUBMITTED, blipSubmitted)
robo.Run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment