def run(self, payload, user): callback_id = user.message.callback_id if user.behaviors.has_callback(callback_id): params = {log_const.KEY_NAME: "handling_respond"} log("HandlerRespond started", user, params) action_params = user.behaviors.get_callback_action_params( callback_id) if action_params: app_info = None for original_message_name in [ MESSAGE_TO_SKILL, SERVER_ACTION, RUN_APP ]: if original_message_name in action_params: app_info = AppInfo( action_params[original_message_name].get( APP_INFO, {})) break smart_kit_metrics.counter_incoming(self.app_name, user.message.message_name, self.__class__.__name__, user, app_info=app_info) text_preprocessing_result = TextPreprocessingResult( payload.get("message", {})) params = { log_const.KEY_NAME: log_const.NORMALIZED_TEXT_VALUE, "normalized_text": str(text_preprocessing_result.raw), } log("text preprocessing result: '%(normalized_text)s'", user, params) action_name = self.get_action_name(payload, user) action = user.descriptions["external_actions"][action_name] action_params = self.get_action_params(payload) return action.run(user, text_preprocessing_result, action_params)
def run(self, payload, user): # отправка события о входящем сообщении в систему мониторинга smart_kit_metrics.counter_incoming(self.app_name, user.message.message_name, self.__class__.__name__, user, app_info=user.message.app_info)
def run(self, payload, user): callback_id = user.message.callback_id action_params = self.get_action_params(payload, user) action_name = self.get_action_name(payload, user) params = { log_const.KEY_NAME: "process_time", "callback_id": str(callback_id), "process_time": self.get_processing_time(user), "action_name": action_name } if user.behaviors.has_callback(callback_id): action_params = self.get_action_params(payload, user) params["to_message_name"] = action_params.get(TO_MESSAGE_NAME) log("HandlerRespond with action %(action_name)s started respond on %(to_message_name)s", user, params) else: log("HandlerRespond with action %(action_name)s started without callback", user, params) smart_kit_metrics.counter_incoming(self.app_name, user.message.message_name, self.__class__.__name__, user) text_preprocessing_result = TextPreprocessingResult(payload.get("message", {})) if payload.get("message"): params = { log_const.KEY_NAME: log_const.NORMALIZED_TEXT_VALUE, "normalized_text": str(text_preprocessing_result.raw), } log("text preprocessing result: '%(normalized_text)s'", user, params, level="DEBUG") action = user.descriptions["external_actions"][action_name] return action.run(user, text_preprocessing_result, action_params)
def run(self, payload, user): super().run(payload, user) callback_id = user.message.callback_id if user.behaviors.has_callback(callback_id): params = {log_const.KEY_NAME: "handling_timeout"} log("TimeoutHandler started", user, params) action_params = user.behaviors.get_callback_action_params( callback_id) if action_params: app_info = None for original_message_name in [SERVER_ACTION, RUN_APP]: if original_message_name in action_params: app_info = AppInfo( action_params[original_message_name].get( APP_INFO, {})) break smart_kit_metrics.counter_incoming(self.app_name, user.message.message_name, self.__class__.__name__, user, app_info=app_info) callback_id = user.message.callback_id result = user.behaviors.timeout(callback_id) return result
def run(self, payload, user): action_params = pickle_deepcopy(self.get_action_params(payload)) params = { log_const.KEY_NAME: "handling_server_action", "server_action_params": str(action_params), "server_action_id": self.get_action_name(payload, user) } log("HandlerServerAction %(server_action_id)s started", user, params) app_info = user.message.app_info smart_kit_metrics.counter_incoming(self.app_name, user.message.message_name, self.__class__.__name__, user, app_info=app_info) action_id = self.get_action_name(payload, user) action = user.descriptions["external_actions"][action_id] return action.run(user, TextPreprocessingResult({}), action_params)