| Changes to /trunk/samples/extensions/robots/python/yasr/smiley.py |
r0 vs. r7
Edit
|
r7
|
| /trunk/samples/extensions/robots/python/yasr/smiley.py | /trunk/samples/extensions/robots/python/yasr/smiley.py r7 | ||
| Properties | |||
| svn:executable | |||
| 1 | * | ||
| Contents | |||
| 1 | #!/usr/bin/python2.4 | ||
| 2 | # | ||
| 3 | # Copyright 2009 Google Inc. All Rights Reserved. | ||
| 4 | """Implementation of the Everything and the Kitchen Sink bot | ||
| 5 | |||
| 6 | Yet another smiley robot | ||
| 7 | """ | ||
| 8 | |||
| 9 | __author__ = 'douwe@google.com (Douwe Osinga)' | ||
| 10 | |||
| 11 | import logging | ||
| 12 | |||
| 13 | from api import events | ||
| 14 | from api import robot | ||
| 15 | |||
| 16 | |||
| 17 | def OnBlipSubmitted(properties, context): | ||
| 18 | blip = context.GetBlipById(properties['blipId']) | ||
| 19 | contents = blip.GetDocument().GetText() | ||
| 20 | contents = contents.replace(':-(', unichr(0x2639)).replace(':-)', unichr(0x263A)) | ||
| 21 | blip.GetDocument().SetText(contents) | ||
| 22 | |||
| 23 | if __name__ == '__main__': | ||
| 24 | yasr = robot.Robot('Yasr', | ||
| 25 | image_url='http://wave-api-dmo.appspot.com/public/smiley.png', | ||
| 26 | profile_url='http://code.google.com') | ||
| 27 | |||
| 28 | yasr.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted) | ||
| 29 | yasr.Run(debug=True) | ||
| 30 | |||