GithubHelp home page GithubHelp logo

andrew-tierno / tockstalk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azoff/tockstalk

0.0 0.0 0.0 76 KB

Cypress bot to book restaurants on Tock and optionally report attempts to slack

License: MIT License

JavaScript 28.05% TypeScript 71.95%

tockstalk's Introduction

tockstalk

A Cypress bot to book restaurants on Tock and optionally report attempts to Slack.

image

Prerequisites

Ensure your computer has node and npm installed. You can use nodenv if you don't. Once installed, use npm install to pull down the dependencies for the project. Before you can run the bot, you'll also need to configure it. Read on to the next section for how to do that.

Configuration

If you don't already have an account on Tock, make one. Once you've created your account, take note of your credentials as you'll need them in a bit. Next, navigate to your account billing page and ensure you have a credit card on file. Take note of the CVV number for the card.

image

Next go find the restaurant you'd like to book, and grab the path for the booking page. In the example above, that would be:

/otiumgrillandgreens/experience/330688/reservation

Last but not least, if you want to use Slack, create an incoming webhook for your Slack account. This will be the endpoint the runner uses to send notifications to the slack room of your choice.

With all this in-hand, you can create your configuration file. There's an example in the repo you can start with, though you'll need to create a real one named cypress.env.json in the project root:

cp cypress.env.example.json cypress.env.json
open cypress.env.json

The fields are all pretty self explanatory, though you can use dryRun to avoid actually booking if you just want to test the whole thing out. The only optional fields are those related to slack*, which you can omit if you don't want to send notifications to slack.

Scheduling

image

A lot of restaurants set their next month's schedule on a particular day and time. You can use github actions to schedule jobs on a cron and try to snag a spot as things open up. The example in this repo attempts bookings every 15 minutes. You can fork the repo and try it out yourself. Just be sure to set a secret CYPRESS_ENV with the above JSON so that the action will run.

Bot Detection

Tock uses Cloudflare's bot detection system, Turnstile, to prevent automated access to their site. Thankfully, Cypress is pretty good about presenting itself as a human. The only times it runs into issues is when Cypress runs in "studio" mode, which unfortunately is the default mode for developers using Cypress (i.e. cypress open).

The underlying issue is that Cypress studio runs its end to end tests in an iframe, which Turnstile immediately flags as a bot. To avoid this, the bot is set up to run in a frameless mode (i.e. cypress run), but can still run in "headed" mode for local development. In the end, this change to the normal working style of Cypress is a small price to pay for the convenience of automated booking.

tockstalk's People

Contributors

azoff avatar

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.