sharp-chat/SharpChat.Protocol.IRC/Channels/ChannelManagerExtensions.cs

19 lines
699 B
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Channels;
using System;
namespace SharpChat.Protocol.IRC.Channels {
public static class ChannelManagerExtensions {
public static void GetChannelByIRCName(this ChannelManager channels, string ircName, Action<IChannel> callback) {
if(ircName == null)
throw new ArgumentNullException(nameof(ircName));
if(callback == null)
throw new ArgumentNullException(nameof(callback));
if(string.IsNullOrWhiteSpace(ircName) || ircName == @"#") {
callback(null);
return;
}
channels.GetChannel(c => ircName.Equals(c.GetIRCName()), callback);
}
}
}