Code Monkey home page Code Monkey logo

hqtrivia's Introduction

Welcome to HackQ for Swift (MacOS)

alt text

Features:

  • Gets questions directly from the HQ WebSocket, no need to do OCR
  • Solves them using a search method created by Daniel Smith
  • Clean, friendly, and simple UI

How to use:

  • Download the repo/clone it
  • Enter in your info (Bearer token, user id, Google API key, Google CSE ID) [you have to fill in the info in ViewController.swift and SiteEncoding.swift]
  • Run a pod install to make sure everything is up to date
  • Run the project... if you start it before the game is live, it won't connect because the socket url isn't available, so once the game is live, click the "HackQ" label at the top of the window (or you can just wait until the countdown starts to launch it)

Some info to use for authorization for the WebSocket:

  • HQ reset Bearer tokens so you gotta use your own

Fill in info in lines 31, 50, 57 at the end of the link, and 83 of ViewController.swift and lines 13, and 14 in SiteEncoding.swift

How it works:

  • Uses Alamofire to make a request to the host
  • Once the game is live, the "socketUrl" becomes available under the "broadcast" structure
  • A socket is opened with SwiftWebSocket, using all required headers
  • When a message is received, it is checked if it is a question then it parses the answers and sets the labels as their string value then solves (chat messages come through with the socket too, so this is why you have to check the type)

Requirements (CocoaPods):

  • Alamofire (for HTTPS requests, to find the socketUrl which changes each broadcast)
  • SwiftyJSON (for easy JSON parsing)
  • SwiftWebSocket (for opening the WebSocket that gets questions and answers, with authorization and other headers)
  • KeychainSwift (for the API key/CSE ID)

Support:

  • If you need any help, open an issue, I will try to help

Disclaimer:

  • This is meant for educational use only, I do not advise you to use this in an actual HQ game because it is against their terms of service

TODO:

Credits:

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.