google wave に招待してもらったけど、特にやることがなかったので、例によって単純な robot を動かしてみた。
発言を書き換える robot の作り方は、神記事(Google Wave API開発ガイド(後編)JavaとPythonでGoogle WaveのRobotを作るには(3/4)−@IT) で完璧に解説されている。記事を見ながら appspot + google wave に入門し、vaginakun を google wave に解き放つことができた。
vaginakun@appspot.com を contact に入れて new wave 作れば、変換エンジンこそ古いものの #vagina の雰囲気を味わえるよ!
#!/usr/bin/env python # -*- coding: utf-8 -*- from waveapi import events from waveapi import model from waveapi import robot import urllib def OnParticipantsChanged(properties, context): added = properties['participantsAdded'] for participant in added: Greet(context, participant) def OnRobotAdded(properties, context): root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText('hello') def OnBlipCreated(properties, context): blip = context.GetBlipById(properties['blipId']) text = blip.GetDocument().GetText() d = urllib.urlopen("http://woremacx.com/text2vagina/?text=" + urllib.quote(text.encode('utf-8'))) res = d.read() blip.GetDocument().SetText(res) def Greet(context, participant): root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText(participant + u" さん、こんにちは!") if __name__ == '__main__': myRobot = robot.Robot('vaginakun', image_url='http://vaginakun.appspot.com/assets/icon.png', version='4', profile_url='http://vaginakun.appspot.com/') myRobot.RegisterHandler(events.WAVELET_PARTICIPANTS_CHANGED, OnParticipantsChanged) myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipCreated) myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded) myRobot.Run()

Leave a comment