matt1484 / bl3_auto_vip

Borderlands3 Auto VIP/Shift Code Redemption System
Apache License 2.0
81 stars 19 forks source link

Feature/add single shift code redemption support #25

Closed squatto closed 5 years ago

squatto commented 5 years ago

This PR adds a -shift-code parameter that lets you redeem a single SHIFT code. The reason for this is twofold:

  1. The user can quickly redeem a SHIFT code that has an expiration time (like the latest BL3 codes) without having to wait for someone to add it to the Orcz.com table (case in point, this SHIFT code is 2 hours old, expires in 18 hours, and isn't on Orcz.com yet)
  2. Some SHIFT codes aren't flagged as active in the 2K API response, so even if they are on Orcz.com, they won't be redeemed. See below...

I also added an -allow-inactive option that allows SHIFT codes to be redeemed even if the 2K API response says they are inactive. For example, the SHIFT code from that tweet above is 5ZC3B-WRKHT-Z53CK-BTB33-CB9HA, it is active right now, but the 2K API response is:

{
  "entitlement_offer_codes": [
    // other platforms removed, but all are is_active=false
    {
      "code": "5ZC3B-WRKHT-Z53CK-BTB33-CB9HH",
      "max_redeemable": 1000000,
      "amount_redeemed": 15598,
      "start_date": "2019-10-10T15:00:00.000Z",
      "end_date": "2019-10-11T15:00:00.000Z",
      "offer_title_text": "Golden Key for Borderlands 3",
      "offer_description_text": "Your SHiFT code has been redeemed! Go to your Mail from the in-game Social menu to add the reward to your inventory!",
      "offer_service": "epic",
      "offer_title": "oak",
      "offer_id": 1375,
      "is_active": false
    }
  ]
}

WITHOUT -allow-inactive:

❯ go run cmd/main.go -email a@b.com -password abc123 \
  -shift-code "5ZC3B-WRKHT-Z53CK-BTB33-CB9HH"

Setting up . . . . . success!
Logging in as 'a@b.com' . . . . . success!
Getting SHIFT platforms . . . . . success!
Getting previously redeemed SHIFT codes . . . . . success!
Checking single SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . no available redemption platforms found!
The single SHIFT code could not be redeemed at this time. Try again later.
Exiting in 5 4 3 2 1

WITH -allow-inactive:

❯ go run cmd/main.go -email a@b.com -password abc123 \
  -shift-code "5ZC3B-WRKHT-Z53CK-BTB33-CB9HH" -allow-inactive

Setting up . . . . . success!
Logging in as 'a@b.com' . . . . . success!
Getting SHIFT platforms . . . . . success!
Getting previously redeemed SHIFT codes . . . . . success!
Checking single SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Trying 'steam' SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Trying 'xboxlive' SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Trying 'psn' SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Trying 'epic' SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Trying 'googleplay' SHIFT code '5ZC3B-WRKHT-Z53CK-BTB33-CB9HH' . . . . . success!
Exiting in 5 4 3 2 1

This is my first time modifying a go program, but I tried to follow your coding style and conventions. Feel free to fix anything I messed up ;)

matt1484 commented 5 years ago

Code looks good, wondering though, does the “is_active” issue only affect new limited time codes or has it been an issue with codes already in the list?

squatto commented 5 years ago

Thanks! I'm actually not sure about that. This PR, in combination with #26, addresses that possibility though. I mention it in the PR notes.