From 98de0908afcc0053976def648e5abada43c6315b Mon Sep 17 00:00:00 2001 From: sugyan Date: Sun, 27 Dec 2009 23:27:30 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9B=B8=E5=BC=8F=E3=82=92=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=93=E3=81=A8=E3=81=AA=E3=81=8Fzenrize?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/zen-ra/wave_robot.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/python/zen-ra/wave_robot.py b/python/zen-ra/wave_robot.py index 8755ccf..bc792e3 100644 --- a/python/zen-ra/wave_robot.py +++ b/python/zen-ra/wave_robot.py @@ -1,9 +1,11 @@ -#/usr/bin/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- import logging +import re import yaml from zenra import Zenra +from waveapi import document from waveapi import events from waveapi import model from waveapi import robot @@ -12,6 +14,9 @@ def OnBlipSubmitted(properties, context): blip = context.GetBlipById(properties['blipId']) text = blip.GetDocument().GetText() + # 既に全裸になっていれば何もしない + if re.search(u'全裸で', text): + return # config.yamlから設定情報を取得 # --- # robot: @@ -21,10 +26,18 @@ def OnBlipSubmitted(properties, context): zenra_text = zenra.zenrize(text).decode('utf-8') logging.debug(text) logging.debug(zenra_text) + # 全裸になってなければ何もしない if text == zenra_text: return - blip.GetDocument().SetText(zenra_text) + + for match in re.finditer(u'全裸で', zenra_text): + blip.GetDocument().InsertText(match.start(), u'全裸で') + blip.GetDocument().SetAnnotation( + document.Range(match.start(), match.end()), + 'style/fontWeight', + 'bold', + ) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG)