1. luastoned
  2. Facepunch Lua API

Commits

luastoned  committed c882208

Added member.userID

  • Participants
  • Parent commits fa8bd15
  • Branches default

Comments (0)

Files changed (3)

File facepunch/member.lua

View file
  • Ignore whitespace
 
 -------------------------------------------------------------------------------
 -- member.searchUser()
--- Purpose: Searchs for users with the given string in their name, returns 0
+-- Purpose: Searches for users with the given string in their name, returns 0
 --			then a table of the usernames if successful, otherwise 1 and nil
 -- Input: name - partial or full string of user, must be at least 3 characters
---		  long to receive results
+--				 long to receive results
 --		  session - option session object
 --		  securityToken - security token for making the request
 -- Output: error code, table of usernames
 -------------------------------------------------------------------------------
 function new()
 	local t = {
+		userID = nil,
 		username = nil,
 		online = nil,
 		usergroup = nil,

File facepunch/thread.lua

View file
  • Ignore whitespace
 --			each part of the pattern represents
 -------------------------------------------------------------------------------
 threadPageMemberPattern = "" ..
+-- User ID
+"username_container.-href=\"members/(%d+)" ..
 -- Username
-"username_container.-href=\"members/.- title=\"(.-) is " ..
+".-title=\"(.-) is " ..
 -- Online Status
 "(.-)line" ..
 -- Displayed Username
 function getMembersInPage( threadPage )
 	local t = {}
 	local matched = false
-	for username,
+	for userID,
+		username,
 		status,
 		displayedUsername,
 		usertitle,
 		end
 		if ( not matched ) then
 			local member			= member()
+			member.userID			= userID
 			member.username			= username
 			member.online			= status == "on"
 			if ( username == displayedUsername ) then

File test/getMembersInPage.lua

View file
  • Ignore whitespace
 local members = thread.getMembersInPage( threadPage )
 for _, member in pairs( members ) do
 	print( member )
+	print( "\tuser id: " .. tostring( member.userID ) )
 	print( "\tonline: " .. tostring( member.online ) )
 	print( "\tusergroup: " .. tostring( member.usergroup ) )
 	print( "\tusertitle: " .. tostring( member.usertitle ) )