Implement basic workshop community functionality
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 and CCommunityComment 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-nullon success, anErrorobject on failureitems- an array ofCWorkshopItemobjects
CWorkshopItem
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-nullon success, anErrorobject on failure
getComments([max, ]callback)
Gets the comments for the item, optionally with a maximum number to fetch
callback- Called when the comments have been retrievederr-nullon success, anErrorobject on failurecomments- an array ofCCommunityCommentobjects
CCommunityComment
submitter
A SteamID object representing the submitter of the comment
content
The body of the comment, as plain HTML.
time
A Date object representing the time the comment was submitted
delete(callback)
Deletes the comment.
callback- Called when the comment has been deletederr-nullon success, anErrorobject on failure