Giter Site home page Giter Site logo

metacurb / hqt Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 3.0 15.65 MB

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

License: MIT License

JavaScript 100.00%
hqtrivia hqtriviahack hq trivia hq-trivia-bot hq-trivia-hack

hqt's Introduction

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

hqt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hqt's Issues

Bearer_token help!

How do you get the bearer token retrieved from the HQ Trivia API? Do you need to get this before every game or is it the same for each game? Add me on discord if you want to chat there Cheesy #8556. Thanks

2 Issues - Need help.

Currently I am having two issues:

  1. I am trying to do touch .env in terminal but no file is created (I am in the HQT file)
  1. When entering the Bearer Token do we include "Bearer" or just enter the letters and numbers, all one line?

Using macOS High Sierra.

Any help much appreciated. Thank you for creating this project

Bro I need ur help in One of my node.js project

First of all thanks for reading this out

Bro i need ur help in one of my node.js script which is usually based on HQ Trivia Googling answer but its not working now i dont know why!
Could you help me out!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.