using System;
namespace TechBot.IRCLibrary
{
///
/// IRC user.
///
public class IrcUser
{
#region Private fields
private string nickname;
private string decoratedNickname;
#endregion
#region Public properties
///
/// Nickname of user.
///
public string Nickname
{
get
{
return nickname;
}
}
///
/// Decorated nickname of user.
///
public string DecoratedNickname
{
get
{
return decoratedNickname;
}
}
///
/// Wether user is channel operator.
///
public bool Operator
{
get
{
return decoratedNickname.StartsWith("@");
}
}
///
/// Wether user has voice.
///
public bool Voice
{
get
{
return decoratedNickname.StartsWith("+");
}
}
#endregion
///
/// Constructor.
///
/// Nickname (possibly decorated) of user.
public IrcUser(string nickname)
{
this.decoratedNickname = nickname.Trim();
this.nickname = StripDecoration(decoratedNickname);
}
///
/// Strip docoration of nickname.
///
/// Possible decorated nickname.
/// Undecorated nickname.
public static string StripDecoration(string decoratedNickname)
{
if (decoratedNickname.StartsWith("@"))
{
return decoratedNickname.Substring(1);
}
else if (decoratedNickname.StartsWith("+"))
{
return decoratedNickname.Substring(1);
}
else
{
return decoratedNickname;
}
}
}
}