示例#1
0
 def matcher(func):
     """Add decorated function to skills list for Rasa NLU matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"rasanlu_intent": intent}
     )
     return func
示例#2
0
 def matcher(func):
     """Add decorated function to skills list for Dialogflow matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"dialogflow_intent": intent}
     )
     return func
示例#3
0
 def matcher(func):
     """Add decorated function to skills list for luisai matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"luisai_intent": intent}
     )
     return func
示例#4
0
 def matcher(func):
     """Add decorated function to skills list for always matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"always": True}
     )
     return func
示例#5
0
 def matcher(func):
     """Add decorated function to skills list for always matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"always": True}
     )
     return func
示例#6
0
 def matcher(func):
     """Add decorated function to skills list for Dialogflow matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"dialogflow_intent": intent}
     )
     return func
示例#7
0
 def matcher(func):
     """Add decorated function to skills list for luisai matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"luisai_intent": intent}
     )
     return func
示例#8
0
 def matcher(func):
     """Add decorated function to skills list for Rasa NLU matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"rasanlu_intent": intent}
     )
     return func
示例#9
0
    def matcher(func):
        """Add decorated function to skills list for webhook matching."""
        func = add_skill_attributes(func)
        func.matchers.append(
            {"webhook": webhook}
        )

        return func
示例#10
0
 def matcher(func):
     """Add decorated function to skills list for crontab matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"crontab": crontab,
          "timezone": timezone}
     )
     return func
示例#11
0
 def constraint_decorator(func):
     """Add user constraint to skill."""
     def constraint_callback(message, users=users):
         """Check if the user is correct."""
         return message.user in users
     func = add_skill_attributes(func)
     func.constraints.append(constraint_callback)
     return func
示例#12
0
 def constraint_decorator(func):
     """Add room constraint to skill."""
     def constraint_callback(message, rooms=rooms):
         """Check if the room is correct."""
         return message.target in rooms
     func = add_skill_attributes(func)
     func.constraints.append(constraint_callback)
     return func
示例#13
0
 def matcher(func):
     """Add decorated function to skills list for catch-all matching."""
     func = add_skill_attributes(func)
     func.matchers.append({
         "catchall": True,
         "messages_only": messages_only
     })
     return func
示例#14
0
    def matcher(func):
        """Add decorated function to skills list for webhook matching."""
        func = add_skill_attributes(func)
        func.matchers.append(
            {"webhook": webhook}
        )

        return func
示例#15
0
 def matcher(func):
     """Add decorated function to skills list for crontab matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"crontab": crontab,
          "timezone": timezone}
     )
     return func
示例#16
0
    def constraint_decorator(func):
        """Add room constraint to skill."""
        def constraint_callback(message, rooms=rooms):
            """Check if the room is correct."""
            return message.target in rooms

        func = add_skill_attributes(func)
        func.constraints.append(constraint_callback)
        return func
示例#17
0
    def constraint_decorator(func):
        """Add connectors constraint to skill."""
        def constraint_callback(message, connectors=connectors):
            """Check if the connectors is correct."""
            return message.connector and (message.connector.name in connectors)

        func = add_skill_attributes(func)
        func.constraints.append(constraint_callback)
        return func
示例#18
0
    def constraint_decorator(func):
        """Add user constraint to skill."""
        def constraint_callback(message, users=users):
            """Check if the user is correct."""
            return message.user in users

        func = add_skill_attributes(func)
        func.constraints.append(constraint_callback)
        return func
示例#19
0
 def constraint_decorator(func):
     """Add connectors constraint to skill."""
     def constraint_callback(message, connectors=connectors):
         """Check if the connectors is correct."""
         print(message.connector.name)
         print(connectors)
         return message.connector.name in connectors
     func = add_skill_attributes(func)
     func.constraints.append(constraint_callback)
     return func
示例#20
0
 def matcher(func):
     """Add decorated function to skills list for regex matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"regex": {
             "expression": regex,
             "case_sensitive": case_sensitive,
             "score_factor": score_factor or REGEX_SCORE_FACTOR,
         }}
     )
     return func
示例#21
0
 def matcher(func):
     """Add decorated function to skills list for regex matching."""
     func = add_skill_attributes(func)
     func.matchers.append(
         {"regex": {
             "expression": regex,
             "case_sensitive": case_sensitive,
             "matching_condition": matching_condition,
             "score_factor": score_factor or REGEX_SCORE_FACTOR,
         }}
     )
     return func
示例#22
0
 def matcher(func):
     """Add decorated function to skills list for parse matching."""
     func = add_skill_attributes(func)
     func.matchers.append({
         "parse_format": {
             "expression": format_str,
             "case_sensitive": case_sensitive,
             "matching_condition": matching_condition,
             "score_factor": score_factor or REGEX_PARSE_SCORE_FACTOR,
         }
     })
     return func
示例#23
0
    def constraint_decorator(func):
        """Add room constraint to skill."""
        def constraint_callback(message, rooms=rooms):
            """Check if the room is correct."""
            if hasattr(message.connector, "lookup_target"):
                rooms = list(map(message.connector.lookup_target, rooms))

            return message.target in rooms

        func = add_skill_attributes(func)
        if invert:
            constraint_callback = invert_wrapper(constraint_callback)
        func.constraints.append(constraint_callback)
        return func
示例#24
0
 def matcher(func):
     """Add decorated function to list for event matching."""
     func = add_skill_attributes(func)
     func.matchers.append({"event_type": dict(type=event_type, **kwargs)})
     return func
示例#25
0
 def matcher(func):
     """Add decorated function to list for event matching."""
     func = add_skill_attributes(func)
     func.matchers.append({"event_type": {"type": event_type}})
     return func