From 46525efd8616ae7ab9775b1a569e926503ead2e3 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 10 Apr 2023 21:17:52 +0900 Subject: [PATCH] google_chat_ros/script/helper.py: add ~send_dialogflow_response_to_google_chat param. Set False did not returns dialogflow response to chat --- .../node_scripts/sample_app_print.py | 0 google_chat_ros/launch/google_chat.launch | 2 ++ google_chat_ros/scripts/helper.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) mode change 100755 => 100644 dialogflow_task_executive/node_scripts/sample_app_print.py diff --git a/dialogflow_task_executive/node_scripts/sample_app_print.py b/dialogflow_task_executive/node_scripts/sample_app_print.py old mode 100755 new mode 100644 diff --git a/google_chat_ros/launch/google_chat.launch b/google_chat_ros/launch/google_chat.launch index 8ef7a56ac..c374eb828 100644 --- a/google_chat_ros/launch/google_chat.launch +++ b/google_chat_ros/launch/google_chat.launch @@ -22,6 +22,7 @@ + to_dialogflow_client: $(arg to_dialogflow_client) + send_dialogflow_response_to_google_chat: $(arg send_dialogflow_response_to_google_chat) debug_sound: $(arg debug_sound) diff --git a/google_chat_ros/scripts/helper.py b/google_chat_ros/scripts/helper.py index 4b5a33247..99002b529 100644 --- a/google_chat_ros/scripts/helper.py +++ b/google_chat_ros/scripts/helper.py @@ -18,6 +18,7 @@ def __init__(self): # Get configuration params self.to_dialogflow_task_executive = rospy.get_param("~to_dialogflow_client") self.sound_play_jp = rospy.get_param("~debug_sound") + self.send_dialogflow_response_to_google_chat = rospy.get_param("~send_dialogflow_response_to_google_chat", True) self._message_sub = rospy.Subscriber("google_chat_ros/message_activity", MessageEvent, callback=self._message_cb) self.recent_message_event = None @@ -59,13 +60,14 @@ def _message_cb(self, data): thread_name = data.message.thread_name text = data.message.argument_text if self.to_dialogflow_task_executive: - chat_goal = SendMessageGoal() - chat_goal.space = space - chat_goal.thread_name = thread_name dialogflow_res = self.dialogflow_action_client(text) - content = "<{}> {}".format(sender_id, dialogflow_res.response.response) - chat_goal.text = content - self.send_chat_client(chat_goal) + if self.send_dialogflow_response_to_google_chat: + chat_goal = SendMessageGoal() + chat_goal.space = space + chat_goal.thread_name = thread_name + content = "<{}> {}".format(sender_id, dialogflow_res.response.response) + chat_goal.text = content + self.send_chat_client(chat_goal) if self.sound_play_jp: sound_goal = SoundRequestGoal() sound_goal.sound_request.sound = sound_goal.sound_request.SAY