public void CommandQuit(object sender, CommandEventArgs e) { Game game; string key = e.Client.Extensions.NetworkName + "/" + e.Target; if (!this.Games.TryGetValue(key, out game)) { e.Whisper("There's no game going on at the moment."); } else { lock (game.Lock) { int index = game.IndexOf(e.Sender.Nickname); if (index == -1) { e.Whisper("You're not in this game."); } else { Bot.Say(game.Connection, game.Channel, "\u000312\u0002{0}\u0002 has left the game.", e.Sender.Nickname); this.RemovePlayer(game, index); } } } }
public void CommandIdentify(object sender, CommandEventArgs e) { if (e.Target is IrcChannel) // A channel message. Identification should (obviously) be done privately. { e.Whisper(Bot.Choose(Bot.Choose("Hey ", "") + e.Sender.Nickname + ", ", "") + Bot.Choose("I think " + Bot.Choose("that ", "")) + Bot.Choose("you should probably ", "you'll want to ") + Bot.Choose("run ", "use ", "invoke ") + "that command in a PM to me, " + Bot.Choose("not in a channel.", "rather than in a channel."), SayOptions.Capitalise); // TODO: Prompt the user to change their password. } if (!e.Client.Extensions.SupportsMonitor) { // Ensure that the user is on at least one channel with the bot. Otherwise it's a security hole. bool found = false; foreach (IrcChannel _channel in e.Client.Channels) { if (_channel.Users.Contains(e.Sender.Nickname)) { found = true; break; } } if (!found) { e.Whisper(Bot.Choose("You need to ", "You must ") + "be in " + Bot.Choose("at least one ", "a ") + "channel with me to identify yourself" + Bot.Choose(", " + e.Sender.Nickname, "") + "."); return; } } // Identify. string username; string password; Identification id; string message; if (e.Parameters.Length == 1) { username = e.Sender.Nickname; password = e.Parameters[0]; } else { username = e.Parameters[0]; password = e.Parameters[1]; } if (Bot.Identify(e.Sender, username, password, out id, out message)) { if (e.Client.Extensions.SupportsMonitor) { e.Client.MonitorList.Add(e.Sender.Nickname); } } e.Whisper(message); }
public async void CommandCommandInfo(object sender, CommandEventArgs e) { if (!await showCommandInfo(e.Target, e.Sender, e.Parameters[0])) { e.Whisper($"I don't recognise that command. Use {Colours.Bold}{Bot.ReplaceCommands("!cmdlist", e.Target)}{Colours.Bold} for a list of commands."); } }
public void CommandChannels(object sender, CommandEventArgs e) { IrcClient targetClient; string targetNickname; if (e.Parameters.Length == 2) { targetClient = null; foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (client.Address.Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase) || (client.Extensions.NetworkName ?? "").Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase)) { targetClient = client; break; } } if (targetClient == null) { e.Fail(string.Format("I'm not connected to \u0002{0}\u0002.", e.Parameters[0])); return; } targetNickname = e.Parameters[1]; } else { targetClient = e.Client; targetNickname = e.Parameters[0]; } e.Whisper(string.Join(" ", targetClient.Users[targetNickname].Channels.Select(channel => channel.Users[targetNickname].Status.GetPrefixes() + channel.Name))); }
public void CommandRaw(object sender, CommandEventArgs e) { IrcClient targetConnection; string targetAddress; string command; if (e.Parameters.Length == 2) { targetAddress = e.Parameters[0]; command = e.Parameters[1]; } else { targetAddress = null; command = e.Parameters[0]; } if (targetAddress == null || targetAddress == ".") { targetConnection = e.Client; } else { targetConnection = null; foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (client.Address.Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase) || (client.Extensions.NetworkName ?? "").Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase)) { targetConnection = client; break; } } if (targetConnection == null) { e.Reply(string.Format("I'm not connected to \u0002{0}\u0002.", e.Parameters[0])); return; } } if (targetConnection.State == IrcClientState.Disconnected) { e.Reply(string.Format("My connection to \u0002{0}\u0002 is currently down.", targetConnection.Address)); return; } e.Whisper("Acknowledged."); targetConnection.Send(command); }
public void CommandDie(object sender, CommandEventArgs e) { string message; if (e.Parameters.Length == 1) { message = e.Parameters[0]; } else { message = "Shutting down"; } e.Whisper("Goodbye, {0}.", e.Sender.Nickname); foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (client.State >= IrcClientState.Registering) { client.Send("QUIT :{0}", message); } } System.Threading.Thread.Sleep(2000); Environment.Exit(0); }
public async void CommandCommandList(object sender, CommandEventArgs e) { StringBuilder generalBuilder = new StringBuilder("\u0002General commands:\u0002 "); StringBuilder channelBuilder = new StringBuilder(string.Format("\u0002Commands for {0}:\u0002 ", e.Target)); int channelMinLength = channelBuilder.Length; foreach (var pluginEntry in Bot.Plugins) { List <string> commands = new List <string>(16); bool isGeneral = false; bool found = false; foreach (string channel in pluginEntry.Obj.Channels) { string[] fields = channel.Split(new char[] { '/' }, 2); string channelSub; if (fields.Length == 1) { channelSub = fields[0]; } else { if (fields[0] != "*" && !fields[0].Equals(e.Client.Extensions.NetworkName, StringComparison.OrdinalIgnoreCase) && !fields[0].Equals(e.Client.Address, StringComparison.OrdinalIgnoreCase)) { continue; } channelSub = fields[1]; } if (channelSub == "*" || channelSub == "*#") { found = true; isGeneral = true; } else if (e.Client.CaseMappingComparer.Equals(channelSub, e.Target?.Target)) { found = true; } else { continue; } } if (!found) { continue; } foreach (MethodInfo method in pluginEntry.Obj.GetType().GetMethods()) { foreach (CommandAttribute attribute in method.GetCustomAttributes(typeof(CommandAttribute), true)) { // Check the scope. if ((attribute.Scope & CommandScope.PM) == 0 && !(e.Target is IrcChannel)) { continue; } if ((attribute.Scope & CommandScope.Channel) == 0 && e.Target is IrcChannel) { continue; } // Check for permissions. string permission; if (attribute.Permission == null) { permission = null; } else if (attribute.Permission != "" && attribute.Permission.StartsWith(".")) { permission = pluginEntry.Key + attribute.Permission; } else { permission = attribute.Permission; } if (permission != null && !await Bot.CheckPermissionAsync(e.Sender, permission)) { continue; } // Add the command. commands.Add(attribute.Names[0]); } } if (commands.Count != 0) { commands.Sort(); StringBuilder builder = isGeneral ? generalBuilder : channelBuilder; builder.AppendFormat(" \u00034[{0}]\u000F ", pluginEntry.Key); builder.Append(string.Join(" ", commands)); } } if (generalBuilder.Length > "\u0002General commands:\u0002 ".Length) { e.Whisper(generalBuilder.ToString()); } if (channelBuilder.Length > channelMinLength) { e.Whisper(channelBuilder.ToString()); } }
public void CommandTime(object sender, CommandEventArgs e) { string key = e.Client.NetworkName + "/" + e.Sender.Nickname; Request request; if (requests.TryGetValue(key, out request)) { e.Whisper("I already have a pending request from you."); return; } // Parse the message. string timeString, zoneString, targetZoneString; var fields = e.Parameters[0].Split(new string[] { " in " }, 2, StringSplitOptions.None); if (fields.Length == 2) { timeString = fields[0]; zoneString = fields[1]; } else { timeString = fields[0]; zoneString = null; } fields = (zoneString ?? timeString).Split(new string[] { " to " }, 2, StringSplitOptions.None); DateTime?time; TimeSpan?zone; TimeSpan?targetZone; if (fields.Length == 2) { if (zoneString == null) { timeString = fields[0]; } else { zoneString = fields[0]; } targetZoneString = fields[1]; } else { targetZoneString = null; } if (targetZoneString == null && zoneString == null) { time = null; zone = null; targetZone = GetOffset(timeString, out targetZoneString); if (targetZone == null) { e.Whisper($"I do not recognize the time zone '{targetZoneString}'."); return; } DoConversion(e.Client, e.Sender, e.Target.Target, null, null, TimeSpan.Zero, targetZoneString, targetZone.Value); } else { DateTime time2; if (!TryParseUserTime(timeString, out time2)) { e.Whisper("I could not parse that time."); return; } time = time2; if (zoneString == null || zoneString.StartsWith("local", InvariantCultureIgnoreCase)) { zone = null; } else { zone = GetOffset(zoneString, out zoneString); if (zone == null) { e.Whisper($"I do not recognize the time zone '{zoneString}'."); return; } } if (targetZoneString == null || targetZoneString.StartsWith("local", InvariantCultureIgnoreCase)) { targetZone = null; } else { targetZone = GetOffset(targetZoneString, out targetZoneString); if (targetZone == null) { e.Whisper($"I do not recognize the time zone '{targetZoneString}'."); return; } } // Unless both zones are specified, we need to do a CTCP TIME. if (zone == null || targetZone == null) { request = new Request(e.Client, e.Target.Target, e.Sender, time, zone, targetZone, zoneString ?? targetZoneString); request.Timeout += Request_Timeout; e.Sender.Ctcp("TIME"); requests.Add(key, request); request.Start(); } else { DoConversion(e.Client, e.Sender, e.Target.Target, time, zoneString, zone.Value, targetZoneString, targetZone.Value); } } }
public async void CommandSet(object sender, CommandEventArgs e) { string property = e.Parameters[0]; string value = e.Parameters.Length == 1 ? null : e.Parameters[1]; int value2; bool value3; switch (property.Replace(" ", "").Replace("-", "").ToUpperInvariant()) { case "AI": if (!await SetPermissionCheckAsync(e)) { return; } if (value == null) { if (this.AIEnabled) { e.Reply("I \u00039will\u000F join Greedy Dice games."); } else { e.Reply("I \u00034will not\u000F join Greedy Dice games."); } } else if (Bot.TryParseBoolean(value, out value3)) { if (this.AIEnabled = value3) { e.Reply("I \u00039will now\u000F join Greedy Dice games."); } else { e.Reply("I \u00034will no longer\u000F join Greedy Dice games."); } } else { e.Whisper(string.Format("I don't recognise '{0}' as a Boolean value. Please enter 'on' or 'off'.", value)); } break; case "ENTRYTIME": case "ENTRYPERIOD": case "STARTTIME": case "ENTRY": if (!await SetPermissionCheckAsync(e)) { return; } if (value == null) { e.Reply("The entry period is \u0002{0}\u0002 seconds.", this.EntryTime); } else if (int.TryParse(value, out value2)) { if (value2 > 0) { this.EntryTime = value2; e.Reply("The entry period is now \u0002{0}\u0002 seconds.", this.EntryTime); } else { e.Whisper("The number must be positive.", value); } } else { e.Whisper(string.Format("That isn't a valid integer.", value)); } break; case "ENTRYWAITLIMIT": if (!await SetPermissionCheckAsync(e)) { return; } if (value == null) { e.Reply("The entry period may be extended to \u0002{0}\u0002 seconds.", this.EntryWaitLimit); } else if (int.TryParse(value, out value2)) { if (value2 > 0) { this.EntryWaitLimit = value2; e.Reply("The entry period may now be extended to \u0002{0}\u0002 seconds.", this.EntryWaitLimit); } else { e.Whisper("The number must be positive.", value); } } else { e.Whisper(string.Format("That isn't a valid integer.", value)); } break; case "TURNTIME": case "TIMELIMIT": case "IDLETIME": case "TIME": if (!await SetPermissionCheckAsync(e)) { return; } if (value == null) { if (this.TurnTime == 0) { e.Reply("The turn time limit is disabled.", this.TurnTime); } else { e.Reply("The turn time limit is \u0002{0}\u0002 seconds.", this.TurnTime); } } else if (int.TryParse(value, out value2)) { if (value2 >= 0) { this.TurnTime = value2; if (value2 == 0) { e.Reply("The turn time limit is now disabled.", this.TurnTime); } else { e.Reply("The turn time limit is now \u0002{0}\u0002 seconds.", this.TurnTime); } // Reset the existing turn timers. foreach (Game game in this.Games.Values) { game.GameTimer.Interval = this.TurnTime == 0 ? 60e+3 : (this.TurnTime * 1e+3); } } else { e.Whisper("The number cannot be negative.", value); } } else { e.Whisper(string.Format("That isn't a valid integer.", value)); } break; case "TURNWAITLIMIT": if (!await SetPermissionCheckAsync(e)) { return; } if (value == null) { e.Reply("The turn time limit may be extended to \u0002{0}\u0002 seconds.", this.TurnWaitLimit); } else if (int.TryParse(value, out value2)) { if (value2 > 0) { this.TurnWaitLimit = value2; e.Reply("The turn time limit may now be extended to \u0002{0}\u0002 seconds.", this.TurnWaitLimit); } else { e.Whisper("The number must be positive.", value); } } else { e.Whisper(string.Format("That isn't a valid integer.", value)); } break; default: e.Whisper(string.Format("I don't manage a setting named \u0002{0}\u0002.", property)); break; } }
public async void CommandDeleteAlias(object sender, CommandEventArgs e) { string alias = e.Parameters[0]; Command command; foreach (var pluginEntry in Bot.Plugins) { if (!pluginEntry.Obj.Commands.TryGetValue(alias, out command)) { continue; } // Check the scope. if ((command.Attribute.Scope & CommandScope.PM) == 0 && !(e.Target is IrcChannel)) { continue; } if ((command.Attribute.Scope & CommandScope.Channel) == 0 && e.Target is IrcChannel) { continue; } // Check for permissions. string permission; if (command.Attribute.Permission == null) { permission = null; } else if (command.Attribute.Permission != "" && command.Attribute.Permission.StartsWith(".")) { permission = this.Key + command.Attribute.Permission; } else { permission = command.Attribute.Permission; } if (permission != null) { if (!await Bot.CheckPermissionAsync(e.Sender, permission)) { if (command.Attribute.NoPermissionsMessage != null) { e.Whisper(command.Attribute.NoPermissionsMessage); } return; } } if (command.Attribute.Names.Count == 1) { e.Fail("That's the only alias, and cannot be deleted."); return; } pluginEntry.Obj.Commands.Remove(e.Parameters[0]); command.Attribute.Names.RemoveAll(name => name.Equals(e.Parameters[0], StringComparison.CurrentCultureIgnoreCase)); e.Reply("Deleted the alias successfully."); return; } }
public async void CommandAddAlias(object sender, CommandEventArgs e) { string alias = e.Parameters[1]; Command command; foreach (var pluginEntry in Bot.Plugins) { if (!pluginEntry.Obj.Commands.TryGetValue(alias, out command)) { continue; } // Check the scope. if ((command.Attribute.Scope & CommandScope.PM) == 0 && !(e.Target is IrcChannel)) { continue; } if ((command.Attribute.Scope & CommandScope.Channel) == 0 && e.Target is IrcChannel) { continue; } // Check for permissions. string permission; if (command.Attribute.Permission == null) { permission = null; } else if (command.Attribute.Permission != "" && command.Attribute.Permission.StartsWith(".")) { permission = this.Key + command.Attribute.Permission; } else { permission = command.Attribute.Permission; } if (permission != null) { if (!await Bot.CheckPermissionAsync(e.Sender, permission)) { if (command.Attribute.NoPermissionsMessage != null) { e.Whisper(command.Attribute.NoPermissionsMessage); } return; } } if (pluginEntry.Obj.Commands.ContainsKey(e.Parameters[0])) { e.Reply("A command with that name is already defined."); return; } pluginEntry.Obj.Commands.Add(e.Parameters[0], command); command.Attribute.Names.Add(e.Parameters[0]); e.Reply("Added an alias successfully."); return; } }
public async void CommandAddTrigger(object sender, CommandEventArgs e) { var match = Regex.Match(e.Parameters[0], @"(?:/(\\.|[^\/])*/)?(\S+)(?>\s+)(.+)"); if (!match.Success) { return; } string regex, switches; if (match.Groups[1].Success) { regex = match.Groups[1].Value; switches = match.Groups[2].Value; } else { regex = match.Groups[2].Value; switches = ""; } var fields = match.Groups[3].Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); string alias = fields[0]; Command command; foreach (var pluginEntry in Bot.Plugins) { if (!pluginEntry.Obj.Commands.TryGetValue(alias, out command)) { continue; } // Check the scope. if ((command.Attribute.Scope & CommandScope.PM) == 0 && !(e.Target is IrcChannel)) { continue; } if ((command.Attribute.Scope & CommandScope.Channel) == 0 && e.Target is IrcChannel) { continue; } // Check for permissions. string permission; if (command.Attribute.Permission == null) { permission = null; } else if (command.Attribute.Permission != "" && command.Attribute.Permission.StartsWith(".")) { permission = this.Key + command.Attribute.Permission; } else { permission = command.Attribute.Permission; } if (permission != null) { if (!await Bot.CheckPermissionAsync(e.Sender, permission)) { if (command.Attribute.NoPermissionsMessage != null) { e.Whisper(command.Attribute.NoPermissionsMessage); } return; } } pluginEntry.Obj.Triggers.Add(new Trigger(new TriggerAttribute(regex), (_sender, _e) => command.Handler.Invoke(_sender, new CommandEventArgs(_e.Client, _e.Target, _e.Sender, _e.Match.Groups.Cast <Group>().Select(g => g.Value).ToArray())))); e.Reply("Added a trigger successfully."); return; } }
public void CommandSet(object sender, CommandEventArgs e) { if (e.Parameters.Length == 1) { switch (e.Parameters[0].ToUpperInvariant()) { case "WHO": case "WHOINTERVAL": if (this.WhoTimer.Enabled) { e.Reply("WHO requests \u00039are\u000F being sent every \u0002{0}\u0002 seconds.", this.WhoTimer.Interval / 1000); } else { e.Reply("WHO requests \u00034are not\u000F being sent.", 0); } break; default: e.Whisper(string.Format("I don't manage a setting named \u0002{0}\u0002.", e.Parameters[1])); break; } } else { switch (e.Parameters[0].ToUpperInvariant()) { case "WHO": case "WHOINTERVAL": int value; if (int.TryParse(e.Parameters[1], out value)) { if (value == 0) { this.WhoTimer.Stop(); e.Reply("WHO requests will \u00034no longer\u000F be sent.", 0); } else if (value >= 5) { this.WhoTimer.Interval = value * 1000; this.WhoTimer.Start(); e.Reply("WHO requests will \u00039now\u000F be sent every \u0002{0}\u0002 seconds.", value); } else if (value > 0) { e.Whisper("That number is too small.", value); } else { e.Whisper("The number cannot be negative.", value); } } else { e.Whisper(string.Format("That's not a valid integer.", e.Parameters[1])); } break; default: e.Whisper(string.Format("I don't manage a setting named \u0002{0}\u0002.", e.Parameters[1])); break; } } }
public void CommandGetGender(object sender, CommandEventArgs e) { Gender gender; string header = null; if (this.GenderTable.TryGetValue(e.Parameters[0], out gender)) { header = e.Parameters[0]; } else { string[] fields = e.Parameters[0].Split(new char[] { '/' }, 2); if (fields.Length == 1) { fields = new string[] { "*", fields[0] } } ; var thisEntry = Bot.GetClientEntry(e.Client); if (fields[1].Contains("!")) { foreach (ClientEntry clientEntry in new[] { thisEntry }.Concat(Bot.Clients).Distinct()) { IrcClient client = clientEntry.Client; if (fields[0] == "*" || fields[0].Equals(client.Extensions.NetworkName, StringComparison.OrdinalIgnoreCase) || fields[0].Equals(client.Address, StringComparison.OrdinalIgnoreCase)) { foreach (var user in client.Users) { if (Bot.MaskCheck(user.ToString(), fields[1])) { gender = user.Gender; header = user.Nickname + "\u0002 on \u0002" + client.Extensions.NetworkName; break; } } break; } } } else { foreach (ClientEntry clientEntry in new[] { thisEntry }.Concat(Bot.Clients).Distinct()) { IrcClient client = clientEntry.Client; if (fields[0] == "*" || fields[0].Equals(client.Extensions.NetworkName, StringComparison.OrdinalIgnoreCase) || fields[0].Equals(client.Address, StringComparison.OrdinalIgnoreCase)) { if (client.Users.TryGetValue(fields[1], out IrcUser user)) { gender = user.Gender; header = user.Nickname + "\u0002 on \u0002" + client.Extensions.NetworkName; } break; } } } if (header == null) { e.Whisper("I didn't find any matching users."); return; } } if (gender == Gender.Male) { e.Reply("\u0002{0}\u0002 is \u0002male\u0002.", header); } else if (gender == Gender.Female) { e.Reply("\u0002{0}\u0002 is \u0002female\u0002.", header); } else if (gender == Gender.Bot) { e.Reply("\u0002{0}\u0002 is \u0002none\u0002.", header); } else { e.Reply("\u0002{0}\u0002 is \u0002unknown\u0002.", header); } }
public async void CommandSetGender(object sender, CommandEventArgs e) { Gender gender = Gender.Unspecified; bool valid = false; string mask = null; if (e.Parameters.Length == 1) { valid = true; mask = "*!*" + (e.Sender.Ident.StartsWith("~") ? e.Sender.Ident.Substring(1) : e.Sender.Ident) + "@" + e.Sender.Host; if (e.Parameters[0].Equals("male", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[00].Equals("m", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Male; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002male\u0002.", mask); } else if (e.Parameters[0].Equals("female", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[0].Equals("f", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Female; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002female\u0002.", mask); } else if (e.Parameters[0].Equals("none", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[0].Equals("n", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[0].Equals("bot", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[0].Equals("b", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Bot; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002none\u0002.", mask); } else if (e.Parameters[0].Equals("clear", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[0].Equals("c", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Unspecified; } else { valid = false; } } if (valid) { if (gender == Gender.Unspecified) { if (this.GenderTable.Remove(mask)) { e.Reply("Gender for \u0002{0}\u0002 has been cleared.", mask); } else { e.Whisper("No gender for \u0002{0}\u0002 was set.", mask); return; } } else { this.GenderTable[mask] = gender; } e.Sender.Gender = gender; return; } else if (await Bot.CheckPermissionAsync(e.Sender, this.Key + ".setgender.others")) { if (e.Parameters.Length == 1 || e.Parameters[1].Equals("clear", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("c", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Unspecified; if (this.GenderTable.Remove(e.Parameters[0])) { e.Reply("Gender for \u0002{0}\u0002 has been cleared.", e.Parameters[0]); } else { e.Whisper("No gender for \u0002{0}\u0002 was set.", e.Parameters[0]); return; } } else if (e.Parameters[1].Equals("male", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("m", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Male; this.GenderTable[e.Parameters[0]] = Gender.Male; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002male\u0002.", e.Parameters[0]); } else if (e.Parameters[1].Equals("female", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("f", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Female; this.GenderTable[e.Parameters[0]] = Gender.Female; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002female\u0002.", e.Parameters[0]); } else if (e.Parameters[1].Equals("none", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("n", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("bot", StringComparison.InvariantCultureIgnoreCase) || e.Parameters[1].Equals("b", StringComparison.InvariantCultureIgnoreCase)) { gender = Gender.Bot; this.GenderTable[e.Parameters[0]] = Gender.Bot; e.Reply("Gender for \u0002{0}\u0002 has been set to \u0002none\u0002.", e.Parameters[0]); } else { e.Whisper("'{0}' isn't a valid option. Use 'male', 'female', 'none' or 'clear'.", e.Parameters[1]); return; } } else { e.Whisper("You don't have permission to set a gender for others."); return; } string[] fields = e.Parameters[0].Split(new char[] { '/' }, 2); if (fields.Length == 1) { fields = new string[] { "*", fields[0] } } ; int index = fields[1].IndexOf('!'); int index2 = index == -1 ? 0 : fields[1].IndexOfAny(new char[] { '*', '?' }, 0, index); if (index2 == -1) { foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (fields[0] == "*" || fields[0].Equals(client.Extensions.NetworkName, StringComparison.OrdinalIgnoreCase) || fields[0].Equals(client.Address, StringComparison.OrdinalIgnoreCase)) { IrcUser user; if (client.Users.TryGetValue(fields[1].Substring(0, index), out user)) { if (Bot.MaskCheck(user.ToString(), fields[1])) { user.Gender = gender; } } } } } else { foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (fields[0] == "*" || fields[0].Equals(client.NetworkName, StringComparison.OrdinalIgnoreCase) || fields[0].Equals(client.Address, StringComparison.OrdinalIgnoreCase)) { foreach (IrcUser user in client.Users) { if (Bot.MaskCheck(user.ToString(), fields[1])) { user.Gender = gender; } } } } } }