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(); }
void tas_BattleUserIpRecieved(object sender, TasEventArgs e) { UpdateWithUserIp(e.ServerParams[0], IPAddress.Parse(e.ServerParams[1])); BannedUser b; if (IsBanned(e.ServerParams[0], out b)) { tas.Say(TasClient.SayPlace.Battle, "", e.ServerParams[0] + " (" + b.Name + ") is banned for " + b.Reason, true); tas.Kick(e.ServerParams[0]); } }
void tas_BattleUserJoined(object sender, BattleUserEventArgs e1) { if (e1.BattleID != tas.MyBattleID) { return; } string name = e1.UserName; string welc = config.Welcome; if (!string.IsNullOrEmpty(welc)) { welc = welc.Replace("%1", name); welc = welc.Replace("%2", GetUserLevel(name).ToString()); welc = welc.Replace("%3", MainConfig.SpringieVersion); SayBattlePrivate(name, welc); } if (spring.IsRunning) { spring.AddUser(e1.UserName, e1.ScriptPassword); TimeSpan started = DateTime.Now.Subtract(spring.GameStarted); started = new TimeSpan((int)started.TotalHours, started.Minutes, started.Seconds); SayBattlePrivate(name, String.Format("THIS GAME IS CURRENTLY IN PROGRESS, PLEASE WAIT UNTIL IT ENDS! Running for {0}", started)); SayBattlePrivate(name, "If you say !notify, I will message you when the current game ends."); } if (SpawnConfig == null) { try { var serv = GlobalConst.GetSpringieService(); PlayerJoinResult ret = serv.AutohostPlayerJoined(tas.MyBattle.GetContext(), tas.ExistingUsers[name].AccountID); if (ret != null) { if (!string.IsNullOrEmpty(ret.PrivateMessage)) { tas.Say(SayPlace.User, name, ret.PrivateMessage, false); } if (!string.IsNullOrEmpty(ret.PublicMessage)) { tas.Say(SayPlace.Battle, "", ret.PublicMessage, true); } if (ret.ForceSpec) { tas.ForceSpectator(name); } if (ret.Kick) { tas.Kick(name); } } } catch (Exception ex) { SayBattle("ServerManage error: " + ex, false); } } if (SpawnConfig != null && SpawnConfig.Owner == name) // owner joins, set him boss { ComBoss(TasSayEventArgs.Default, new[] { name }); } }
void tas_BattleUserStatusChanged(object sender, TasEventArgs e) { TasClient.UserBattleStatus u; if (tas.GetBattle().ContainsUser(e.ServerParams[0], out u)) { if (u.SyncStatus == TasClient.SyncStatuses.Unsynced) { tas.Say(TasClient.SayPlace.Battle, "", "kicking " + u.name + " - has incorrect spring or mod version", true); tas.Kick(u.name); } } }
protected void KickUnsynced(TasClient tas) { for (int i = 0; i < users.Count; ++i) { UserBattleStatus u; if (tas.IsConnected && tas.GetBattle().ContainsUser(users[i], out u)) { if (u.SyncStatus == SyncStatuses.Unknown && (DateTime.Now - times[i]) > TimeSpan.FromSeconds(timeout)) { tas.Kick(users[i]); } } } }
void tas_BattleUserStatusChanged(object sender, TasEventArgs e) { UserBattleStatus u; Battle b = tas.GetBattle(); if (b != null && b.ContainsUser(e.ServerParams[0], out u)) { if (u.SyncStatus == SyncStatuses.Unsynced) { SayBattle("kicking " + u.name + " - has incorrect spring or mod version"); tas.Kick(u.name); } if (KickSpectators && u.IsSpectator == true && u.name != tas.UserName) { SayBattle(config.KickSpectatorText); ComKick(TasSayEventArgs.Default, new string[] { u.name }); } HandleAutoLocking(); int cnt = 0; foreach (UserBattleStatus ubs in b.Users) { if (!ubs.IsSpectator && ubs.IsReady) { cnt++; } } string usname; int allyno; if ((cnt == config.MaxPlayers || (autoLock > 0 && autoLock == cnt)) && AllReadyAndSynced(out usname) && AllUniqueTeams(out usname) && BalancedTeams(out allyno)) { SayBattle("server is full, starting"); System.Threading.Thread.Sleep(1000); // just to make sure that other clients update their game info and balance ends ComStart(TasSayEventArgs.Default, new string[] { }); } } }