Пример #1
0
        public void Load(JToken root)
        {
            JTokenStack stack = new JTokenStack(root);

            SayDictionary = readDictionary((JObject)stack.Get("say"));

            stack.Pop();
        }
Пример #2
0
        public void Load(JToken root)
        {
            var stack = new JTokenStack(root);

            // #general
            stack.Push("general");
            botToken = (string)stack.Get("botToken");
            stack.Pop();
            // #

            // #voice
            stack.Push("voice");

            // #voice - speak
            stack.Push("speak");
            speakEnabled         = (bool)stack.Get("enabled");
            speakRecordingDevice = (string)stack.Get("recordingDevice");
            speakAudioType       = (AudioApplication)Enum.Parse(typeof(AudioApplication), (string)stack.Get("audioType"));
            speakBitRate         = (int?)stack.Get("bitRate");
            speakBufferMillis    = (int)stack.Get("bufferMillis");
            stack.Pop();
            // #voice

            // #voice - listen
            stack.Push("listen");
            listenEnabled        = (bool)stack.Get("enabled");
            listenPlaybackDevice = (string)stack.Get("playbackDevice");
            stack.Pop();
            // #voice

            voiceAutoJoinVoiceChannels = readVoiceChannels((JObject)stack.Get("autoJoinVoiceChannels"));
            stack.Pop();
            // #

            // #text
            stack.Push("text");

            // #text - commands
            stack.Push("commands");
            commandsBotAgent = (string)stack.Get("botAgent");
            if (commandsBotAgent == null)
            {
                throw new FormatException("bot agent cannot be null");
            }

            // #text - commands - permissions
            stack.Push("permissions");
            commandsDefaultPermissions.Clear();
            foreach (var defaultPermission in stack.Get("defaultPermissions").Value <string>().Split(' '))
            {
                commandsDefaultPermissions.Add(defaultPermission);
            }
            commandsUserPermissions = readUserPermissions((JObject)stack.Get("userPermissions"));
            commandsRolePermissions = readRolePermissions((JObject)stack.Get("rolePermissions"));
            stack.Pop();
            // #text - commands

            stack.Pop();
            // #text

            stack.Pop();
            // #

            stack.Pop();
        }