diff --git a/docs/handlers.rst b/docs/handlers.rst index e7cfd6aa..e4e45a84 100644 --- a/docs/handlers.rst +++ b/docs/handlers.rst @@ -89,6 +89,7 @@ WeRoBot会将合法的请求发送给 handlers 依次执行。 :func:`robot.update_member_card ` 会员卡积分余额发生变动 (Event) :func:`robot.card_sku_remind ` 库存警告 (Event) :func:`robot.card_pay_order ` 券点发生变动 (Event) +:func:`robot.templatesendjobfinish_event ` 模板信息推送事件 (Event) :func:`robot.submit_membercard_user_info ` 激活卡券 (Event) :func:`robot.location_event ` 上报位置 (Event) :func:`robot.unknown_event ` 未知类型 (Event) diff --git a/tests/test_handler.py b/tests/test_handler.py index c57946be..ba7b4340 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -675,6 +675,31 @@ def submit_membercard_user_info(): assert reply._args['content'] == u'现在醒一醒还来得及' +def test_templatesendjobfinish_event_handler(): + @werobot.templatesendjobfinish_event + def templatesendjobfinish_event(): + return '喵喵~模板消息已经推送' + + message = parse_user_msg( + """ + + + + 1395658920 + + + 200163836 + + + """ + ) + + reply = werobot.get_reply(message) + + assert isinstance(reply, TextReply) + assert reply._args['content'] == u'喵喵~模板消息已经推送' + + def test_unknown_event(): @werobot.unknown_event def unknown_event(message): diff --git a/tests/test_parser.py b/tests/test_parser.py index bd9673f0..699df710 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -862,7 +862,7 @@ def test_location_event(): assert message.precision == 119.385040 -def test_template_send_job_finish_event(): +def test_templatesendjobfinish_event(): message = parse_user_msg( """ diff --git a/werobot/robot.py b/werobot/robot.py index d1c89280..0e56097a 100644 --- a/werobot/robot.py +++ b/werobot/robot.py @@ -79,6 +79,7 @@ class BaseRoBot(object): 'update_member_card_event', 'card_sku_remind_event', 'card_pay_order_event', + 'templatesendjobfinish_event', 'submit_membercard_user_info_event', # event 'text', 'image', @@ -455,6 +456,12 @@ def submit_membercard_user_info(self, f): self.add_handler(f, type='submit_membercard_user_info_event') return f + def templatesendjobfinish_event(self, f): + """在模版消息发送任务完成后,微信服务器会将是否送达成功作为通知,发送到开发者中心中填写的服务器配置地址中 + """ + self.add_handler(f, type='templatesendjobfinish_event') + return f + def unknown_event(self, f): """ 为未知类型 ``(unknown_event)`` 事件添加一个 handler 方法的装饰器。