rust_rcs_client/chat_bot/
chatbot_config.rs

1// Copyright 2023 宋昊文
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::provisioning::rcs_application::RcsApplication;
16
17pub struct ChatbotConfig {
18    pub chatbot_directory: Option<String>,
19    pub bot_info_fqdn: Option<String>,
20    pub specific_chatbots_lists: Option<String>,
21}
22
23impl ChatbotConfig {
24    pub fn new() -> ChatbotConfig {
25        ChatbotConfig {
26            chatbot_directory: None,
27            bot_info_fqdn: None,
28            specific_chatbots_lists: None,
29        }
30    }
31
32    pub fn update_configuration(&mut self, rcs_app: &RcsApplication) {
33        if let Some(messaging_config) = rcs_app.get_messaging_config() {
34            if let Some(chatbot_config) = messaging_config.get_chat_bot_config() {
35                self.chatbot_directory = chatbot_config.get_chatbot_directory();
36                self.bot_info_fqdn = chatbot_config.get_bot_info_fqdn();
37                self.specific_chatbots_lists = chatbot_config.get_specific_chatbots_lists();
38            }
39        }
40    }
41}