本文整理匯總了Python中rule.Rule.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python Rule.execute方法的具體用法?Python Rule.execute怎麽用?Python Rule.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rule.Rule
的用法示例。
在下文中一共展示了Rule.execute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: reply
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import execute [as 別名]
def reply(self, data, cb):
info = data
if not isinstance(data, Info):
info = Info(data)
if not self.config.get('keepBlank', False) and info.text:
info.text = info.text.trim()
rule_list = self.routes
waiter = self.wait_rules.get(info.user, None)
if waiter:
rule_list = [].extend(waiter).extend(self.routes)
self.last_wait_rules[info.user] = waiter
self.wait_rules[info.user] = None
for i in range(0, len(rule_list)):
rule = rule_list[i]
if Rule.is_match(info, rule):
weixinlogger.info("match %s" % rule.name)
conversationlogger.info("match %s" % rule.name)
rule.count = i
result = Rule.execute(info, rule, cb)
if isinstance(result, (str, unicode)):
result = BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, result)
if result:
if rule.replies:
self.wait(info.user, Rule.convert(rule.replies, rule.name))
return cb(None, result)
else:
logger.debug("not match %s" % rule.name)
return cb('404', BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, self.get_status('404') + info.text))