def _check_condition(conditions, member): condition_bool = False # 检查是否满足条件 for condition in conditions: checked_yesterday = None check_list = [x.strip() for x in condition.split(':')] try: days, rate, checked, points, checked_yesterday = check_list except ValueError: days, rate, checked, points = check_list bool_ = True if days: # 组龄 bool_ = bool_ and eval_bool(member['days'], days) if rate: # 打卡率 bool_ = bool_ and eval_bool(member['rate'], rate) if points: # 贡献值 bool_ = bool_ and eval_bool(member['points'], points) if checked and (not int(checked)): # 当天未打卡 bool_ = bool_ and (not member['checked']) if checked_yesterday and (not int(checked_yesterday)): # 昨天未打卡 bool_ = bool_ and (not member['checked_yesterday']) condition_bool = condition_bool or bool_ if condition_bool: break return condition_bool
def check_welcome(shanbay, member, settings): """检查是否是新人""" if eval_bool(member['days'], settings.welcome): if retry_shanbay(shanbay.send_mail, True, 'bool', [member['username']], settings.welcome_title, render(member, 'welcome_mail.txt')): print(u'欢迎短信已发送') else: print(u'欢迎短信发送失败') return member