24 lines
954 B
C#
24 lines
954 B
C#
|
using SharpChat.ClientCommands;
|
||
|
using SharpChat.Users;
|
||
|
|
||
|
namespace SharpChat;
|
||
|
public static class UserExtensions {
|
||
|
public static string GetLegacyName(this User user) {
|
||
|
return string.IsNullOrWhiteSpace(user.NickName) ? user.UserName : '~' + user.NickName;
|
||
|
}
|
||
|
|
||
|
public static string GetLegacyNameWithStatus(this User user) {
|
||
|
return user.Status == UserStatus.Away ? string.Format(
|
||
|
"<{0}>_{1}",
|
||
|
user.StatusText.TruncateIfTooLong(AFKClientCommand.MAX_GRAPHEMES, AFKClientCommand.MAX_BYTES).Trim().ToUpperInvariant(),
|
||
|
user.GetLegacyName()
|
||
|
) : user.GetLegacyName();
|
||
|
}
|
||
|
|
||
|
public static bool LegacyNameEquals(this User user, string name) {
|
||
|
return user.NameEquals(name)
|
||
|
|| string.Equals(name, user.GetLegacyName(), StringComparison.OrdinalIgnoreCase)
|
||
|
|| string.Equals(name, user.GetLegacyNameWithStatus(), StringComparison.OrdinalIgnoreCase);
|
||
|
}
|
||
|
}
|