Beispiel #1
0
        public HypeCommandsSettings EnsureDefaultHypeSettings(string userID)
        {
            var key = HypeCommandsSettings.GetKey(userID);
            HypeCommandsSettings hypeCommandsSettings;

            try
            {
                hypeCommandsSettings = this.redis.Get <HypeCommandsSettings>(key);
            }
            catch (System.Runtime.Serialization.SerializationException)
            {
                this.redis.Delete(key);
                hypeCommandsSettings = null;
            }

            if (hypeCommandsSettings == null)
            {
                hypeCommandsSettings = new HypeCommandsSettings
                {
                    userID       = userID,
                    hypeCommands = new List <Common.Models.HypeCommand>
                    {
                        new Common.Models.HypeCommand
                        {
                            accessLevel      = (int)KomaruBot.Common.Constants.AccessLevel.Public,
                            commandResponses = new List <Common.Models.HypeCommandResponse>
                            {
                                new Common.Models.HypeCommandResponse {
                                    message = "D e e R F o r C e",
                                }
                            },
                            commandText             = "!df",
                            numberOfResponses       = 1,
                            pointsCost              = 0,
                            randomizeResponseOrders = false,
                        },
                        new Common.Models.HypeCommand
                        {
                            accessLevel      = (int)KomaruBot.Common.Constants.AccessLevel.Public,
                            commandResponses = new List <Common.Models.HypeCommandResponse>
                            {
                                new Common.Models.HypeCommandResponse {
                                    message = "D e e R F o r C e",
                                }
                            },
                            commandText             = "!deerforce",
                            numberOfResponses       = 1,
                            pointsCost              = 0,
                            randomizeResponseOrders = false,
                        },
                    },
                };
                this.redis.Set(key, hypeCommandsSettings);
            }

            return(hypeCommandsSettings);
        }
Beispiel #2
0
 public void SaveSettings(HypeCommandsSettings toSave)
 {
     this.redis.Set(toSave.GetKey(), toSave);
 }