diff --git a/ChatSharp/ChannelCollection.cs b/ChatSharp/ChannelCollection.cs index f3053c2..ccc5fc6 100644 --- a/ChatSharp/ChannelCollection.cs +++ b/ChatSharp/ChannelCollection.cs @@ -1,8 +1,8 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; -using System.Linq; - +using System.Linq; + namespace ChatSharp { public class ChannelCollection : IEnumerable diff --git a/ChatSharp/ClientSettings.cs b/ChatSharp/ClientSettings.cs index 95364e2..32565e3 100644 --- a/ChatSharp/ClientSettings.cs +++ b/ChatSharp/ClientSettings.cs @@ -1,4 +1,4 @@ -namespace ChatSharp +namespace ChatSharp { public class ClientSettings { diff --git a/ChatSharp/Events/ChannelEventArgs.cs b/ChatSharp/Events/ChannelEventArgs.cs index 13dc786..1c3145e 100644 --- a/ChatSharp/Events/ChannelEventArgs.cs +++ b/ChatSharp/Events/ChannelEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class ChannelEventArgs : EventArgs diff --git a/ChatSharp/Events/ChannelTopicEventArgs.cs b/ChatSharp/Events/ChannelTopicEventArgs.cs index df88eea..bb6f568 100644 --- a/ChatSharp/Events/ChannelTopicEventArgs.cs +++ b/ChatSharp/Events/ChannelTopicEventArgs.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace ChatSharp.Events { diff --git a/ChatSharp/Events/ChannelUserEventArgs.cs b/ChatSharp/Events/ChannelUserEventArgs.cs index 99eaa40..1eac86e 100644 --- a/ChatSharp/Events/ChannelUserEventArgs.cs +++ b/ChatSharp/Events/ChannelUserEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class ChannelUserEventArgs : EventArgs diff --git a/ChatSharp/Events/ErronousNickEventArgs.cs b/ChatSharp/Events/ErronousNickEventArgs.cs index e6cdf60..d607d2f 100644 --- a/ChatSharp/Events/ErronousNickEventArgs.cs +++ b/ChatSharp/Events/ErronousNickEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class ErronousNickEventArgs : EventArgs diff --git a/ChatSharp/Events/IrcNoticeEventArgs.cs b/ChatSharp/Events/IrcNoticeEventArgs.cs index 2a73fd2..7ce83f9 100644 --- a/ChatSharp/Events/IrcNoticeEventArgs.cs +++ b/ChatSharp/Events/IrcNoticeEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class IrcNoticeEventArgs : EventArgs diff --git a/ChatSharp/Events/ModeChangeEventArgs.cs b/ChatSharp/Events/ModeChangeEventArgs.cs index ac70a8a..70b81b4 100644 --- a/ChatSharp/Events/ModeChangeEventArgs.cs +++ b/ChatSharp/Events/ModeChangeEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class ModeChangeEventArgs : EventArgs diff --git a/ChatSharp/Events/NickChangedEventArgs.cs b/ChatSharp/Events/NickChangedEventArgs.cs index b133f0d..607fda9 100644 --- a/ChatSharp/Events/NickChangedEventArgs.cs +++ b/ChatSharp/Events/NickChangedEventArgs.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace ChatSharp.Events { diff --git a/ChatSharp/Events/PrivateMessageEventArgs.cs b/ChatSharp/Events/PrivateMessageEventArgs.cs index eeb94fc..d7075fc 100644 --- a/ChatSharp/Events/PrivateMessageEventArgs.cs +++ b/ChatSharp/Events/PrivateMessageEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class PrivateMessageEventArgs : EventArgs diff --git a/ChatSharp/Events/RawMessageEventArgs.cs b/ChatSharp/Events/RawMessageEventArgs.cs index 07b237b..dd15486 100644 --- a/ChatSharp/Events/RawMessageEventArgs.cs +++ b/ChatSharp/Events/RawMessageEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class RawMessageEventArgs : EventArgs diff --git a/ChatSharp/Events/ServerMOTDEventArgs.cs b/ChatSharp/Events/ServerMOTDEventArgs.cs index f9a3a8c..7cdd755 100644 --- a/ChatSharp/Events/ServerMOTDEventArgs.cs +++ b/ChatSharp/Events/ServerMOTDEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class ServerMOTDEventArgs : EventArgs diff --git a/ChatSharp/Events/SocketErrorEventArgs.cs b/ChatSharp/Events/SocketErrorEventArgs.cs index 3177ba3..416405c 100644 --- a/ChatSharp/Events/SocketErrorEventArgs.cs +++ b/ChatSharp/Events/SocketErrorEventArgs.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.Sockets; namespace ChatSharp.Events diff --git a/ChatSharp/Events/SupportsEventArgs.cs b/ChatSharp/Events/SupportsEventArgs.cs index cb333e1..612ccb7 100644 --- a/ChatSharp/Events/SupportsEventArgs.cs +++ b/ChatSharp/Events/SupportsEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class SupportsEventArgs : EventArgs diff --git a/ChatSharp/Events/WhoIsEventArgs.cs b/ChatSharp/Events/WhoIsEventArgs.cs index 90c803a..bd320ad 100644 --- a/ChatSharp/Events/WhoIsEventArgs.cs +++ b/ChatSharp/Events/WhoIsEventArgs.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp.Events { public class WhoIsReceivedEventArgs : EventArgs diff --git a/ChatSharp/Handlers/ChannelHandlers.cs b/ChatSharp/Handlers/ChannelHandlers.cs index 9465557..5fdb450 100644 --- a/ChatSharp/Handlers/ChannelHandlers.cs +++ b/ChatSharp/Handlers/ChannelHandlers.cs @@ -1,148 +1,148 @@ -using ChatSharp.Events; -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace ChatSharp.Handlers -{ - internal static class ChannelHandlers - { - public static void HandleJoin(IrcClient client, IrcMessage message) - { - IrcChannel channel = null; - if (client.User.Nick == new IrcUser(message.Prefix).Nick) - { - // We've joined this channel - channel = new IrcChannel(client, message.Parameters[0]); - client.Channels.Add(channel); - } - else - { - // Someone has joined a channel we're already in - channel = client.Channels[message.Parameters[0]]; - channel.Users.Add(new IrcUser(message.Prefix)); - } - if (channel != null) - client.OnUserJoinedChannel(new ChannelUserEventArgs(channel, new IrcUser(message.Prefix))); - } - - public static void HandleGetTopic(IrcClient client, IrcMessage message) - { - IrcChannel channel = null; - string topic; - if (client.Channels.Contains(message.Parameters[1])) - { - channel = client.Channels[message.Parameters[1]]; - topic = message.Parameters[2]; - channel.Topic = topic; - } - else - { - channel = new IrcChannel(client, message.Parameters[1]); - topic = message.Parameters[2]; - } - client.OnChannelTopicReceived(new ChannelTopicEventArgs(channel, topic)); - } - - public static void HandleGetEmptyTopic(IrcClient client, IrcMessage message) - { - var channel = client.Channels[message.Parameters[1]]; - var topic = message.Parameters[2]; - client.OnChannelTopicReceived(new ChannelTopicEventArgs(channel, topic)); - } - - public static void HandlePart(IrcClient client, IrcMessage message) - { - if (!client.Channels.Contains(message.Parameters[0])) - return; // we already parted the channel, ignore - - if (client.User.Match(message.Prefix)) // We've parted this channel - client.Channels.Remove(client.Channels[message.Parameters[0]]); - else // Someone has parted a channel we're already in - { - var user = new IrcUser(message.Prefix).Nick; - var channel = client.Channels[message.Parameters[0]]; - if (channel.Users.Contains(user)) - channel.Users.Remove(user); - foreach (var mode in channel.UsersByMode) - { - if (mode.Value.Contains(user)) - mode.Value.Remove(user); - } - client.OnUserPartedChannel(new ChannelUserEventArgs(client.Channels[message.Parameters[0]], new IrcUser(message.Prefix))); - } - } - - public static void HandleUserListPart(IrcClient client, IrcMessage message) - { - var channel = client.Channels[message.Parameters[2]]; - var users = message.Parameters[3].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); - foreach (var user in users) - { - if (string.IsNullOrWhiteSpace(user)) continue; - var mode = client.ServerInfo.GetModeForPrefix(user[0]); - if (mode == null) - channel.Users.Add(new IrcUser(user)); - else - { - channel.Users.Add(new IrcUser(user.Substring(1))); - if (!channel.UsersByMode.ContainsKey(mode.Value)) - channel.UsersByMode.Add(mode.Value, new UserCollection()); - channel.UsersByMode[mode.Value].Add(new IrcUser(user.Substring(1))); - } - } - } - - public static void HandleUserListEnd(IrcClient client, IrcMessage message) - { - var channel = client.Channels[message.Parameters[1]]; - client.OnChannelListRecieved(new ChannelEventArgs(channel)); - if (client.Settings.ModeOnJoin) - { - try - { - client.GetMode(channel.Name, c => Console.WriteLine(c.Mode)); - } - catch { } - } - if (client.Settings.WhoIsOnJoin) - { - Task.Factory.StartNew(() => WhoIsChannel(channel, client, 0)); - } - } - - private static void WhoIsChannel(IrcChannel channel, IrcClient client, int index) - { - // Note: joins and parts that happen during this will cause strange behavior here - Thread.Sleep(client.Settings.JoinWhoIsDelay * 1000); - var user = channel.Users[index]; - client.WhoIs(user.Nick, (whois) => - { - user.User = whois.User.User; - user.Hostname = whois.User.Hostname; - user.RealName = whois.User.RealName; - Task.Factory.StartNew(() => WhoIsChannel(channel, client, index + 1)); - }); - } - - public static void HandleKick(IrcClient client, IrcMessage message) - { - var channel = client.Channels[message.Parameters[0]]; - var kicked = channel.Users[message.Parameters[1]]; - if (string.Equals(message.Parameters[1], client.User.Nick, StringComparison.OrdinalIgnoreCase)) // We've been kicked - client.Channels.Remove(client.Channels[message.Parameters[0]]); - else - { - if (channel.Users.Contains(message.Parameters[1])) - channel.Users.Remove(message.Parameters[1]); - foreach (var mode in channel.UsersByMode.Where(mode => mode.Value.Contains(message.Parameters[1]))) - { - mode.Value.Remove(message.Parameters[1]); - } - } - client.OnUserKicked(new KickEventArgs(channel, new IrcUser(message.Prefix), - kicked, message.Parameters[2])); - } - } -} +using ChatSharp.Events; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace ChatSharp.Handlers +{ + internal static class ChannelHandlers + { + public static void HandleJoin(IrcClient client, IrcMessage message) + { + IrcChannel channel = null; + if (client.User.Nick == new IrcUser(message.Prefix).Nick) + { + // We've joined this channel + channel = new IrcChannel(client, message.Parameters[0]); + client.Channels.Add(channel); + } + else + { + // Someone has joined a channel we're already in + channel = client.Channels[message.Parameters[0]]; + channel.Users.Add(new IrcUser(message.Prefix)); + } + if (channel != null) + client.OnUserJoinedChannel(new ChannelUserEventArgs(channel, new IrcUser(message.Prefix))); + } + + public static void HandleGetTopic(IrcClient client, IrcMessage message) + { + IrcChannel channel = null; + string topic; + if (client.Channels.Contains(message.Parameters[1])) + { + channel = client.Channels[message.Parameters[1]]; + topic = message.Parameters[2]; + channel.Topic = topic; + } + else + { + channel = new IrcChannel(client, message.Parameters[1]); + topic = message.Parameters[2]; + } + client.OnChannelTopicReceived(new ChannelTopicEventArgs(channel, topic)); + } + + public static void HandleGetEmptyTopic(IrcClient client, IrcMessage message) + { + var channel = client.Channels[message.Parameters[1]]; + var topic = message.Parameters[2]; + client.OnChannelTopicReceived(new ChannelTopicEventArgs(channel, topic)); + } + + public static void HandlePart(IrcClient client, IrcMessage message) + { + if (!client.Channels.Contains(message.Parameters[0])) + return; // we already parted the channel, ignore + + if (client.User.Match(message.Prefix)) // We've parted this channel + client.Channels.Remove(client.Channels[message.Parameters[0]]); + else // Someone has parted a channel we're already in + { + var user = new IrcUser(message.Prefix).Nick; + var channel = client.Channels[message.Parameters[0]]; + if (channel.Users.Contains(user)) + channel.Users.Remove(user); + foreach (var mode in channel.UsersByMode) + { + if (mode.Value.Contains(user)) + mode.Value.Remove(user); + } + client.OnUserPartedChannel(new ChannelUserEventArgs(client.Channels[message.Parameters[0]], new IrcUser(message.Prefix))); + } + } + + public static void HandleUserListPart(IrcClient client, IrcMessage message) + { + var channel = client.Channels[message.Parameters[2]]; + var users = message.Parameters[3].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); + foreach (var user in users) + { + if (string.IsNullOrWhiteSpace(user)) continue; + var mode = client.ServerInfo.GetModeForPrefix(user[0]); + if (mode == null) + channel.Users.Add(new IrcUser(user)); + else + { + channel.Users.Add(new IrcUser(user.Substring(1))); + if (!channel.UsersByMode.ContainsKey(mode.Value)) + channel.UsersByMode.Add(mode.Value, new UserCollection()); + channel.UsersByMode[mode.Value].Add(new IrcUser(user.Substring(1))); + } + } + } + + public static void HandleUserListEnd(IrcClient client, IrcMessage message) + { + var channel = client.Channels[message.Parameters[1]]; + client.OnChannelListRecieved(new ChannelEventArgs(channel)); + if (client.Settings.ModeOnJoin) + { + try + { + client.GetMode(channel.Name, c => Console.WriteLine(c.Mode)); + } + catch { } + } + if (client.Settings.WhoIsOnJoin) + { + Task.Factory.StartNew(() => WhoIsChannel(channel, client, 0)); + } + } + + private static void WhoIsChannel(IrcChannel channel, IrcClient client, int index) + { + // Note: joins and parts that happen during this will cause strange behavior here + Thread.Sleep(client.Settings.JoinWhoIsDelay * 1000); + var user = channel.Users[index]; + client.WhoIs(user.Nick, (whois) => + { + user.User = whois.User.User; + user.Hostname = whois.User.Hostname; + user.RealName = whois.User.RealName; + Task.Factory.StartNew(() => WhoIsChannel(channel, client, index + 1)); + }); + } + + public static void HandleKick(IrcClient client, IrcMessage message) + { + var channel = client.Channels[message.Parameters[0]]; + var kicked = channel.Users[message.Parameters[1]]; + if (string.Equals(message.Parameters[1], client.User.Nick, StringComparison.OrdinalIgnoreCase)) // We've been kicked + client.Channels.Remove(client.Channels[message.Parameters[0]]); + else + { + if (channel.Users.Contains(message.Parameters[1])) + channel.Users.Remove(message.Parameters[1]); + foreach (var mode in channel.UsersByMode.Where(mode => mode.Value.Contains(message.Parameters[1]))) + { + mode.Value.Remove(message.Parameters[1]); + } + } + client.OnUserKicked(new KickEventArgs(channel, new IrcUser(message.Prefix), + kicked, message.Parameters[2])); + } + } +} diff --git a/ChatSharp/Handlers/ListingHandlers.cs b/ChatSharp/Handlers/ListingHandlers.cs index d977eab..f5f1fb3 100644 --- a/ChatSharp/Handlers/ListingHandlers.cs +++ b/ChatSharp/Handlers/ListingHandlers.cs @@ -1,4 +1,4 @@ -namespace ChatSharp.Handlers +namespace ChatSharp.Handlers { internal static class ListingHandlers { diff --git a/ChatSharp/Handlers/MOTDHandlers.cs b/ChatSharp/Handlers/MOTDHandlers.cs index 721e316..f8904ea 100644 --- a/ChatSharp/Handlers/MOTDHandlers.cs +++ b/ChatSharp/Handlers/MOTDHandlers.cs @@ -1,4 +1,4 @@ -using ChatSharp.Events; +using ChatSharp.Events; using System; namespace ChatSharp.Handlers diff --git a/ChatSharp/Handlers/MessageHandlers.cs b/ChatSharp/Handlers/MessageHandlers.cs index 1f5caee..9e86917 100644 --- a/ChatSharp/Handlers/MessageHandlers.cs +++ b/ChatSharp/Handlers/MessageHandlers.cs @@ -1,4 +1,4 @@ -using ChatSharp.Events; +using ChatSharp.Events; using System.Linq; using System; diff --git a/ChatSharp/Handlers/ServerHandlers.cs b/ChatSharp/Handlers/ServerHandlers.cs index d2fd762..0deacde 100644 --- a/ChatSharp/Handlers/ServerHandlers.cs +++ b/ChatSharp/Handlers/ServerHandlers.cs @@ -1,6 +1,6 @@ -using ChatSharp.Events; -using System.Linq; - +using ChatSharp.Events; +using System.Linq; + namespace ChatSharp.Handlers { internal static class ServerHandlers diff --git a/ChatSharp/Handlers/UserHandlers.cs b/ChatSharp/Handlers/UserHandlers.cs index e499156..31f02de 100644 --- a/ChatSharp/Handlers/UserHandlers.cs +++ b/ChatSharp/Handlers/UserHandlers.cs @@ -1,6 +1,6 @@ -using System; -using System.Linq; - +using System; +using System.Linq; + namespace ChatSharp.Handlers { public static class UserHandlers diff --git a/ChatSharp/IrcChannel.cs b/ChatSharp/IrcChannel.cs index 524e5fc..a23445d 100644 --- a/ChatSharp/IrcChannel.cs +++ b/ChatSharp/IrcChannel.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; - +using System.Collections.Generic; + namespace ChatSharp { public class IrcChannel @@ -67,10 +67,10 @@ namespace ChatSharp Client.ChangeMode(Name, change); } - public void SetTopic(string topic) - { - Client.SetTopic(Name, topic); - Topic = topic; + public void SetTopic(string topic) + { + Client.SetTopic(Name, topic); + Topic = topic; } } } diff --git a/ChatSharp/IrcClient.Commands.cs b/ChatSharp/IrcClient.Commands.cs index fc8e82e..a45dedf 100644 --- a/ChatSharp/IrcClient.Commands.cs +++ b/ChatSharp/IrcClient.Commands.cs @@ -1,6 +1,6 @@ -using System; -using System.Linq; - +using System; +using System.Linq; + namespace ChatSharp { public partial class IrcClient @@ -59,9 +59,9 @@ namespace ChatSharp SendRawMessage("TOPIC {0} :{1}", channel, topic); } - public void GetTopic(string channel) - { - SendRawMessage("TOPIC {0}", channel); + public void GetTopic(string channel) + { + SendRawMessage("TOPIC {0}", channel); } public void KickUser(string channel, string user) diff --git a/ChatSharp/IrcClient.cs b/ChatSharp/IrcClient.cs index e0e3dff..bba3120 100644 --- a/ChatSharp/IrcClient.cs +++ b/ChatSharp/IrcClient.cs @@ -1,12 +1,12 @@ -using ChatSharp.Events; -using ChatSharp.Handlers; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Net.Security; -using System.Net.Sockets; -using System.Text; +using ChatSharp.Events; +using ChatSharp.Handlers; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Net.Security; +using System.Net.Sockets; +using System.Text; using System.Timers; namespace ChatSharp @@ -65,14 +65,14 @@ namespace ChatSharp } public Stream NetworkStream { get; set; } - public bool UseSSL { get; private set; } + public bool UseSSL { get; private set; } public bool IgnoreInvalidSSL { get; set; } public Encoding Encoding { get; set; } public IrcUser User { get; set; } public ChannelCollection Channels { get; private set; } public ClientSettings Settings { get; set; } public RequestManager RequestManager { get; set; } - public ServerInfo ServerInfo { get; set; } + public ServerInfo ServerInfo { get; set; } public string PrivmsgPrefix { get; set; } public IrcClient(string serverAddress, IrcUser user, bool useSSL = false) @@ -89,7 +89,7 @@ namespace ChatSharp MessageHandlers.RegisterDefaultHandlers(this); RequestManager = new RequestManager(); UseSSL = useSSL; - WriteQueue = new ConcurrentQueue(); + WriteQueue = new ConcurrentQueue(); PrivmsgPrefix = ""; } @@ -115,7 +115,7 @@ namespace ChatSharp SendRawMessage(nextMessage); } }; - checkQueue.Start(); + checkQueue.Start(); Socket.BeginConnect(ServerHostname, ServerPort, ConnectComplete, null); } @@ -146,9 +146,9 @@ namespace ChatSharp NetworkStream = new NetworkStream(Socket); if (UseSSL) { - if (IgnoreInvalidSSL) + if (IgnoreInvalidSSL) NetworkStream = new SslStream(NetworkStream, false, (sender, certificate, chain, policyErrors) => true); - else + else NetworkStream = new SslStream(NetworkStream); ((SslStream)NetworkStream).AuthenticateAsClient(ServerHostname); } @@ -349,11 +349,11 @@ namespace ChatSharp protected internal virtual void OnChannelListRecieved(ChannelEventArgs e) { if (ChannelListRecieved != null) ChannelListRecieved(this, e); - } + } public event EventHandler ChannelTopicReceived; - protected internal virtual void OnChannelTopicReceived(ChannelTopicEventArgs e) - { - if (ChannelTopicReceived != null) ChannelTopicReceived(this, e); + protected internal virtual void OnChannelTopicReceived(ChannelTopicEventArgs e) + { + if (ChannelTopicReceived != null) ChannelTopicReceived(this, e); } public event EventHandler ConnectionComplete; protected internal virtual void OnConnectionComplete(EventArgs e) @@ -368,19 +368,19 @@ namespace ChatSharp public event EventHandler UserKicked; protected internal virtual void OnUserKicked(KickEventArgs e) { - if (UserKicked != null) UserKicked(this, e); - } - - public event EventHandler WhoIsReceived; - protected internal virtual void OnWhoIsReceived(WhoIsReceivedEventArgs e) - { - if (WhoIsReceived != null) WhoIsReceived(this, e); - } - - public event EventHandler NickChanged; - protected internal virtual void OnNickChanged(NickChangedEventArgs e) - { - if (NickChanged != null) NickChanged(this, e); + if (UserKicked != null) UserKicked(this, e); + } + + public event EventHandler WhoIsReceived; + protected internal virtual void OnWhoIsReceived(WhoIsReceivedEventArgs e) + { + if (WhoIsReceived != null) WhoIsReceived(this, e); + } + + public event EventHandler NickChanged; + protected internal virtual void OnNickChanged(NickChangedEventArgs e) + { + if (NickChanged != null) NickChanged(this, e); } } } diff --git a/ChatSharp/IrcMessage.cs b/ChatSharp/IrcMessage.cs index 758c319..7a02ef7 100644 --- a/ChatSharp/IrcMessage.cs +++ b/ChatSharp/IrcMessage.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; +using System.Linq; + namespace ChatSharp { public class IrcMessage diff --git a/ChatSharp/IrcProtocolException.cs b/ChatSharp/IrcProtocolException.cs index 5c36934..067cd59 100644 --- a/ChatSharp/IrcProtocolException.cs +++ b/ChatSharp/IrcProtocolException.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp { public class IrcProtocolException : Exception diff --git a/ChatSharp/IrcUser.cs b/ChatSharp/IrcUser.cs index cecd1da..0db8753 100644 --- a/ChatSharp/IrcUser.cs +++ b/ChatSharp/IrcUser.cs @@ -1,6 +1,6 @@ -using System; -using System.Linq; - +using System; +using System.Linq; + namespace ChatSharp { public class IrcUser : IEquatable diff --git a/ChatSharp/Mask.cs b/ChatSharp/Mask.cs index d5d70e1..cde8d12 100644 --- a/ChatSharp/Mask.cs +++ b/ChatSharp/Mask.cs @@ -1,5 +1,5 @@ -using System; - +using System; + namespace ChatSharp { public class Mask diff --git a/ChatSharp/MaskCollection.cs b/ChatSharp/MaskCollection.cs index 589fb89..6fca576 100644 --- a/ChatSharp/MaskCollection.cs +++ b/ChatSharp/MaskCollection.cs @@ -1,7 +1,7 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; -using System.Linq; - +using System.Linq; + namespace ChatSharp { public class MaskCollection : IEnumerable diff --git a/ChatSharp/PrivateMessage.cs b/ChatSharp/PrivateMessage.cs index 48d3a7f..1e28106 100644 --- a/ChatSharp/PrivateMessage.cs +++ b/ChatSharp/PrivateMessage.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; namespace ChatSharp { diff --git a/ChatSharp/Properties/AssemblyInfo.cs b/ChatSharp/Properties/AssemblyInfo.cs index 712b2e6..8c5ec22 100644 --- a/ChatSharp/Properties/AssemblyInfo.cs +++ b/ChatSharp/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/ChatSharp/RequestManager.cs b/ChatSharp/RequestManager.cs index 3696113..8a3f502 100644 --- a/ChatSharp/RequestManager.cs +++ b/ChatSharp/RequestManager.cs @@ -1,7 +1,7 @@ -using System; +using System; using System.Collections.Generic; -using System.Linq; - +using System.Linq; + namespace ChatSharp { public class RequestManager diff --git a/ChatSharp/ServerInfo.cs b/ChatSharp/ServerInfo.cs index 27c42f7..4c34b64 100644 --- a/ChatSharp/ServerInfo.cs +++ b/ChatSharp/ServerInfo.cs @@ -1,4 +1,4 @@ -namespace ChatSharp +namespace ChatSharp { public class ServerInfo { diff --git a/ChatSharp/UserCollection.cs b/ChatSharp/UserCollection.cs index 36b1df5..efb1796 100644 --- a/ChatSharp/UserCollection.cs +++ b/ChatSharp/UserCollection.cs @@ -1,7 +1,7 @@ -using System.Collections; +using System.Collections; using System.Collections.Generic; -using System.Linq; - +using System.Linq; + namespace ChatSharp { public class UserCollection : IEnumerable diff --git a/ChatSharp/WhoIs.cs b/ChatSharp/WhoIs.cs index 3683d2a..8f9ebd7 100644 --- a/ChatSharp/WhoIs.cs +++ b/ChatSharp/WhoIs.cs @@ -1,4 +1,4 @@ -namespace ChatSharp +namespace ChatSharp { public class WhoIs { diff --git a/TestChatSharp/Program.cs b/TestChatSharp/Program.cs index fb6006b..47cfbd2 100644 --- a/TestChatSharp/Program.cs +++ b/TestChatSharp/Program.cs @@ -1,7 +1,7 @@ -using ChatSharp; -using System; -using System.Linq; - +using ChatSharp; +using System; +using System.Linq; + namespace TestChatSharp { class Program @@ -31,29 +31,29 @@ namespace TestChatSharp var parts = e.PrivateMessage.Message.Split(' '); client.ChangeMode(parts[1], parts[2]); } - else if (e.PrivateMessage.Message.StartsWith(".topic ")) - { - string messageArgs = e.PrivateMessage.Message.Substring(7); - if (messageArgs.Contains(" ")) - { - string channel = messageArgs.Substring(0, messageArgs.IndexOf(" ")); - string topic = messageArgs.Substring(messageArgs.IndexOf(" ") + 1); - client.Channels[channel].SetTopic(topic); - } - else - { - string channel = messageArgs.Substring(messageArgs.IndexOf("#")); - client.GetTopic(channel); - } + else if (e.PrivateMessage.Message.StartsWith(".topic ")) + { + string messageArgs = e.PrivateMessage.Message.Substring(7); + if (messageArgs.Contains(" ")) + { + string channel = messageArgs.Substring(0, messageArgs.IndexOf(" ")); + string topic = messageArgs.Substring(messageArgs.IndexOf(" ") + 1); + client.Channels[channel].SetTopic(topic); + } + else + { + string channel = messageArgs.Substring(messageArgs.IndexOf("#")); + client.GetTopic(channel); + } } }; client.ChannelMessageRecieved += (s, e) => { Console.WriteLine("<{0}> {1}", e.PrivateMessage.User.Nick, e.PrivateMessage.Message); - }; - client.ChannelTopicReceived += (s, e) => - { - Console.WriteLine("Received topic for channel {0}: {1}", e.Channel.Name, e.Topic); + }; + client.ChannelTopicReceived += (s, e) => + { + Console.WriteLine("Received topic for channel {0}: {1}", e.Channel.Name, e.Topic); }; client.ConnectAsync(); while (true) ; diff --git a/TestChatSharp/Properties/AssemblyInfo.cs b/TestChatSharp/Properties/AssemblyInfo.cs index acd65c4..c54500c 100644 --- a/TestChatSharp/Properties/AssemblyInfo.cs +++ b/TestChatSharp/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following