def register(f): f = method_to_func(f) if target_sequence: csequence = re.compile(target_sequence) else: csequence = None # The filtering condition is either the target bit itself or nothing global_event_handlers[f] = Trigger( SequenceReceived, lambda e: csequence is None or csequence.search(e.sequence), f) return f
def register(f): f = method_to_func(f) # The filtering condition is given as an argument. # There could be one or two state objects (corresponding to the # world state). So we check if we need to call the condition with # one or two arguments. global_event_handlers[f] = Trigger( StateChanged, lambda e: e.second_state and condition(e.state, e.second_state) or (not e.second_state and condition(e.state)), f) return f
def register(f): f = method_to_func(f) # If a target message is given, interpret it as a regular expression if target_message: cmessage = re.compile(target_message) else: cmessage = None # The filtering condition applied the target message expression # to the event message global_event_handlers[f] = Trigger( OutputMessageUpdated, lambda e: cmessage is None or cmessage.search(e.output_message), f) return f
def register(f): f = method_to_func(f) # There is no filtering condition (it always activates if registered) global_event_handlers[f] = Trigger(Timeout, lambda e: True, f) return f
def register(f): f = method_to_func(f) # The filtering condition is always True global_event_handlers[f] = Trigger(WorldStart, lambda e: True, f) return f