コード例 #1
0
    def need_capabilities(self, capability_item_or_list):
        def check_if_capability_present_in_request(
                capability_to_check: str) -> bool:
            for capability_request_item in self.request.originalDetectIntentRequest.payload.surface.capabilities:
                if isinstance(
                        capability_request_item,
                        dict) and "name" in capability_request_item.keys():
                    if capability_request_item["name"] == capability_to_check:
                        return True
            return False

        if isinstance(capability_item_or_list, str):
            if (capability_item_or_list not in self.ALL_CAPABILITIES
                    or check_if_capability_present_in_request(
                        capability_to_check=capability_item_or_list) is False):
                return DummyObject()
            else:
                return self
        elif isinstance(capability_item_or_list, list):
            for capability_item in capability_item_or_list:
                if (capability_item not in self.ALL_CAPABILITIES
                        or check_if_capability_present_in_request(
                            capability_to_check=capability_item) is False):
                    return DummyObject()
            return self
        else:
            raise Exception(
                f"The variable passed to the need_capabilities function must be of type {list} or {str}"
                f"but was {capability_item_or_list} of type {type(capability_item_or_list)}"
            )
コード例 #2
0
    def session_remember(self, data_key: str, specific_object_type=None):
        raise Exception("deprecated")
        # todo: re-activate that
        return DummyObject()

        data_object = self.smart_session_user_data.get(data_key)
        if specific_object_type is None:
            return data_object.to_any()
        else:
            return data_object.to_specific_type(
                type_to_return=specific_object_type)
コード例 #3
0
 def audioPlayer(self):
     if self._audioPlayer is None:
         return DummyObject()
     return self._audioPlayer
コード例 #4
0
 def __getattr__(self, item):
     self_vars = vars(self)
     if item in self_vars:
         return self_vars[item]
     else:
         return DummyObject()
コード例 #5
0
 def track(self, name: str) -> Track:
     for track in self.tracks:
         if track.name == name:
             return track
     return DummyObject()
コード例 #6
0
 def bixbyHandlerInput(self):
     return self._bixbyHandlerInput if self._bixbyHandlerInput is not None else DummyObject()
コード例 #7
0
 def dialogFlowHandlerInput(self):
     return self._dialogFlowHandlerInput if self._dialogFlowHandlerInput is not None else DummyObject()
コード例 #8
0
 def alexaHandlerInput(self):
     return self._alexaHandlerInput if self._alexaHandlerInput is not None else DummyObject()
コード例 #9
0
 def discordHandlerInput(self):
     return self._discordHandlerInput if self._discordHandlerInput is not None else DummyObject(
     )
コード例 #10
0
 def _load_smart_session_user_data(self):
     return DummyObject()
     # todo: re-activate that
     """