Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic workshop community functionality #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

birjj
Copy link

@birjj birjj commented Nov 14, 2019

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 retrieved
    • err - null on success, an Error object on failure
    • items - an array of CWorkshopItem objects

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 retrieved
    • err - null on success, an Error object 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 retrieved
    • err - null on success, an Error object on failure
    • comments - an array of CCommunityComment objects

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 deleted
    • err - null on success, an Error object on failure

Implements CWorkshopItem and CCommunityComment
Currently only supports getting a users items, getting its basic information, and getting its comments. The comments can be read and deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant