Cleaned up mention logic, removed User.NicknameMention

This commit is contained in:
RogueException
2016-07-19 15:53:17 -03:00
parent f2df627e41
commit 53e1c79848
7 changed files with 14 additions and 25 deletions

View File

@@ -15,7 +15,6 @@
public static bool HasStringPrefix(this IMessage msg, string str, ref int argPos)
{
var text = msg.Content;
//str = str + ' ';
if (text.StartsWith(str))
{
argPos = str.Length;
@@ -26,19 +25,14 @@
public static bool HasMentionPrefix(this IMessage msg, IUser user, ref int argPos)
{
var text = msg.Content;
string mention = user.Mention + ' ';
if (text.StartsWith(mention))
{
argPos = mention.Length;
return true;
}
string nickMention = user.NicknameMention + ' ';
if (text.StartsWith(mention))
{
argPos = nickMention.Length;
return true;
}
return false;
if (text.Length <= 3 || text[0] != '<' || text[1] != '@') return false;
int endPos = text.IndexOf('>');
if (endPos == -1) return false;
ulong userId;
if (!MentionUtils.TryParseUser(text.Substring(0, endPos), out userId)) return false;
return userId == user.Id;
}
}
}