public void IsNeverExpired() { var info = new BanInfo ("192.168.1.*", null, TimeSpan.Zero); Assert.IsFalse (info.IsExpired); info.Created = new DateTime (1990, 1, 1); Assert.IsFalse (info.IsExpired); }
public static BanInfo Parse(IrcMessageData data) { BanInfo info = new BanInfo(); // :magnet.oftc.net 367 meebey #smuxi test!test@test [email protected] 1216309801.. info.f_Channel = data.RawMessageArray[3]; info.f_Mask= data.RawMessageArray[4]; return info; }
public override void Execute(Player player) { if (player != null && !player.Privileges.HasPrivilege("ban")) { WriteLine(player, "You have no ban privileges"); return; } Player target = Player.Find(Target); if (target == null) { WriteLine(player, "Couldn't find target player"); return; } if (target.Privileges.HasPrivilege("immunity")) { WriteLine(player, "Target has general immunity"); return; } if (target.Privileges.HasPrivilege("noban")) { WriteLine(player, "Target has ban immunity"); return; } TimeSpan duration; if (!TryParseDuration(out duration)) { WriteLine(player, "Duration was misformed"); } BanInfo bi = new BanInfo(player, target, duration, Reason); int userid = Player.GetUserID(player); Task.Factory.StartNew(() => { SharpMod.Database.AddBan(bi, (Exception exception, bool success) => { if (success) { OnSuccess(userid); } else { OnFailure(userid, exception); } }); }); }
private void Attach() { if (this.descriptor != null) { if (this.descriptor is INotifyPropertyChanged) { (this.descriptor as INotifyPropertyChanged).PropertyChanged += Descriptor_PropertyChanged; } this.BanInfo = this.descriptor.BanInfo; } this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
private void bansToolStripMenuItem_Click(object sender, EventArgs e) { BanInfo baninfo = GetTable <BanInfo>(Table.Bans); dataGridView1.DataSource = baninfo.bans.Select(b => new { b.name, b.ip, b.reason }).ToList(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { /*for (int j = 0; j < dataGridView1.ColumnCount; j++) * { * dataGridView1.Rows[i].Cells[j].ReadOnly = false; * }*/ } }
public void Ctor() { var info = new BanInfo ("192.168.1.*", null, TimeSpan.Zero); Assert.AreEqual ("192.168.1.*", info.IPMask); Assert.AreEqual (null, info.Username); Assert.AreEqual (DateTime.Today, info.Created.Date); Assert.AreEqual (TimeSpan.Zero, info.Length); info = new BanInfo (null, "monkeys", TimeSpan.FromHours (1.1)); Assert.AreEqual (null, info.IPMask); Assert.AreEqual ("monkeys", info.Username); Assert.AreEqual (DateTime.Today, info.Created.Date); Assert.AreEqual (TimeSpan.FromHours (1.1), info.Length); }
public void Ctor() { var info = new BanInfo("192.168.1.*", null, TimeSpan.Zero); Assert.AreEqual("192.168.1.*", info.IPMask); Assert.AreEqual(null, info.Username); Assert.AreEqual(DateTime.Today, info.Created.Date); Assert.AreEqual(TimeSpan.Zero, info.Length); info = new BanInfo(null, "monkeys", TimeSpan.FromHours(1.1)); Assert.AreEqual(null, info.IPMask); Assert.AreEqual("monkeys", info.Username); Assert.AreEqual(DateTime.Today, info.Created.Date); Assert.AreEqual(TimeSpan.FromHours(1.1), info.Length); }
private static string FormatUserID(string userID, BanInfo banInfo, UserState userState) { if (banInfo.Path != string.Empty) { return(TerminalStrings.Foreground(userID, TerminalColor.Red)); } else if (userState != UserState.Online) { return(TerminalStrings.Foreground(userID, TerminalColor.BrightBlack)); } else { return(userID); } }
public bool RequestBanInfo(SteamID steamID, out BanInfo banInfo) { if (steamID != null && !string.IsNullOrEmpty(_keyManager.SWAKey)) { try { using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", _keyManager.SWAKey)) { KeyValue pair = steamUser.GetPlayerBans(steamids: steamID.ConvertToUInt64()); foreach (var get in pair["players"].Children) { if (get["SteamId"].AsUnsignedLong() == steamID.ConvertToUInt64()) { banInfo = new BanInfo { SteamID = get["SteamId"].AsUnsignedLong(), CommunityBanned = get["CommunityBanned"].AsBoolean(), VacBanned = get["VACBanned"].AsBoolean(), VacBanCount = get["NumberOfVACBans"].AsInteger(), DaysSinceLastBan = get["DaysSinceLastBan"].AsInteger(), GameBanCount = get["NumberOfGameBans"].AsInteger(), EconomyBan = get["EconomyBan"].AsString() }; return(true); } } } } catch (WebException ex) { Log.Error(ex, "A error occured when trying to get the Ban Information for {SteamID}.", steamID.ConvertToUInt64()); } Log.Warning("Did not receive ban informations for {SteamID}. Skipping...", steamID.ConvertToUInt64()); banInfo = null; return(false); } Log.Warning("No valid Web API key has been found. Skipping ban checking..."); banInfo = null; return(false); }
public UserDescriptor(Authentication authentication, IUser user, DescriptorTypes descriptorTypes, object owner) : base(authentication, user, descriptorTypes) { this.user = user; this.Owner = owner ?? this; this.user.Dispatcher.VerifyAccess(); this.userInfo = this.user.UserInfo; this.UserState = this.user.UserState; this.banInfo = this.user.BanInfo; if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true) { this.user.Deleted += User_Deleted; this.user.UserInfoChanged += User_UserInfoChanged; this.user.UserStateChanged += User_UserStateChanged; this.user.UserBanInfoChanged += User_UserBanInfoChanged; } }
public void AddBan(BanInfo ban) { if (ban == null) { throw new ArgumentNullException("ban"); } using (var session = Persistance.SessionFactory.OpenSession()) { session.SaveOrUpdate(new LocalBanInfo { Created = DateTime.Now, IPMask = ban.IPMask, Length = ban.Length, Username = ban.Username }); } }
private static void ResolvedBans(BanInfo information) { if (information == null) { return; } Player target = Player.FindByUserId(information.Player.UserId); if (target == null) { return; } if (!target.Privileges.HasPrivilege("noban")) { target.Kick(information.Reason); } }
public static async Task UserBanned(SocketUser user, SocketGuild guild) { Console.WriteLine("ReceivedBanEvent"); if ((await guild.GetBanAsync(user.Id)).Reason.Contains(DiscordBot.client.CurrentUser.Id.ToString()) == false) { BanInfo banInfo = new BanInfo() { Source = "Ban Event", Reason = (await guild.GetBanAsync(user.Id)).Reason, UserId = user.Id, Username = user.Username, UserDiscriminator = user.Discriminator, UserNickname = guild.GetUser(user.Id).Nickname, UserCreationDate = user.CreatedAt, JoinDate = guild.GetUser(user.Id).JoinedAt }; await DiscordBot.SendBanMessage(banInfo); } }
public void RemoveBan(BanInfo ban) { if (ban == null) { throw new ArgumentNullException("ban"); } using (var session = Persistance.SessionFactory.OpenSession()) { LocalBanInfo localBan = (ban as LocalBanInfo) ?? session.Query <LocalBanInfo>().FirstOrDefault(b => b.Username == ban.Username || b.IPMask == ban.IPMask); if (localBan == null) { return; } session.Delete(localBan); } }
public void BanUser() { var admin = JoinAsGuest(server, client, "admin"); permissions.EnablePermissions(admin.UserId, PermissionName.BanUser); var ban = new BanInfo(null, "username", TimeSpan.Zero); users.BansChanged += (sender, e) => { Assert.IsTrue(users.GetBans().Contains(ban), "User provider did not contain the new ban."); Assert.Pass(); }; handler.OnBanUserMessage(new MessageEventArgs <BanUserMessage> (server, new BanUserMessage { Removing = false, BanInfo = ban })); Assert.Fail("Ban never reached the user provider"); }
public static async Task SendBanMessage(BanInfo banInfo) { // Creates a new EmbededBuilder to send embeded messages. EmbedBuilder builder = new EmbedBuilder(); // The following if-else statement checks if there was a ban reason given. if (string.IsNullOrEmpty(banInfo.Reason)) { banInfo.Reason = "There was no reason given."; } // Sets the message color to red. builder.WithColor(Color.Red); // Set the title. builder.WithTitle("User banned:"); // Adds the discription. builder.WithDescription("A user was banned."); builder.AddField("General Information:", $"Reason: {banInfo.Reason}.\n" + $"Source: {banInfo.Source}\n"); // Gets the avatar (profile picture) of the banned user. builder.ThumbnailUrl = client.GetUser(banInfo.UserId).GetAvatarUrl(); if (banInfo.StaffId != 0) { builder.AddField("Staff information", $"Username: { banInfo.StaffUsername}#{banInfo.StaffDiscriminator}\n" + $"User Id: {banInfo.StaffId}"); } // The folowing two AddField methods adds aditional information about the user. builder.AddField("User information", $"Username: {banInfo.Username}#{banInfo.UserDiscriminator}\n" + $"User id: {banInfo.UserId}\n" + $"User created at: {banInfo.UserCreationDate}\n" + $"User joined the guild at: {banInfo.JoinDate}"); builder.WithCurrentTimestamp(); // Sends the embeded message to the Discord ban-list channel. await client.GetGuild(mainGuildId).GetTextChannel(logChannelID).SendMessageAsync(null, false, builder.Build()); }
private void UserContext_UsersBanChanged(object sender, ItemsEventArgs <IUser> e) { var userID = this.authentication.ID; var exceptionUserID = e.UserID; var signatureDate = e.SignatureDate; var values = new BanInfo[e.Items.Length]; for (var i = 0; i < e.Items.Length; i++) { var item = e.Items[i]; var lockInfo = item.BanInfo; if (item.BanInfo.Path != item.Path) { lockInfo = BanInfo.Empty; lockInfo.Path = item.Path; } values[i] = lockInfo; } var metaData = e.MetaData as object[]; var changeType = (BanChangeType)metaData[0]; var comments = metaData[1] as string[]; this.InvokeEvent(userID, exceptionUserID, () => this.Callback.OnUsersBanChanged(signatureDate, values, changeType, comments)); }
public void IsExpired() { var info = new BanInfo ("192.168.1.*", null, TimeSpan.FromHours (1)); info.Created = new DateTime (1990, 1, 1); Assert.IsTrue (info.IsExpired); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { Removing = reader.ReadBool(); BanInfo = new BanInfo (context, reader); }
/// <summary> /// Gets the ban information. /// </summary> /// <param name="user">The user.</param> /// <returns>The ban information as a QL color-formatted string.</returns> public BanInfo GetBanInfo(string user) { var bInfo = new BanInfo(); if (VerifyDb()) { if (!DoesUserExistInDb(user.ToLowerInvariant())) { return(null); } try { using (var sqlcon = new SQLiteConnection(_sqlConString)) { sqlcon.Open(); using (var cmd = new SQLiteCommand(sqlcon)) { cmd.CommandText = "SELECT * FROM bannedusers WHERE user = @user"; cmd.Parameters.AddWithValue("@user", user.ToLowerInvariant()); using (var reader = cmd.ExecuteReader()) { if (!reader.HasRows) { Log.Write(string.Format("GetBanInfo: Player {0} does not exist in ban database.", user), _logClassType, _logPrefix); return(null); } while (reader.Read()) { bInfo.PlayerName = user; bInfo.BannedBy = (string)reader["bannedBy"]; bInfo.BanAddedDate = (DateTime)reader["banAddDate"]; bInfo.BanExpirationDate = (DateTime)reader["banExpirationDate"]; switch ((long)reader["banType"]) { case (long)BanType.AddedByAdmin: bInfo.BanType = BanType.AddedByAdmin; break; case (long)BanType.AddedByEarlyQuit: bInfo.BanType = BanType.AddedByEarlyQuit; break; } Log.Write(string.Format( "Got ban info for player: {0} - added by: {1}, added on: {2}, expires: {3}, type: {4}", user, bInfo.BannedBy, bInfo.BanAddedDate.ToString("G", DateTimeFormatInfo.InvariantInfo), bInfo.BanExpirationDate.ToString("G", DateTimeFormatInfo.InvariantInfo), bInfo.BanType), _logClassType, _logPrefix); } } } } } catch (Exception ex) { Log.WriteCritical( string.Format("Problem getting ban info for player {0} from ban database: {1}", user, ex.Message), _logClassType, _logPrefix); bInfo = null; } } return(bInfo); }
public void BanUserRemove() { var admin = JoinAsGuest (server, client, "admin"); permissions.EnablePermissions (admin.UserId, PermissionName.BanUser); var ban = new BanInfo (null, "username", TimeSpan.Zero); users.AddBan (ban); Assert.IsTrue (users.GetBans().Contains (ban), "User provider did not contain the new ban."); users.BansChanged += (sender, e) => { Assert.IsFalse (users.GetBans().Contains (ban), "User provider still contained the ban."); Assert.Pass(); }; handler.OnBanUserMessage (new MessageEventArgs<BanUserMessage> (server, new BanUserMessage { Removing = true, BanInfo = ban })); Assert.Fail ("Ban never reached the user provider"); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { Removing = reader.ReadBool(); BanInfo = new BanInfo(context, reader); }
public void IsNotExpired() { var info = new BanInfo ("192.168.1.*", null, TimeSpan.FromDays (30)); info.Created = DateTime.Today.Subtract (TimeSpan.FromDays (28)); Assert.IsFalse (info.IsExpired); }
public async Task BanGuildMember(string user, [Remainder] string reason = null) { if (string.IsNullOrEmpty(reason)) { reason = "There was no reason given."; } IGuildUser bannedUser; if (GeneralFunctions.CheckUlong(user) == true && DiscordBot.CheckIsInGuild(Context.Guild.Id, Convert.ToUInt64(user))) { bannedUser = await Context.Guild.GetUserAsync(Convert.ToUInt64(user)); } else if (GeneralFunctions.CheckUlong(user) == false && Context.Message.MentionedUserIds.Count >= 1 && DiscordBot.CheckIsInGuild(Context.Guild.Id, Context.Message.MentionedUserIds.First())) { bannedUser = await Context.Guild.GetUserAsync(Context.Message.MentionedUserIds.First()); } else if ((GeneralFunctions.CheckUlong(user) == true && DiscordBot.CheckIsInGuild(Context.Guild.Id, Convert.ToUInt64(user)) == false) || (GeneralFunctions.CheckUlong(user) == false && Context.Message.MentionedUserIds.Count >= 1 && DiscordBot.CheckIsInGuild(Context.Guild.Id, Context.Message.MentionedUserIds.First()) == false)) { await ReplyAsync("Error 0x2: This user was not found in this server."); return; } else if (GeneralFunctions.CheckUlong(user) == false || (GeneralFunctions.CheckUlong(user) == false && Context.Message.MentionedUserIds.Count == 0)) { await ReplyAsync("Error 0x3: There was not a valid id or mention found."); return; } else { await ReplyAsync("Error 0x4: An error occured during command execution please check your input"); return; } #region comment //Continue if: //1. The user is in the guild. //2. The user id is valid or if the mention is valid. //Errors: //Error 1: invalid mention or id //Error 2: User not found //Error 3: Given too many users //Error 4: Unknown Error #endregion BanInfo bannedUserInfo = new BanInfo { UserId = bannedUser.Id, Username = bannedUser.Username, UserDiscriminator = bannedUser.Discriminator, UserNickname = bannedUser.Nickname, UserCreationDate = bannedUser.CreatedAt, JoinDate = bannedUser.JoinedAt, StaffId = Context.Message.Author.Id, StaffUsername = Context.Message.Author.Username, StaffDiscriminator = Context.Message.Author.Discriminator, Source = "Ban Command", Reason = reason }; await Context.Guild.AddBanAsync(bannedUser, 0, DiscordBot.client.CurrentUser.Id.ToString() + " - " + reason); if (await DiscordBot.CheckIfBanned(Context.Guild.Id, bannedUserInfo.UserId) == true) { await ReplyAsync("The user was banned."); await DiscordBot.SendBanMessage(bannedUserInfo); } else { await ReplyAsync("Error 0x5: User was not banned for an unknown reason."); } }
public void RemoveBan(BanInfo ban) { if (ban == null) throw new ArgumentNullException ("ban"); lock (this.bans) this.bans.Remove (ban); OnBansChanged(); }
public void LoadLowData() { { TextAsset data = Resources.Load("TestJson/Local_RandomName", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject RandomName = new JSONObject(strSrc); for (int i = 0; i < RandomName.list.Count; i++) { RandomNameInfo tmpInfo = new RandomNameInfo(); tmpInfo.Index = (uint)RandomName[i]["Index_ui"].n; tmpInfo.Name1 = RandomName[i]["Name1_c"].str; tmpInfo.Name2 = RandomName[i]["Name2_c"].str; tmpInfo.Name3 = RandomName[i]["Name3_c"].str; RandomNameInfoDic.Add(tmpInfo.Index, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StageData", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StageData = new JSONObject(strSrc); for (int i = 0; i < StageData.list.Count; i++) { StageDataInfo tmpInfo = new StageDataInfo(); tmpInfo.StringId = (uint)StageData[i]["StringId_ui"].n; tmpInfo.String = StageData[i]["String_c"].str; string kr_c = StageData[i]["String_c"].str; if (kr_c.Contains("\\\\n")) { kr_c = kr_c.Replace("\\\\n", "\n"); } else if (kr_c.Contains("\\n")) { kr_c = kr_c.Replace("\\n", "\n"); } tmpInfo.String = kr_c; StageDataInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringBuff", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringBuff = new JSONObject(strSrc); for (int i = 0; i < StringBuff.list.Count; i++) { StringBuffInfo tmpInfo = new StringBuffInfo(); tmpInfo.StringId = (uint)StringBuff[i]["StringId_ui"].n; tmpInfo.String = StringBuff[i]["String_c"].str; StringBuffInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringCommon", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringCommon = new JSONObject(strSrc); for (int i = 0; i < StringCommon.list.Count; i++) { StringCommonInfo tmpInfo = new StringCommonInfo(); tmpInfo.StringId = (uint)StringCommon[i]["StringId_ui"].n; /// 스트링에 엔터값이 잘못 들어간다 제거해준다 string kr_c = StringCommon[i]["String_c"].str; if (kr_c.Contains("\\\\n")) { kr_c = kr_c.Replace("\\\\n", "\n"); } else if (kr_c.Contains("\\n")) { kr_c = kr_c.Replace("\\n", "\n"); } tmpInfo.String = kr_c; //// //tmpInfo.String = StringCommon[i]["String_c"].str; StringCommonInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringItem", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringItem = new JSONObject(strSrc); for (int i = 0; i < StringItem.list.Count; i++) { StringItemInfo tmpInfo = new StringItemInfo(); tmpInfo.StringId = (uint)StringItem[i]["StringId_ui"].n; tmpInfo.String = StringItem[i]["String_c"].str; StringItemInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringSkill", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringSkill = new JSONObject(strSrc); for (int i = 0; i < StringSkill.list.Count; i++) { StringSkillInfo tmpInfo = new StringSkillInfo(); tmpInfo.StringId = (uint)StringSkill[i]["StringId_ui"].n; tmpInfo.String = StringSkill[i]["String_c"].str; StringSkillInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringUnit", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringUnit = new JSONObject(strSrc); for (int i = 0; i < StringUnit.list.Count; i++) { StringUnitInfo tmpInfo = new StringUnitInfo(); tmpInfo.StringId = (uint)StringUnit[i]["StringId_ui"].n; //tmpInfo.String = StringUnit[i]["String_c"].str; /// 스트링에 엔터값이 잘못 들어간다 제거해준다 string kr_c = StringUnit[i]["String_c"].str; if (kr_c.Contains("\\\\n")) { kr_c = kr_c.Replace("\\\\n", "\n"); } else if (kr_c.Contains("\\n")) { kr_c = kr_c.Replace("\\n", "\n"); } tmpInfo.String = kr_c; StringUnitInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringTitle", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringTitle = new JSONObject(strSrc); for (int i = 0; i < StringTitle.list.Count; i++) { StringTitleInfo tmpInfo = new StringTitleInfo(); tmpInfo.StringId = (uint)StringTitle[i]["StringId_ui"].n; tmpInfo.String = StringTitle[i]["String_c"].str; StringTitleInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_StringAchievement", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringAchievement = new JSONObject(strSrc); for (int i = 0; i < StringAchievement.list.Count; i++) { StringAchievementInfo tmpInfo = new StringAchievementInfo(); tmpInfo.StringId = (uint)StringAchievement[i]["StringId_ui"].n; tmpInfo.String = StringAchievement[i]["String_c"].str; StringAchievementInfoDic.Add(tmpInfo.StringId, tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_ErrorPopup", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject ErrorPopup = new JSONObject(strSrc); for (int i = 0; i < ErrorPopup.list.Count; i++) { ErrorPopupInfo tmpInfo = new ErrorPopupInfo(); tmpInfo.Index = (uint)ErrorPopup[i]["Index_ui"].n; string str = ErrorPopup[i]["Description_c"].str; if (str.Contains("\\\\n")) { str = str.Replace("\\\\n", "\n"); } else if (str.Contains("\\n")) { str = str.Replace("\\n", "\n"); } tmpInfo.Description = str; if (!ErrorPopupInfoDic.ContainsKey(tmpInfo.Index)) { ErrorPopupInfoDic.Add(tmpInfo.Index, tmpInfo); } else { Debug.LogError("already added index " + tmpInfo.Index); } } } { TextAsset data = Resources.Load("TestJson/Local_Ban", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Ban = new JSONObject(strSrc); for (int i = 0; i < Ban.list.Count; i++) { BanInfo tmpInfo = new BanInfo(); tmpInfo.ID = (uint)Ban[i]["ID_ui"].n; tmpInfo.word = Ban[i]["word_c"].str; BanInfoList.Add(tmpInfo); } } { TextAsset data = Resources.Load("TestJson/Local_Dialog", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject StringCommon = new JSONObject(strSrc); for (int i = 0; i < StringCommon.list.Count; i++) { StringLocalDialogInfo tmpInfo = new StringLocalDialogInfo(); tmpInfo.StringId = (uint)StringCommon[i]["StringId_ui"].n; tmpInfo.NPCNameLEFT = StringCommon[i]["NPCNameLEFT_c"].str; tmpInfo.NPCNameRIGHT = StringCommon[i]["NPCNameRIGHT_c"].str; tmpInfo.TalkPosition = (byte)StringCommon[i]["TalkPosition_b"].n; tmpInfo.String = StringCommon[i]["String_c"].str; //Debug.Log(" string :"+tmpInfo.String+", TalkPosition:"+tmpInfo.TalkPosition); StringLocalDialogInfoDic.Add(tmpInfo.StringId, tmpInfo); } } }
public void RemoveBan(BanInfo ban) { if (ban == null) throw new ArgumentNullException ("ban"); using (var session = Persistance.SessionFactory.OpenSession()) { LocalBanInfo localBan = (ban as LocalBanInfo) ?? session.Query<LocalBanInfo>().FirstOrDefault (b => b.Username == ban.Username || b.IPMask == ban.IPMask); if (localBan == null) return; session.Delete (localBan); } }
private async void User_UserBanInfoChanged(object sender, EventArgs e) { this.banInfo = this.user.BanInfo; await this.RefreshAsync(); }
public void AddBan(BanInfo ban) { if (ban == null) throw new ArgumentNullException ("ban"); using (var session = Persistance.SessionFactory.OpenSession()) { session.SaveOrUpdate (new LocalBanInfo { Created = DateTime.Now, IPMask = ban.IPMask, Length = ban.Length, Username = ban.Username }); } }
public void InvokeUserBan(Authentication authentication, User user, BanInfo banInfo) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeUserBan), user, banInfo.Comment); }
public void AddBan(BanInfo bi, Action <Exception, bool> callback) { callback(null, false); }