Skip to content
/ HQT Public

πŸ† A tool built in Node.js to try and help you solve those difficult HQ Trivia questions!

License

Notifications You must be signed in to change notification settings

metacurb/HQT

Repository files navigation

HQT

Attempt to find the answer most likely to be correct from a question given on HQ Trivia. It will attempt to utilise various APIs, and create a "score" based on the results.

How it works

Connecting to the HQ Trivia API, we are able to see when a broadcast will be taking place. If the bot finds a websocketUrl available, it will create a new session, and begin monitoring that data. If a question is passed through, it will then clean the question and answers, and use third party services to try and find results.

Scoring (To be implemented)

A scoring system will be used to determine how likely that any one of the answers is the correct one. This won't be full-proof, but will hopefully give a better indicator of a correct answer. Below is a summary of how each part of the system works. This will need to be updated as time goes on. Numbers will need to be updated to try and give the best representational score possible.

Resource Scoring type Weight
Google Search no. of results 20%
Google Search Number of "hits" 40%
Wikipedia Number of "hits" 40%

Google

Using Google's custom search engine REST API, we are able to return a list of results based upon a query. This gives us important data that we can validate our question against. We will take:

  • The number of results
  • The number of "hits" returned, checking each relevant word in the question against the descriptions from the results.

We can that use that information and compare it to each answer, creating a score.

Wikipedia

Similarly to Google, we will use Wikipedia's API to search for each answer. Using the question, we will check for "hits" matching relevant words.

Setup

Prerequisites

  1. Google Custom Search
  2. Google Custom Search API key

Code

  1. git clone the repository
  2. cd hqt
  3. touch .env, and in that file enter:
    • GOOGLE_KEY - Your Google Custom Search API Key
    • GOOGLE_ENGINE_ID - Your Google Custom Search Engine ID
    • BEARER_TOKEN - Your bearer token retrieved from the HQ Trivia API
  4. npm install
  5. npm run start

Structure

HQT
β”‚   README.md
β”‚   package.json
β”‚   package-lock.json
β”‚   .gitignore                // Files we don't want to commit to the repo
β”‚   .babelrc                  // Babel configuration
β”‚   .eslintrc.json            // ESLint configuration
β”‚
└───data
β”‚   └───questions.json        // Questions recieved through the open websocket connection
β”‚
└───dist                      // Transpiled code will end up here 
β”‚
└───examples
β”‚   β”‚   api-data.json         // Example data directly from the API, when a broadcast is in progress
β”‚   β”‚   curl.txt              // Example curl request to the API
β”‚   └───websocket-data.json   // Example websocket data from the broadcast
β”‚
└───src
    β”‚   init.js               // Initialiser script
    β”‚
    └───helpers
    β”‚   β”‚   index.js
    β”‚   β”‚   formatNumber.js   // Parse floats and turn them into integers
    β”‚   └───getHits.js        // Find the number of matches an array of words has in a text
    β”‚
    └───log
    β”‚   β”‚   index.js
    β”‚   β”‚   success.js        // console.log success formatting
    β”‚   β”‚   warn.js           // console.log warn formatting
    β”‚   β”‚   error.js          // console.log error formatting
    β”‚   └───reset.js          // Clear the console
    β”‚
    └───reader
    β”‚   β”‚   index.js
    β”‚   β”‚   scan.js           // Read image, and grab text from it
    β”‚   β”‚   wordlist.js       // List of words to strip out of a question
    β”‚   └───parse.js          // Prepare text for search using resolvers
    β”‚
    └───resolvers
        β”‚   index.js
        β”‚   wikipedia.js      // Results returned from Wikipedia's API
        └───google.js         // Results returned from Googles search API

Resources/APIs

Examples/Inspiration

About

πŸ† A tool built in Node.js to try and help you solve those difficult HQ Trivia questions!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published