Exemple #1
0
        private void SetFields(string email, byte[] salt, byte[] passwordVerifier, UserLevels userLevel)
        {
            this.Email            = email;
            this.Salt             = salt;
            this.PasswordVerifier = passwordVerifier;
            this.UserLevel        = userLevel;

            this.BnetAccountID       = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.AccountId).SetLow(this.PersistentID).Build();
            this.BnetGameAccountID   = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(this.PersistentID).Build();
            this.BannerConfiguration = D3.Account.BannerConfiguration.CreateBuilder()
                                       .SetBannerShape(2952440006)
                                       .SetSigilMain(976722430)
                                       .SetSigilAccent(803826460)
                                       .SetPatternColor(1797588777)
                                       .SetBackgroundColor(1379006192)
                                       .SetSigilColor(1797588777)
                                       .SetSigilPlacement(3057352154)
                                       .SetPattern(4173846786)
                                       .SetUseSigilVariant(true)
                                       .SetEpicBanner(0)
                                       .Build();

            this.Achievements        = new List <bnet.protocol.achievements.AchievementUpdateRecord>();
            this.AchievementCriteria = new List <bnet.protocol.achievements.CriteriaUpdateRecord>();
        }
        public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help)
        {
            var app = ctx.Client.CurrentApplication;

            if (app == null)
            {
                return(false);
            }

            if (help || app.Owners.Any(x => x.Id == ctx.User.Id))
            {
                return(true);
            }

            var userLevel = ctx.Member != null?
                            UserLevels.GetMemberLevel(ctx.Member) :
                                UserLevels.GetLevel(ctx.User.Id, ctx.Guild.Id);

            if (ctx.Member == ctx.Guild.Owner && userLevel < (int)ShimaConsts.UserPermissionLevel.DEFAULT_SERVER_OWNER)
            {
                userLevel = (int)ShimaConsts.UserPermissionLevel.DEFAULT_SERVER_OWNER;
            }

            if (userLevel < level)
            {
                if (!string.IsNullOrWhiteSpace(failMessage))
                {
                    await CTX.RespondSanitizedAsync(ctx, failMessage);
                }
                return(false);
            }
            return(true);
        }
Exemple #3
0
        public Account(string email, string password, UserLevels userLevel) // Account with **newly generated** persistent ID
            : base()
        {
            if (password.Length > 16)
            {
                password = password.Substring(0, 16);                       // make sure the password does not exceed 16 chars.
            }
            var salt             = SRP6a.GetRandomBytes(32);
            var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt);

            this.SetFields(email, salt, passwordVerifier, userLevel);
        }
Exemple #4
0
        private void LoadAndParseSettingsFiles()
        {
            string propertiesFileContents = StaticData.Instance.ReadAllText(Path.Combine("SliceSettings", "Properties.json"));

            settingsData = JsonConvert.DeserializeObject <List <OrganizerSettingsData> >(propertiesFileContents) as List <OrganizerSettingsData>;

            OrganizerUserLevel userLevelToAddTo = null;
            OrganizerCategory  categoryToAddTo  = null;
            OrganizerGroup     groupToAddTo     = null;
            OrganizerSubGroup  subGroupToAddTo  = null;

            foreach (string line in StaticData.Instance.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    switch (CountLeadingSpaces(line))
                    {
                    case 0:
                        userLevelToAddTo = new OrganizerUserLevel(sanitizedLine);
                        UserLevels.Add(sanitizedLine, userLevelToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new OrganizerCategory(sanitizedLine);
                        userLevelToAddTo.CategoriesList.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new OrganizerGroup(sanitizedLine);
                        categoryToAddTo.GroupsList.Add(groupToAddTo);
                        break;

                    case 6:
                        subGroupToAddTo = new OrganizerSubGroup(sanitizedLine);
                        groupToAddTo.SubGroupsList.Add(subGroupToAddTo);
                        break;

                    case 8:
                        OrganizerSettingsData data = GetSettingsData(sanitizedLine);
                        if (data != null)
                        {
                            subGroupToAddTo.SettingDataList.Add(data);
                        }

                        break;

                    default:
                        throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Exemple #5
0
        public ArrayList GetActivatedLevels()
        {
            ArrayList arrLevels = new ArrayList();

            if (IsOnline)
            {
                MethodInfo m;

                Assembly assemblyInstance = Assembly.Load("EPMLiveAccountManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5");
                Type     thisClass        = assemblyInstance.GetType("EPMLiveAccountManagement.AccountManagement", true, true);

                m         = thisClass.GetMethod("GetActivatedFeatures");
                arrLevels = (ArrayList)m.Invoke(null, new object[] { _web.Site.ID });
            }
            else
            {
                int type = 0;

                SortedList slAvailable = GetAllAvailableLevels(out type);

                if (type == 3)
                {
                    UserLevels uls = new UserLevels();

                    foreach (System.Collections.Generic.KeyValuePair <int, UserLevel> ul in uls)
                    {
                        UserLevel oUl = (UserLevel)ul.Value;

                        if (slAvailable.Contains(oUl.id))
                        {
                            foreach (int level in oUl.levels)
                            {
                                if (!arrLevels.Contains(level.ToString()))
                                {
                                    arrLevels.Add(level.ToString());
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (DictionaryEntry de in slAvailable)
                    {
                        arrLevels.Add(de.Key.ToString());
                    }
                }
            }

            return(arrLevels);
        }
Exemple #6
0
        private void LoadAndParseSettingsFiles()
        {
            UserLevel userLevelToAddTo = null;
            Category  categoryToAddTo  = null;
            Group     groupToAddTo     = null;
            SubGroup  subGroupToAddTo  = null;

            foreach (string line in AggContext.StaticData.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    switch (CountLeadingSpaces(line))
                    {
                    case 0:
                        userLevelToAddTo = new UserLevel(sanitizedLine);
                        UserLevels.Add(sanitizedLine, userLevelToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new Category(sanitizedLine, userLevelToAddTo);
                        userLevelToAddTo.Categories.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new Group(sanitizedLine, categoryToAddTo);
                        categoryToAddTo.Groups.Add(groupToAddTo);
                        break;

                    case 6:
                        subGroupToAddTo = new SubGroup(sanitizedLine, groupToAddTo);
                        groupToAddTo.SubGroups.Add(subGroupToAddTo);
                        break;

                    case 8:
                        SliceSettingData data = GetSettingsData(sanitizedLine);
                        if (data != null)
                        {
                            subGroupToAddTo.Settings.Add(data);
                            data.OrganizerSubGroup = subGroupToAddTo;
                            userLevelToAddTo.AddSetting(data.SlicerConfigName, subGroupToAddTo);
                        }

                        break;

                    default:
                        throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Exemple #7
0
 public void UpdateUserLevel(UserLevels userLevel)
 {
     this.UserLevel = userLevel;
     try
     {
         var query = string.Format("UPDATE accounts SET userLevel={0} WHERE id={1}", (byte)userLevel, this.PersistentID);
         var cmd   = new SQLiteCommand(query, DBManager.Connection);
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.ErrorException(e, "UpdateUserLevel()");
     }
 }
Exemple #8
0
        private static int CheckOldPurchaseMethod(ActFeature feature, string username, DataSet dsInfo)
        {
            if (dsInfo.Tables.Count < 2 || dsInfo.Tables[1].Rows.Count == 0 || !dsInfo.Tables[1].Columns.Contains(LevelColumn))
            {
                throw new InvalidOperationException($"dsInfo.Tables[1].Rows[0][{LevelColumn}] should not be null");
            }

            int contractlevel;

            if (!int.TryParse(dsInfo.Tables[1].Rows[0][LevelColumn]?.ToString(), out contractlevel))
            {
                contractlevel = 2;
            }

            var userLevels = new UserLevels();
            var userLevel  = userLevels.GetById(1);

            if (contractlevel == 2)
            {
                userLevel = userLevels.GetById(2);
            }
            else if (contractlevel == 4)
            {
                userLevel = userLevels.GetById(3);
            }

            if (userLevel == null || userLevel.levels == null)
            {
                throw new InvalidOperationException("userLevel.levels should not be null.");
            }
            if (userLevel.levels.Contains((int)feature))
            {
                if (HasAccess(username, dsInfo))
                {
                    return(AccessLicense);
                }
                return(6);
            }

            return(5);
        }
 public RoleLevelAuthorizationAttribute(UserLevels minLevel)
 {
     this.MinimumLevel = minLevel;
 }
Exemple #10
0
        private void SetFields(string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel)
        {
            InitPresenceFields();

            this.Email            = email;
            this.Salt             = salt;
            this.PasswordVerifier = passwordVerifier;
            this.UserLevel        = userLevel;

            this.BnetEntityId = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.AccountId).SetLow(this.PersistentID).Build();

            this.Name     = battleTagName;
            this.HashCode = hashCode;
            this.AccountBattleTagField.Value = Name + "#" + HashCode.ToString("D4");
        }
Exemple #11
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.LastSelectedHeroField.Value = Account.AccountHasNoToons;
     LoadGameAccountIds();
     this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
 }
Exemple #12
0
 public void UpdateUserLevel(UserLevels userLevel)
 {
     this.UserLevel = userLevel;
     try
     {
         var query = string.Format("UPDATE accounts SET userLevel={0} WHERE id={1}", (byte)userLevel, this.PersistentID);
         var cmd = new SQLiteCommand(query, DBManager.Connection);
         cmd.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Logger.ErrorException(e, "UpdateUserLevel()");
     }
 }
Exemple #13
0
        public Account(string email, string password, UserLevels userLevel) // Account with **newly generated** persistent ID
            : base()
        {
            if (password.Length > 16) password = password.Substring(0, 16); // make sure the password does not exceed 16 chars.

            var salt = SRP6a.GetRandomBytes(32);
            var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt);

            this.SetFields(email, salt, passwordVerifier, userLevel);
        }
Exemple #14
0
 public static void LogInUserSession(string userName, UserLevels userLevel, string email)
 {
     CurrentSession.UserName = userName;
     CurrentSession.UserPermissionLevel = userLevel;
     CurrentSession.Email = email;
 }
Exemple #15
0
        private int CheckOnsiteFeatureLicense(ActFeature feature, string username, SPSite site)
        {
            int ActivationType = 0;

            SortedList slAvailable = GetAllAvailableLevels(out ActivationType);

            switch (ActivationType)
            {
            case 1:
            case 2:
                if (slAvailable.ContainsKey((int)feature))
                {
                    if ((int)slAvailable[(int)feature] == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        if (username.ToLower() == "sharepoint\\system")
                        {
                            return(0);
                        }
                        else
                        {
                            return(SetUserActivation((int)feature, username, site));
                        }
                    }
                }
                else
                {
                    return(5);
                }

            case 3:
                bool HasPurchased = false;
                bool HasAccess    = false;

                UserLevels uls = new UserLevels();

                foreach (System.Collections.Generic.KeyValuePair <int, UserLevel> ul in uls)
                {
                    UserLevel oUl = (UserLevel)ul.Value;

                    if (slAvailable.Contains(oUl.id))
                    {
                        if (oUl.levels.Contains((int)feature))
                        {
                            if (username.ToLower() == "sharepoint\\system")
                            {
                                return(0);
                            }

                            HasPurchased = true;

                            ArrayList arrUsers = GetFeatureUsers(1000);

                            bool userAlreadyIn = false;

                            int featureUserCount = 0;

                            foreach (string sUser in arrUsers)
                            {
                                try
                                {
                                    string[] sUserInfo = sUser.Split(':');

                                    if (sUserInfo[1] == oUl.id.ToString())
                                    {
                                        featureUserCount++;
                                    }

                                    if (sUserInfo[0] == username && sUserInfo[1] == oUl.id.ToString() && oUl.levels.Contains((int)feature))
                                    {
                                        userAlreadyIn = true;
                                    }
                                }
                                catch { }
                            }

                            if (userAlreadyIn)
                            {
                                if (featureUserCount > (int)slAvailable[oUl.id])
                                {
                                    return(2);
                                }
                                HasAccess = true;
                            }
                        }
                    }
                }

                if (HasAccess)
                {
                    return(0);
                }
                else if (HasPurchased)
                {
                    return(6);
                }
                else
                {
                    return(5);
                }
            }

            return(1);
        }
Exemple #16
0
 /// <summary>
 /// Marks the method as being the chat handler for a <c>!botname command</c>.
 /// </summary>
 /// <param name="command">The command to detect.</param>
 /// <param name="permission">The default permission required to use the command.</param>
 public BotnameChatCommandAttribute(string command, UserLevels permission) : base(command, permission)
 {
 }
Exemple #17
0
 /// <summary>
 /// Marks the method as being the handler for a <c>!command subcommand</c>.
 /// </summary>
 /// <param name="command">The command to detect, without the <c>!</c>.</param>
 /// <param name="subcommand">The subcommand to detect.</param>
 /// <param name="permission">The default permission required to use the subcommand.</param>
 public CommandAttribute(string command, string subcommand, UserLevels permission)
 {
     this.Command    = command;
     this.SubCommand = subcommand;
     this.Permission = permission;
 }
Exemple #18
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.SetFields(email, salt, passwordVerifier, userLevel);
 }
Exemple #19
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
 }
 /// <summary>
 /// Marks the method as being the whisper handler for a <c>!command</c>.
 /// </summary>
 /// <param name="command">The command to detect.</param>
 /// <param name="permission">The default permission required to use the command.</param>
 public WhisperCommandAttribute(string command, UserLevels permission) : base(command, permission)
 {
 }
 public RoleAuthAttribute(UserLevels minLevel)
 {
     this.MinimumLevel = minLevel;
 }
Exemple #22
0
        public bool Create(string name, string lastname, string mothers_lastname, string email, string password, UserLevels UserLv, string street, string house_No, string residential, string PO, string region_state, string CURP, string RFC)
        {
            List <DataCollection> data = new List <DataCollection>();

            data.Add(new DataCollection("name", Types.VARCHAR, name));
            data.Add(new DataCollection("lastname", Types.VARCHAR, lastname));
            data.Add(new DataCollection("mothers_lastname", Types.VARCHAR, mothers_lastname));
            data.Add(new DataCollection("email", Types.VARCHAR, email));
            data.Add(new DataCollection("password", Types.VARCHAR, password));
            data.Add(new DataCollection("type", Types.VARCHAR, UserLv));
            data.Add(new DataCollection("street", Types.VARCHAR, street));
            data.Add(new DataCollection("house_number", Types.VARCHAR, house_No));
            data.Add(new DataCollection("residential", Types.VARCHAR, residential));
            data.Add(new DataCollection("PO", Types.VARCHAR, PO));
            data.Add(new DataCollection("region_state", Types.VARCHAR, region_state));
            data.Add(new DataCollection("CURP", Types.VARCHAR, CURP));
            data.Add(new DataCollection("RFC", Types.VARCHAR, RFC));

            bool res = base.Create(data);

            if (!res)
            {
                this.ERROR = BD.ERROR;
            }
            return(res);
        }
Exemple #23
0
        private void SetFields(string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel)
        {
            InitPresenceFields();

            this.Email = email;
            this.Salt = salt;
            this.PasswordVerifier = passwordVerifier;
            this.UserLevel = userLevel;

            this.BnetEntityId = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.AccountId).SetLow(this.PersistentID).Build();

            this.Name = battleTagName;
            this.HashCode = hashCode;
            this.AccountBattleTagField.Value = Name + "#" + HashCode.ToString("D4");

        }
Exemple #24
0
        void LoadAndParseSettingsFiles(string properties, string layout)
        {
            {
                string propertiesFileContents = "";
                using (FileStream fileStream = new FileStream(properties, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader propertiesReader = new StreamReader(fileStream))
                    {
                        propertiesFileContents = propertiesReader.ReadToEnd();
                    }
                }

                string[] lines = propertiesFileContents.Split('\n');
                foreach (string line in lines)
                {
                    if (line.Trim().Length > 0)
                    {
                        settingsData.Add(OrganizerSettingsData.NewOrganizerSettingData(line));
                    }
                }
            }

            {
                string layoutFileContents = "";
                using (FileStream fileStream = new FileStream(layout, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader layoutReader = new StreamReader(fileStream))
                    {
                        layoutFileContents = layoutReader.ReadToEnd();
                    }
                }

                OrganizerUserLevel userLevelToAddTo = null;
                OrganizerCategory  categoryToAddTo  = null;
                OrganizerGroup     groupToAddTo     = null;
                OrganizerSubGroup  subGroupToAddTo  = null;
                string[]           lines            = layoutFileContents.Split('\n');
                foreach (string line in lines)
                {
                    if (line.Length > 0)
                    {
                        switch (CountLeadingSpaces(line))
                        {
                        case 0:
                            string userLevelText = line.Replace('"', ' ').Trim();
                            userLevelToAddTo = new OrganizerUserLevel(userLevelText);
                            UserLevels.Add(userLevelText, userLevelToAddTo);
                            break;

                        case 2:
                            categoryToAddTo = new OrganizerCategory(line.Replace('"', ' ').Trim());
                            userLevelToAddTo.CategoriesList.Add(categoryToAddTo);
                            break;

                        case 4:
                            groupToAddTo = new OrganizerGroup(line.Replace('"', ' ').Trim());
                            categoryToAddTo.GroupsList.Add(groupToAddTo);
                            break;

                        case 6:
                            subGroupToAddTo = new OrganizerSubGroup(line.Replace('"', ' ').Trim());
                            groupToAddTo.SubGroupsList.Add(subGroupToAddTo);
                            break;

                        case 8:
                            subGroupToAddTo.SettingDataList.Add(GetSettingsData(line.Replace('"', ' ').Trim()));
                            break;

                        default:
                            throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                        }
                    }
                }
            }
        }
Exemple #25
0
 /// <summary>
 /// Marks the method as being the chat handler for a <c>!command subcommand</c>.
 /// </summary>
 /// <param name="command">The command to detect.</param>
 /// <param name="subcommand">The subcommand to detect.</param>
 /// <param name="permission">The default permission required to use the subcommand.</param>
 public ChatCommandAttribute(string command, string subcommand, UserLevels permission) : base(command, subcommand, permission)
 {
 }
Exemple #26
0
        private void HandleOfflineCase3(string username, SortedList sortedAvailableLevels, ArrayList levels)
        {
            var userLevels = new UserLevels();

            var currentActivatedUsers = GetFeatureUsers(1000);

            foreach (var userLevel in userLevels)
            {
                var userLevelValue = userLevel.Value;

                var activatedUsers = 0;

                foreach (string sUser in currentActivatedUsers)
                {
                    try
                    {
                        var user = sUser.Split(':');
                        if (user[1] == userLevelValue.id.ToString())
                        {
                            activatedUsers++;
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Exception Suppressed {0}", ex);
                    }
                }

                var availAct = 0;

                var level = new ActLevel();

                var totalCount = 0;

                if (sortedAvailableLevels.ContainsKey(userLevelValue.id))
                {
                    totalCount = (int)sortedAvailableLevels[userLevelValue.id];
                }

                if (totalCount > 0 || userLevelValue.id == 0)
                {
                    if (!string.IsNullOrWhiteSpace(username) && currentActivatedUsers.Contains(string.Format("{0}:{1}", username, userLevelValue.id)))
                    {
                        availAct            = 1;
                        level.isUserInLevel = true;
                    }
                    else
                    {
                        availAct = totalCount - activatedUsers;
                    }
                }

                level.id                   = userLevelValue.id;
                level.name                 = userLevelValue.name;
                level.totalactivations     = totalCount;
                level.availableactivations = userLevelValue.id == 0
                    ? 1
                    : availAct;

                levels.Add(level);
            }
        }
 /// <summary>
 /// Marks the method as being the whisper handler for a <c>!botname command subcommand</c>.
 /// </summary>
 /// <param name="command">The command to detect.</param>
 /// <param name="subcommand">The subcommand to detect.</param>
 /// <param name="permission">The default permission required to use the subcommand.</param>
 public BotnameWhisperCommandAttribute(string command, string subcommand, UserLevels permission) : base(command, subcommand, permission)
 {
 }
Exemple #28
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.SetFields(email,salt, passwordVerifier, userLevel);
 }
        private async void CustomCommand_OnEditCommand(object sender, OnChatCommandReceivedArgs e)
        {
            if (!await Permission.Can(e.Command, false, 2).ConfigureAwait(false))
            {
                return;
            }

            Match commandMatch = this._commandAddEditRegex.Match(e.Command.ArgumentsAsString);

            if (commandMatch.Success)
            {
                string command = commandMatch.Groups["command"].Value.ToLowerInvariant();

                if (await PluginManager.DoesCustomChatCommandExistAsync(e.Command.ChatMessage.RoomId, command).ConfigureAwait(false))
                {
                    UserLevels userLevel = GetUserLevelFromTag(commandMatch.Groups["userlevel"].Value);
                    string     response  = commandMatch.Groups["response"].Value;

                    IMongoCollection <CommandDocument> collection = DatabaseClient.Instance.MongoDatabase.GetCollection <CommandDocument>(CommandDocument.CollectionName);

                    // Update the document.
                    UpdateDefinition <CommandDocument> update = Builders <CommandDocument> .Update.Set(c => c.Response, response);

                    FilterDefinition <CommandDocument> filter = Builders <CommandDocument> .Filter.Where(c => c.ChannelId == e.Command.ChatMessage.RoomId && !c.IsWhisperCommand && c.Command == command);

                    // Update permission if the user specified it.
                    if (!string.IsNullOrEmpty(commandMatch.Groups["userlevel"].Value))
                    {
                        _ = update.Set(c => c.UserLevel, userLevel);
                    }

                    _ = await collection.UpdateOneAsync(filter, update).ConfigureAwait(false);

                    // Command modified.
                    TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                         await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "ModifySuccess", e.Command.ChatMessage.RoomId,
                                                                                                   new
                    {
                        CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                        Command       = command,
                        Response      = response,
                        User          = e.Command.ChatMessage.Username,
                        Sender        = e.Command.ChatMessage.Username,
                        e.Command.ChatMessage.DisplayName
                    },
                                                                                                   "@{DisplayName}, the command {CommandPrefix}{Command} has been modified with the response: {Response}").ConfigureAwait(false));
                }
                else
                {
                    // Command does not exist.
                    TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                         await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "ModifyNotExists", e.Command.ChatMessage.RoomId,
                                                                                                   new
                    {
                        CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                        Command       = command,
                        User          = e.Command.ChatMessage.Username,
                        Sender        = e.Command.ChatMessage.Username,
                        e.Command.ChatMessage.DisplayName
                    },
                                                                                                   "@{DisplayName}, the command {CommandPrefix}{Command} cannot be modified as it doesn't exist.").ConfigureAwait(false));
                }
            }
            else
            {
                // Wrong syntax.
                TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                     await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "ModifyUsage", e.Command.ChatMessage.RoomId,
                                                                                               new
                {
                    CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                    User          = e.Command.ChatMessage.Username,
                    Sender        = e.Command.ChatMessage.Username,
                    e.Command.ChatMessage.DisplayName
                },
                                                                                               "@{DisplayName}, Modifies a command. Usage: {CommandPrefix}command modify {CommandPrefix}[command] [permission (optional)] [response]").ConfigureAwait(false));
            }
        }
Exemple #30
0
        private void SetFields(string email, byte[] salt, byte[] passwordVerifier, UserLevels userLevel)
        {
            this.Email = email;
            this.Salt = salt;
            this.PasswordVerifier = passwordVerifier;
            this.UserLevel = userLevel;

            this.BnetAccountID = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.AccountId).SetLow(this.PersistentID).Build();
            this.BnetGameAccountID = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(this.PersistentID).Build();
            this.BannerConfiguration = D3.Account.BannerConfiguration.CreateBuilder()
                .SetBackgroundColorIndex(20)
                .SetBannerIndex(8)
                .SetPattern(4)
                .SetPatternColorIndex(11)
                .SetPlacementIndex(11)
                .SetSigilAccent(4)
                .SetSigilMain(3)
                .SetSigilColorIndex(7)
                .SetUseSigilVariant(true)
                .Build();
        }
Exemple #31
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
 }
Exemple #32
0
        private bool CheckLogin()
        {
            if (string.IsNullOrEmpty(txtLoginCode.Text))
            {
                return(false);
            }

            UserLevels level_before = Program.UserLevel;

            Program.UserLevel = UserLevels.USER;

            string sm = string.Empty;
            string ms = string.Empty;

            sm = string.Format("{0:00}", DateTime.Now.Hour) + string.Format("{0:00}", DateTime.Now.Minute);
            ms = string.Format("{0:00}", DateTime.Now.Minute) + string.Format("{0:00}", DateTime.Now.Hour);

            RackUser user = null;

            if (Program.user_scan_code != "")
            {
                user = RackUser.GetUserByCode(Program.user_scan_code);
            }
            else
            {
                user = RackUser.GetUserByCode(txtLoginCode.Text);
            }
            if (user != null && user.Active != 0)
            {
                //SqlFunctions.EventLog(user.FullName, "login as " + user.FullName);

                Program.UserLevel = (UserLevels)user.UserLevel;
                Program.UserName  = user.FullName;
            }

            if (txtLoginCode.Text == "1" + sm)
            {
                //SqlFunctions.EventLog("Service", "login as service");

                Program.UserLevel = UserLevels.SERVICE;
                Program.UserName  = "";
            }

            if (txtLoginCode.Text == "5" + ms)
            {
                // SqlFunctions.EventLog("Owner", "login as owner");

                Program.UserLevel = UserLevels.OWNER;
                Program.UserName  = "";
            }

            if (Program.UserLevel > UserLevels.USER)
            {
                if (level_before != Program.UserLevel)
                {
                    BauerLib.Speaker.Beep(BauerLib.Speaker.Tones.MB_OK);
                }
                return(true);
            }

            // BauerLib.Speaker.Beep(BauerLib.Speaker.Tones.MB_ICONEXCLAMATION);
            return(false);
        }
Exemple #33
0
 public Account(ulong persistentId, string email, byte[] salt, byte[] passwordVerifier, string battleTagName, int hashCode, UserLevels userLevel) // Account with given persistent ID
     : base(persistentId)
 {
     this.LastSelectedHeroField.Value = Account.AccountHasNoToons;
     LoadGameAccountIds();
     this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
 }
Exemple #34
0
        public Account(string email, string password, string battleTagName, int hashCode, UserLevels userLevel) // Account with **newly generated** persistent ID
            : base(StringHashHelper.HashIdentity(battleTagName + "#" + hashCode.ToString("D4")))
        {
            this.LastSelectedHeroField.Value = Account.AccountHasNoToons;
            LoadGameAccountIds();

            if (password.Length > 16)
            {
                password = password.Substring(0, 16);                       // make sure the password does not exceed 16 chars.
            }
            var salt             = SRP6a.GetRandomBytes(32);
            var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt);

            this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
        }
Exemple #35
0
        public Account(string email, string password, string battleTagName, int hashCode, UserLevels userLevel) // Account with **newly generated** persistent ID
            : base(StringHashHelper.HashIdentity(battleTagName + "#" + hashCode.ToString("D4")))
        {
            this.LastSelectedHeroField.Value = Account.AccountHasNoToons;
            LoadGameAccountIds();

            if (password.Length > 16) password = password.Substring(0, 16); // make sure the password does not exceed 16 chars.

            var salt = SRP6a.GetRandomBytes(32);
            var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt);

            this.SetFields(email, salt, passwordVerifier, battleTagName, hashCode, userLevel);
        }
        private async void CustomCommand_OnAddCommand(object sender, OnChatCommandReceivedArgs e)
        {
            if (!await Permission.Can(e.Command, false, 2).ConfigureAwait(false))
            {
                return;
            }

            Match commandMatch = this._commandAddEditRegex.Match(e.Command.ArgumentsAsString);

            if (commandMatch.Success)
            {
                string command = commandMatch.Groups["command"].Value.ToLowerInvariant();

                if (!await PluginManager.DoesCustomChatCommandExistAsync(e.Command.ChatMessage.RoomId, command).ConfigureAwait(false))
                {
                    UserLevels userLevel = GetUserLevelFromTag(commandMatch.Groups["userlevel"].Value);
                    string     response  = commandMatch.Groups["response"].Value;

                    // TODO: Register the custom role

                    IMongoCollection <CommandDocument> collection = DatabaseClient.Instance.MongoDatabase.GetCollection <CommandDocument>(CommandDocument.CollectionName);

                    CommandDocument commandDocument = new CommandDocument
                    {
                        ChannelId = e.Command.ChatMessage.RoomId,
                        Command   = command,
                        Response  = response,
                        UserLevel = userLevel
                    };

                    await collection.InsertOneAsync(commandDocument).ConfigureAwait(false);

                    // Command added.
                    TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                         await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "AddSuccess", e.Command.ChatMessage.RoomId,
                                                                                                   new
                    {
                        CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                        Command       = command,
                        Response      = response,
                        User          = e.Command.ChatMessage.Username,
                        Sender        = e.Command.ChatMessage.Username,
                        e.Command.ChatMessage.DisplayName
                    },
                                                                                                   "@{DisplayName}, the command {CommandPrefix}{Command} has been added with the response: {Response}").ConfigureAwait(false));
                }
                else
                {
                    // Command exists.
                    TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                         await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "AddAlreadyExists", e.Command.ChatMessage.RoomId,
                                                                                                   new
                    {
                        CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                        Command       = command,
                        User          = e.Command.ChatMessage.Username,
                        Sender        = e.Command.ChatMessage.Username,
                        e.Command.ChatMessage.DisplayName
                    },
                                                                                                   "@{DisplayName}, the command {CommandPrefix}{Command} cannot be added as it already exists.").ConfigureAwait(false));
                }
            }
            else
            {
                // Wrong syntax.
                TwitchLibClient.Instance.SendMessage(e.Command.ChatMessage.Channel,
                                                     await I18n.Instance.GetAndFormatWithAsync("CustomCommand", "AddUsage", e.Command.ChatMessage.RoomId,
                                                                                               new
                {
                    CommandPrefix = PluginManager.Instance.ChatCommandIdentifier,
                    User          = e.Command.ChatMessage.Username,
                    Sender        = e.Command.ChatMessage.Username,
                    e.Command.ChatMessage.DisplayName
                },
                                                                                               "@{DisplayName}, Adds a custom command. Usage: {CommandPrefix}command add {CommandPrefix}[command] [permission (optional)] [response]").ConfigureAwait(false));
            }
        }
Exemple #37
0
        private void SetFields(string email, byte[] salt, byte[] passwordVerifier, UserLevels userLevel)
        {
            this.Email = email;
            this.Salt = salt;
            this.PasswordVerifier = passwordVerifier;
            this.UserLevel = userLevel;

            this.BnetAccountID = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.AccountId).SetLow(this.PersistentID).Build();
            this.BnetGameAccountID = bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(this.PersistentID).Build();
            this.BannerConfiguration = D3.Account.BannerConfiguration.CreateBuilder()
                .SetBannerShape(2952440006)
                .SetSigilMain(976722430)
                .SetSigilAccent(803826460)
                .SetPatternColor(1797588777)
                .SetBackgroundColor(1379006192)
                .SetSigilColor(1797588777)
                .SetSigilPlacement(3057352154)
                .SetPattern(4173846786)
                .SetUseSigilVariant(true)
                .SetEpicBanner(0)
                .Build();

            this.Achievements = new List<bnet.protocol.achievements.AchievementUpdateRecord>();
            this.AchievementCriteria = new List<bnet.protocol.achievements.CriteriaUpdateRecord>();
        }