Esempio n. 1
0
        public JToken ToJson()
        {
            JTokenStack stack = new JTokenStack(new JObject());

            stack.Set("say", writeDictionary(SayDictionary));

            return(stack.Pop());
        }
Esempio n. 2
0
        public void Load(JToken root)
        {
            JTokenStack stack = new JTokenStack(root);

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

            stack.Pop();
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        public JToken ToJson()
        {
            var stack = new JTokenStack(new JObject());

            // #general
            stack.PushNew("general");
            stack.Set("botToken", botToken);

            stack.Pop();
            // #

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

            // #voice - speak
            stack.PushNew("speak");
            stack.Set("enabled", speakEnabled);
            stack.Set("recordingDevice", speakRecordingDevice);
            stack.Set("audioType", Enum.GetName(typeof(AudioApplication), speakAudioType));
            stack.Set("bitRate", speakBitRate);
            stack.Set("bufferMillis", speakBufferMillis);
            stack.Pop();
            // #voice

            // #voice - listen
            stack.PushNew("listen");
            stack.Set("enabled", listenEnabled);
            if (listenEnabled)
            {
                //Utils.Log(LogSeverity.Warning, typeof(Config), "This feature isn't supported yet.");
                //listenEnabled = false;
            }
            stack.Set("playbackDevice", listenPlaybackDevice);
            stack.Pop();
            // #voice

            stack.Set("autoJoinVoiceChannels", writeVoiceChannels(voiceAutoJoinVoiceChannels));
            stack.Pop();
            // #

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

            // #text - commands
            stack.PushNew("commands");
            stack.Set("botAgent", commandsBotAgent);

            // #text - commands - permissions
            stack.PushNew("permissions");
            stack.Set("defaultPermissions", string.Join(" ", commandsDefaultPermissions));
            stack.Set("userPermissions", writeUserPermissions(commandsUserPermissions));
            stack.Set("rolePermissions", writeRolePermissions(commandsRolePermissions));
            stack.Pop();
            // #text - commands

            stack.Pop();
            // #text

            stack.Pop();
            // #

            return(stack.Pop());
        }