コード例 #1
0
        public void ComBan(TasSayEventArgs e, string[] words)
        {
            if (words.Length == 0)
            {
                ah.Respond(e, "this command needs at least 1 argument - exact user name");
                return;
            }

            int duration = 0;

            if (words.Length > 1)
            {
                if (!int.TryParse(words[1], out duration))
                {
                    ah.Respond(e, "second argument must be a number - ban time in minutes or 0 - forever");
                    return;
                }
            }

            if (IsBanned(words[0]))
            {
                ah.Respond(e, "this user is already banned");
                return;
            }

            if (duration < 0)
            {
                duration = 0;
            }
            TimeSpan dur;

            if (duration == 0)
            {
                dur = TimeSpan.FromDays(365 * 1000);
            }
            else
            {
                dur = TimeSpan.FromMinutes(duration);
            }

            var b = new BannedUser(words[0]);

            b.Duration = dur;
            b.Reason   = Utils.Glue(words, 2);

            var battle = tas.GetBattle();
            UserBattleStatus ubs;

            if (battle.ContainsUser(b.Name, out ubs))
            {
                if (ubs.ip != IPAddress.None)
                {
                    b.ipAddresses.Add(ubs.ip.ToString());
                }
            }
            Items.Add(b);
            tas.Say(TasClient.SayPlace.Battle, "", b.Name + " banned - " + b.Reason, true);
            tas.Kick(b.Name);
            Save();
        }
コード例 #2
0
 public bool GetByNameOrIp(string name, string ip, out BannedUser b)
 {
   b = Items.Find(delegate(BannedUser bu) { return bu.nickNames.Contains(name) || bu.ipAddresses.Contains(ip); });
   if (b != null) {
     if (b.Expired) {
       Items.Remove(b);
       b = null;
       return false;
     } else return true;
   } else return false;
 }
コード例 #3
0
 public bool GetByName(string name, out BannedUser b)
 {
   b = Items.Find(delegate(BannedUser u) { return u.nickNames.Contains(name); });
   if (b != null) {
     if (b.Expired) {
       Items.Remove(b);
       b = null;
       return false;
     } else return true;
   } else return false;
 }
コード例 #4
0
 public bool IsBanned(string name, out BannedUser b)
 {
   Battle bat = tas.GetBattle();
   if (GetByName(name, out b)) return true;
   if (bat != null) {
     UserBattleStatus ubs;
     if (bat.ContainsUser(name, out ubs)) {
       string ip = ubs.ip.ToString();
       if (GetByIp(ip, out b)) return true;
     }
   }
   return false;
 }
コード例 #5
0
 public bool GetByNameOrIp(string name, string ip, out BannedUser b)
 {
     b = Items.Find(delegate(BannedUser bu) { return(bu.nickNames.Contains(name) || bu.ipAddresses.Contains(ip)); });
     if (b != null)
     {
         if (b.Expired)
         {
             Items.Remove(b);
             b = null;
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #6
0
 public bool GetByName(string name, out BannedUser b)
 {
     b = Items.Find(delegate(BannedUser u) { return(u.nickNames.Contains(name)); });
     if (b != null)
     {
         if (b.Expired)
         {
             Items.Remove(b);
             b = null;
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #7
0
        public bool IsBanned(string name, out BannedUser b)
        {
            var bat = tas.GetBattle();

            if (GetByName(name, out b))
            {
                return(true);
            }
            if (bat != null)
            {
                UserBattleStatus ubs;
                if (bat.ContainsUser(name, out ubs))
                {
                    string ip = ubs.ip.ToString();
                    if (GetByIp(ip, out b))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #8
0
		public void ComBan(TasSayEventArgs e, string[] words)
		{
			if (words.Length == 0) {
				ah.Respond(e, "this command needs at least 1 argument - exact user name");
				return;
			}

			int duration = 0;
			if (words.Length > 1) {
				if (!int.TryParse(words[1], out duration)) {
					ah.Respond(e, "second argument must be a number - ban time in minutes or 0 - forever");
					return;
				}
			}

			if (IsBanned(words[0])) {
				ah.Respond(e, "this user is already banned");
				return;
			}

			if (duration < 0) duration = 0;
			TimeSpan dur;
			if (duration == 0) dur = TimeSpan.FromDays(365*1000);
			else dur = TimeSpan.FromMinutes(duration);

			var b = new BannedUser(words[0]);
			b.Duration = dur;
			b.Reason = Utils.Glue(words, 2);

			var battle = tas.GetBattle();
			UserBattleStatus ubs;
			if (battle.ContainsUser(b.Name, out ubs)) if (ubs.ip != IPAddress.None) b.ipAddresses.Add(ubs.ip.ToString());
			Items.Add(b);
			tas.Say(TasClient.SayPlace.Battle, "", b.Name + " banned - " + b.Reason, true);
			tas.Kick(b.Name);
			Save();
		}