Skip to content

Commit

Permalink
feat!: separate out config from driver (#47)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The config to set your restaurant sniping preferences now lives in a separate file
  • Loading branch information
Alkaar authored Sep 23, 2022
1 parent debac2b commit 8cbeb27
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ snipe a reservation. It will attempt to grab a reservation for a couple of secon
it was or wasn't successful in getting a reservation.

## Usage
You need to provide a few values before running the bot. These values are located in the `ResyBookingBot` object at
the top. There are comments above the variables with what needs to be provided before it can be used, but I'll list it
You need to provide a few values before running the bot. These values are located in the `ResyConfig` object. There
are comments above the variables with what needs to be provided before it can be used, but I'll list it
here as well for clarity.
* **apiKey** - Your user profile API key. Can be found when logging into Resy if you have the web console open in your
headers called `authorization`.
Expand All @@ -35,15 +35,15 @@ allows full flexibility on your reservation preferences. For example, your prior
* **minute** - Minute of the day when reservations become available and when you want to snipe

## How it works
The main entry point of the bot is in the `ResyBookingBot` object under the `main` function. The bot runs based on the
local time of the machine it's running on. Upon running the bot, it will automatically sleep until the specified time.
At the specified time, it will wake up and attempt to query for reservations for 10 seconds. This is because sometimes
reservations are not available exactly at the same time every day so 10 seconds is to allow for some buffer. Once
reservation times are retrieved, it will try to find the best available time slot given your priority list of
reservation times. If a time can't be booked, the bot will shutdown here. If a time can be booked, it will make an
attempt to snipe it. If a reservation couldn't be booked, and it's still within 10 seconds of the original start time,
it will restart the whole workflow and try to find another available reservation. In the event it was unable to get any
reservations, the bot will automatically shutdown.
The main entry point of the bot is in the `ResyBookingBot` object under the `main` function. It utilizes the arguments
which you need to provide under the `ResyConfig` object. The bot runs based on the local time of the machine it's
running on. Upon running the bot, it will automatically sleep until the specified time. At the specified time, it will
wake up and attempt to query for reservations for 10 seconds. This is because sometimes reservations are not available
exactly at the same time every day so 10 seconds is to allow for some buffer. Once reservation times are retrieved, it
will try to find the best available time slot given your priority list of reservation times. If a time can't be booked,
the bot will shutdown here. If a time can be booked, it will make an attempt to snipe it. If a reservation couldn't be
booked, and it's still within 10 seconds of the original start time, it will restart the whole workflow and try to find
another available reservation. In the event it was unable to get any reservations, the bot will automatically shutdown.

## Running the bot
There are a multitude of ways to run it, but I'll share the two most
Expand Down
29 changes: 1 addition & 28 deletions src/main/scala/com/resy/ResyBookingBot.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.resy

import akka.actor.ActorSystem
import com.resy.ResyConfig._
import org.apache.logging.log4j.scala.Logging
import org.joda.time.DateTime

Expand All @@ -10,34 +11,6 @@ import scala.language.postfixOps

object ResyBookingBot extends Logging {

private val resyKeys = ResyKeys(
// Your user profile API key which can be found via your browser web console in your headers
// called "authorization"
apiKey = ???,
// Your user profile authentication token which can be found via your browser web console in
// your headers called "x-resy-auth-token"
authToken = ???
)

private val resDetails = ReservationDetails(
// Date of the reservation in YYYY-MM-DD format
date = ???,
// Size of the party reservation
partySize = ???,
// Unique identifier of the restaurant where you want to make the reservation
venueId = ???,
// Priority list of reservation times and table types. Time is in military time HH:MM:SS format.
// If no preference on table type, then simply don't set it.
resTimeTypes = ???
)

private val snipeTime = SnipeTime(
// Hour of the day when reservations become available and when you want to snipe
hours = ???,
// Minute of the day when reservations become available and when you want to snipe
minutes = ???
)

def main(args: Array[String]): Unit = {
logger.info("Starting Resy Booking Bot")

Expand Down
32 changes: 32 additions & 0 deletions src/main/scala/com/resy/ResyConfig.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.resy

object ResyConfig {

val resyKeys: ResyKeys = ResyKeys(
// Your user profile API key which can be found via your browser web console in your headers
// called "authorization"
apiKey = ???,
// Your user profile authentication token which can be found via your browser web console in
// your headers called "x-resy-auth-token"
authToken = ???
)

val resDetails: ReservationDetails = ReservationDetails(
// Date of the reservation in YYYY-MM-DD format
date = ???,
// Size of the party reservation
partySize = ???,
// Unique identifier of the restaurant where you want to make the reservation
venueId = ???,
// Priority list of reservation times and table types. Time is in military time HH:MM:SS format.
// If no preference on table type, then simply don't set it.
resTimeTypes = ???
)

val snipeTime: SnipeTime = SnipeTime(
// Hour of the day when reservations become available and when you want to snipe
hours = ???,
// Minute of the day when reservations become available and when you want to snipe
minutes = ???
)
}

0 comments on commit 8cbeb27

Please sign in to comment.