public void CommandConnect(object sender, CommandEventArgs e) { if (e.Parameters.Length == 0) { e.Reply("I'm connected to the following servers:"); foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; switch (client.State) { case IrcClientState.Disconnected: e.Reply(string.Format("{0} - \u00034offline\u000F.", client.NetworkName)); break; case IrcClientState.Connecting: e.Reply(string.Format("{0} - \u00038connecting\u000F.", client.NetworkName)); break; case IrcClientState.SslHandshaking: e.Reply(string.Format("{0} - \u00038establishing TLS connection\u000F.", client.NetworkName)); break; case IrcClientState.SaslAuthenticating: e.Reply(string.Format("{0} - \u00038authenticating\u000F.", client.NetworkName)); break; case IrcClientState.Registering: e.Reply(string.Format("{0} - \u00038logging in\u000F.", client.NetworkName)); break; case IrcClientState.Online: if (client.Channels.Count > 1) { e.Reply(string.Format("{0} - \u00039online\u000F; on channels \u0002{1}\u000F.", client.NetworkName, string.Join("\u000F, \u0002", client.Channels.Select(c => c.Name)))); } else if (client.Channels.Count == 1) { e.Reply(string.Format("{0} - \u00039online\u000F; on channel \u0002{1}\u000F.", client.NetworkName, client.Channels.First().Name)); } else { e.Reply(string.Format("{0} - \u00039online\u000F.", client.NetworkName)); } break; default: e.Reply(string.Format("{0} - {1}.", client.NetworkName, client.State)); break; } } } else { foreach (ClientEntry clientEntry in Bot.Clients) { IrcClient client = clientEntry.Client; if (client.Address.Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase) || (client.Extensions.NetworkName != null && client.Extensions.NetworkName.Equals(e.Parameters[0], StringComparison.OrdinalIgnoreCase))) { if (client.State != IrcClientState.Disconnected) { e.Reply(string.Format("I'm already connected to \u0002{0}\u000F.", client.Address)); } else { e.Reply(string.Format("Reconnecting to \u0002{0}\u000F.", client.Address)); client.Connect(clientEntry.Address, clientEntry.Port); } return; } } e.Reply(string.Format("Connecting to \u0002{0}\u000F.", e.Parameters[0])); var network = new ClientEntry(e.Parameters[0]) { Address = e.Parameters[0], Port = 6667, Nicknames = new[] { e.Client.Me.Nickname }, Ident = e.Client.Me.Ident, FullName = e.Client.Me.FullName }; Bot.AddNetwork(network); network.Connect(); } }