Esempio n. 1
0
        private static void SetString(LangValuesContainer data, string lang, string key, string value)
        {
            if (!data.Languages.Contains(lang))
            {
                data.Languages.Add(lang);
            }
            if (!data.TextStrings.Contains(key))
            {
                data.TextStrings.Add(key);
            }

            // create lang entity
            ConfigValue txtData = new ConfigValue()
            {
                Key       = key,
                Value     = value,
                ValueType = StrType
            };

            var langSection = data.StringsData.FirstOrDefault(x => x.Section == lang);

            if (langSection == null)
            {
                // lang section not created, so we all know what to do
                ConfigValuesContainer section = new ConfigValuesContainer(lang);
                section.Array.Add(txtData);
                data.StringsData.Add(section);
            }
            else
            {
                langSection.Add(txtData);
            }
        }
Esempio n. 2
0
 public Configs()
 {
     CustomValues   = new ConfigValuesContainer(CustomValuesSectionName);
     LanguageValues = new LangValuesContainer();
     ProxyServers   = new List <ProxyValue>();
     Dialogs        = new DialogsContainer();
 }
Esempio n. 3
0
        /// <summary>
        /// Returns default configs object
        /// </summary>
        public static Configs GetDefaultConfigs()
        {
            Configs result = new Configs();

            result.BasicDelay = 100;
            result.BotHash    = "Null";
            result.BotName    = "NoName";

            result.LanguageValues = LangValuesContainer.GetDefaultStrings();
            result.Dialogs        = new DialogsContainer();

            //fill value containers
            result.CustomValues.Array.Add(new ConfigValue()
            {
                Key         = "OnCriticalShutdownDelay",
                Value       = 4000,
                ValueFlag   = ConfigValue.ValueFlags.Default,
                ValueType   = typeof(int).ToString(),
                Name        = "On critical error shutdown delay",
                Description = "Set value in miliseconds which indicates time after critical error before app restart.\r\nBy default - 4000ms."
            });
            result.CustomValues.Array.Add(new ConfigValue()
            {
                Key         = "ShowDialogPath",
                Value       = true,
                ValueFlag   = ConfigValue.ValueFlags.Default,
                ValueType   = typeof(bool).ToString(),
                Name        = "Show dialog path",
                Description = "Enable/Disable displaying user current position in dialogs structure."
            });
            result.CustomValues.Array.Add(new ConfigValue()
            {
                Key         = "IsExtendedRegistration",
                Value       = false,
                ValueFlag   = ConfigValue.ValueFlags.Default,
                ValueType   = typeof(bool).ToString(),
                Name        = "Extended registration",
                Description = "Set 'true' if Bot requires extended registration dialogs. This mean using registration dialog!"
            });
            result.CustomValues.Array.Add(new ConfigValue()
            {
                Key         = "ButtonsPaginationValue",
                Value       = 32,
                ValueFlag   = ConfigValue.ValueFlags.Default,
                ValueType   = typeof(int).ToString(),
                Name        = "Paginated buttons per response",
                Description = "Define how many buttons should display in message"
            });
            result.CustomValues.Array.Add(new ConfigValue()
            {
                Key         = "ReplaceDialogs",
                Value       = true,
                ValueFlag   = ConfigValue.ValueFlags.Default,
                ValueType   = typeof(bool).ToString(),
                Name        = "Replace inline dialogs",
                Description = "Enable dialogs replacement during navigation."
            });
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Build serializeble configs from work data
        /// </summary>
        public Configs(BotConfigs configs, DialogsProvider dialogs)
        {
            BasicDelay = configs.BasicDelay;
            BotHash    = configs.BotHash;
            BotName    = configs.BotName;

            CustomValues   = new ConfigValuesContainer(configs.GetCustomValues(), CustomValuesSectionName);
            LanguageValues = new LangValuesContainer(configs.TextStrings);

            // fill proxies
            ProxyServers = new List <ProxyValue>();
            foreach (var prox in configs.Proxies)
            {
                ProxyServers.Add(new ProxyValue(prox));
            }

            Dialogs = new DialogsContainer(dialogs);
        }
Esempio n. 5
0
        public static LangValuesContainer GetDefaultStrings()
        {
            LangValuesContainer result = new LangValuesContainer();

            SetString(result, "en", "txt_accessDenied", "Access denied!");
            SetString(result, "en", "txt_internalServerError", "Internal server error occured!");
            SetString(result, "en", "txt_rootDialogName", "Root");
            SetString(result, "en", "txt_registrationDialogName", "Registration");
            SetString(result, "en", "txt_registrationDia_content1", "Wellcome...");

            SetString(result, "ru", "txt_accessDenied", "Нет доступа!");
            SetString(result, "ru", "txt_internalServerError", "Произошла внутренняя ошибка!");
            SetString(result, "ru", "txt_rootDialogName", "Главная");
            SetString(result, "ru", "txt_registrationDialogName", "Регистрация");
            SetString(result, "ru", "txt_registrationDia_content1", "Добро пожаловать...");

            //txt_registrationDialogName
            //txt_registrationDia_content1

            return(result);
        }