Implement basic workshop community functionality #238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I needed some basic interaction with the workshop for a spam cleaner I'm developing, and figured you might be interested in merging upstream. If not, no biggie.
Implements the ability to get a list of a users workshop items, and a list of comments on a given workshop item. Uses the two new classes
CWorkshopItem
andCCommunityComment
to represent the data structures.I unfortunately couldn't find any web APIs for this, so all of it is done through parsing the website.
The following APIs have been added:
SteamCommunity
getWorkshopItems([userID, ]callback)
userID
- The user to get workshop items for. If not set, uses the currently logged in user. Can be SteamID or string.callback
- Called when the items have been retrievederr
-null
on success, anError
object on failureitems
- an array ofCWorkshopItem
objectsCWorkshopItem
title
The title of the item.
null
until.fetchInformation()
is called.description
The description of the item, as plain HTML.
null
until.fetchInformation()
is called.creators
An array of
SteamID
objects representing the creators of the item.null
until.fetchInformation()
is called.numRatings
Number of ratings of the item.
null
until.fetchInformation()
is called.numComments
Number of comments on the item.
null
until.fetchInformation()
is called.fetchInformation(callback)
Fetches information about the workshop from its web page. After the callback is called, the information is available on the
CWorkshopItem
instance.callback
- Called when the information has been retrievederr
-null
on success, anError
object on failuregetComments([max, ]callback)
Gets the comments for the item, optionally with a maximum number to fetch
callback
- Called when the comments have been retrievederr
-null
on success, anError
object on failurecomments
- an array ofCCommunityComment
objectsCCommunityComment
submitter
A
SteamID
object representing the submitter of the commentcontent
The body of the comment, as plain HTML.
time
A
Date
object representing the time the comment was submitteddelete(callback)
Deletes the comment.
callback
- Called when the comment has been deletederr
-null
on success, anError
object on failure