campDevs / DiscordBot

Discord bot.
https://glitch.com/edit/#!/carnelian-crayfish
MIT License
73 stars 19 forks source link

Update command fccc #97

Closed ghost closed 6 years ago

ghost commented 6 years ago

fccc

Resolves

Resolves #56

Changes

I had to make a decision about when to make fetch requests to get fcc curriculum data from FCC's Curriculum repo. Fetching this data every time a request is made is not practical. I chose instead that a sane option would be to fetch all the data when the bot starts, as opposed to when the bot installs.

These folders were created to help organize fetch endpoints and response data. githubEndpoints.json was created, because I was unable to automate the process of determining FCC's curriculum structure programmatically.

added src/commands/scrapers/data/fcc/challengeData.json - the response data from fetching githubEndpoints.json

Testing

Manual testing was performed and there appears to be no issues with any of the commands or core bot code.

ghost commented 6 years ago

Updated PR to fix/support the URL link pointing to the challenge's location on learn.freecodecamp.org.

joker314 commented 6 years ago

This is a really good pull request. Briefly scanning through the code, I figure we could replace a few more elements.

Thoughts?

The <img> replacement would have to be done before stripping self-closing tags. In addition, would we want to replace <hr> with a few underscores (or even an image of a horizontal grey line?)

ghost commented 6 years ago

I consider handling img and a tags to be out-of-scope/unnecessary. I have not seen any evidence of img or a tags being used in challenge descriptions. They appear to be used exclusively as content for the built-in editor. When appearing in a description, they are HTML encoded as &lt;...&gt; which then become displayed as html tags.

br, b, strong, and i tags have been handled.

I was unable to successfully convert <hr> to horizontal lines through markdown using this guide - testing ---, - - -, and *** all embedded as those literal strings.

joker314 commented 6 years ago

Alright, could you add

Image tags are being phased out for screen readers. Links, however, remind me of another thing (perhaps out of scope of this PR, but possibly for a follow-up), I believe at the footer of challenges is a list of links to helpful resources. This could be added to the search functionality?


Also, would it be useful to add a url parameter to the embed. This makes the title clickable, and will open up the challenge page?

ghost commented 6 years ago

v2 added back in support for URL clickable titles that send users to the FCC challenge page. It's possible that some challenges do have links in the description, but not all - perhaps a good follow-up issue if needed.

Other changes made as requested. Thanks for the feedback 👍

ghost commented 6 years ago

I should have acknowledged the intent behind the question of the trailing white space, and that is to remove all trailing white space from files I've been working in. Trailing white space has been removed from src/bot.js and src/commands/scrapers/FCCCommand.js in v5.

ghost commented 6 years ago

squashed 5 commits into 1