-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add discussions support #319
base: v4
Are you sure you want to change the base?
Conversation
Oh and while we are at it, I think I mixed both of these a bit. |
You prob want to merge it into #230 |
Yeah I thought about that but ultimately decided against it as DoctorMcKay merged my previous PRs into v4 afterwards anyway and the v4 branch seems a bit stale. |
I'm cool with scraping discussions to retrieve data, but posting threads and comments isn't something I'm comfortable with adding due to the potential for abuse/spam. I'm aware that it's not really difficult for spammers to post spam on their own without the help of the lib, but still. I like to try to maintain at least some plausible deniability for enabling bad people to do bad things. Also, if you're going to target v4 (which seems appropriate), please make sure you're addressing the new lint rules. There are also a bunch of other changes, for example the removal of |
Valve wouldn't know it came from your library, though. Still, you can combat it somewhat by implementing some guards that align with the steam discussion rules, like a blocklist and URL detection. Let's be real, anything can be abused, I hate to see a feature gone just because of theoretical bad actors. |
I can understand leaving out voting in the sharedfile PR from a while ago but when the lib already supports posting comments to profiles, groups and sharedfiles then I don't really see where posting comments to discussions is much different.
Yeah, I saw the check yesterday and wanted to address those today |
…void unhandled exceptions
I have fixed all eslint errors/warnings. The check is still failing because of other files not relevant to this PR. Edit: I have also renamed the class method |
Sounds good, I should probably try to fix all those errors in the v4 branch shortly.
It's not final yet, but I think the helper is going to take care of all this like it did previously, and reject in cases where it would return an error previously. Is this ready for review? |
Yeah, I think it is ready for review. |
I've added support for eventcomments too, this is another type of discussion, usually used to post patch notes or make event announcements. I have also noticed that testing the changes made in this PR just by checking out this branch does not work because it was rebased, and therefore |
Hey!
This PR adds support for scraping information and comments from discussions, as well as posting & deleting comments, subscribing & unsubscribing to/from discussions and setting the amount of comments shown per page.
I have added a new class which represents an existing discussion supplied via URL and scrapes various information from the DOM:
id
(string) - ID of the discussion, is used in the URLtype
(EDiscussionType) - Where the discussion is associated to (app, group or the Steam forum)appID
(string) - The appID this discussion is associated to, if of type EDiscussionType.AppforumID
(string) - ID of the forum the discussion is in, is used in the URLgidforum
(string) - ID used in post requests when interacting with discussions, not sure whytopicOwner
(string) - ID used in post requests when interacting with discussions, not sure whyauthor
(SteamID) - SteamID object of the author of this discussionpostedDate
(Date) - When this discussion was createdtitle
(string) - Title of the discussioncontent
(string) - Content of the discussioncommentsAmount
(number) - Amount of comments present in this discussionanswerCommentIndex
(number) - If this discussion has an answer, this is the index of the commentThe functions already mentioned above are implemented in
components/discussions.js
.Beside the usual functions for commenting and subscribing, it includes another scraper for retrieving a range of comments. Each comment includes the following information:
index
(number) - Index of this comment in the comment chain of this discussioncommentId
(number) - ID of this comment, issued by SteamcommentLink
(string) - Link to this specific comment, will highlight itauthorLink
(string) - Profile link of the author of this comment. I did not convert this one to a SteamID to reduce the large amount of extra requests needed to resolve each author link when requesting a large-ish rangepostedDate
(Date) - When this comment was postedcontent
(string) - Content of all comments quoted in this comment and the comment itselfI have not added support for posting discussions as a class only represents one discussion, not a forum.
Test code to get 3 comments from the provided discussion and see the nested quotes support:
Note: I have encountered an error with the scraper yesterday at discussion.js line 39 getting children of undefined, which I was sadly unable to reproduce again. I just wanna note that the scraper might not be completely failsafe, this is however the same case with the other scrapers as well. If I find any bugs I'll ofc look into fixing them and open another PR, just like previously.
Thanks for reading and I hope you find this feature useful.
Feel free to use the text from this PR in any documentation page if you wish.
Have a nice day :)