Skip to content

Commit f9e1f0e

Browse files
author
Mostey
committed
Added Friends property in the user class and implemented parsing of the user friend count
1 parent 4075ea4 commit f9e1f0e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/epvpapi/Evaluation/UserParser.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,26 @@ public void Execute(HtmlNode coreNode)
134134
}
135135
}
136136

137+
internal class FriendListParser : TargetableParser<User>, INodeParser
138+
{
139+
public FriendListParser(User target) :
140+
base(target)
141+
{ }
142+
143+
public void Execute(HtmlNode coreNode)
144+
{
145+
if (coreNode == null) return;
146+
147+
var friendCountNode = coreNode.SelectSingleNode("../div[1]");
148+
if (friendCountNode != null)
149+
{
150+
var match = Regex.Match(friendCountNode.InnerText, @"Showing [0-9]+ of ([0-9]+) Friend\(s\)");
151+
if (match.Groups.Count > 1)
152+
Target.Friends = match.Groups[1].Value.To<double>().To<uint>();
153+
}
154+
}
155+
}
156+
137157

138158
internal class LastActivityParser : TargetableParser<User>, INodeParser
139159
{
@@ -380,6 +400,7 @@ public void Execute(HtmlDocument document)
380400
new StatisticsParser(Target, IsSessionUser).Execute(document.GetElementbyId("collapseobj_stats"));
381401
new MiniStatsParser(Target).Execute(document.GetElementbyId("collapseobj_stats_mini"));
382402
new LastVisitorsParser(Target).Execute(document.GetElementbyId("collapseobj_visitors"));
403+
new FriendListParser(Target).Execute(document.GetElementbyId("friends_list"));
383404
}
384405
}
385406
}

src/epvpapi/User.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ public enum Status
370370
/// </summary>
371371
public Content Signature { get; set; }
372372

373+
/// <summary>
374+
/// Amount of friends the user has added
375+
/// </summary>
376+
public uint Friends { get; set; }
377+
373378

374379
public User(uint id = 0)
375380
: this(null, id)

0 commit comments

Comments
 (0)