diff --git a/.env.template b/.env.template index e64fede..b277fa9 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,14 @@ +# GitHub Personal Access Token (optional but recommended) +# Without a token, you may hit GitHub's rate limits (60 requests/hour) +# With a token, you get 5,000 requests/hour +# Generate at: https://github.com/settings/tokens +# Requires 'gist' scope to read gists +GITHUB_TOKEN=your_github_token_here + +# ASF Configuration (optional) ASF_PORT=1242 ASF_HOST=localhost ASF_PASSWORD=hunter2 ASF_COMMAND_PREFIX=! ASF_HTTPS=false -ASF_BOTS=asf #https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#bots-argument +ASF_BOTS=asf # https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#bots-argument diff --git a/README.md b/README.md index b855c4f..9e0de80 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,31 @@ Latest games claimed: https://gist.github.com/C4illin/77a4bcb9a9a7a95e5f291badc9 3. `git clone https://github.com/C4illin/ASFclaim.git` 4. `cd ASFclaim` 5. `npm install` +6. **(Optional but recommended)** Create a GitHub Personal Access Token to avoid rate limits: + - Go to https://github.com/settings/tokens + - Click "Generate new token" → "Generate new token (classic)" + - Give it a name like "ASFclaim" + - Select the `gist` scope (required to read gists) + - Copy the generated token + - Create a `.env` file with your GitHub token: + ``` + GITHUB_TOKEN=your_github_token_here + ``` + - **Rate limits**: Without token: 60 requests/hour | With token: 5,000 requests/hour ## Run 1. Make sure ASF is running 2. `node .` -The program checks available licenses every 6 hours. +The program checks available licenses every 6 hours. ### Docker ```bash -docker run --name asfclaim -e ASF_PORT=1242 -e ASF_HOST=localhost -e ASF_HTTPS=false -e ASF_PASSWORD=hunter2 -e ASF_COMMAND_PREFIX=! -e ASF_BOTS=asf ghcr.io/c4illin/asfclaim:master +# With GitHub token (recommended): +docker run --name asfclaim -e GITHUB_TOKEN=your_github_token_here -e ASF_PORT=1242 -e ASF_HOST=localhost -e ASF_HTTPS=false -e ASF_PASSWORD=hunter2 -e ASF_COMMAND_PREFIX=! -e ASF_BOTS=asf ghcr.io/c4illin/asfclaim:master + +# Without GitHub token (may hit rate limits): +docker run --name asfclaim -e ASF_PORT=1242 -e ASF_HOST=localhost -e ASF_HTTPS=false -e ASF_PASSWORD=hunter2 -e ASF_COMMAND_PREFIX=! -e ASF_BOTS=asf ghcr.io/c4illin/asfclaim:master ``` #### Docker-compose: ```yml @@ -36,7 +51,9 @@ services: container_name: asfclaim restart: unless-stopped depends_on: asf # remove this if asf is not running in docker - environment: # all are optional, defaults are listed below + environment: + - GITHUB_TOKEN=${GITHUB_TOKEN} # optional but recommended - prevents rate limiting + # all below are optional, defaults are listed - ASF_PORT=1242 - ASF_HOST=localhost - ASF_PASSWORD= @@ -64,6 +81,6 @@ https://github.com/specu/ASFclaim.py Python rewrite without any dependencies https://github.com/JourneyDocker/ASFclaim fork with different gist and discord notifications Instead of forking it, please consider sending a PR so we can make the best solution together! - + ## Stargazers over time [![Stargazers over time](https://starchart.cc/C4illin/ASFclaim.svg?variant=adaptive)](https://starchart.cc/C4illin/ASFclaim) diff --git a/docker-compose.yml b/docker-compose.yml index 4937fc2..21b62c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: asf-claim: build: . # environment: + # - GITHUB_TOKEN=${GITHUB_TOKEN} # optional: prevents rate limiting # - ASF_PORT=1242 # - ASF_HOST=localhost # - ASF_PASSWORD=hunter2 diff --git a/index.js b/index.js index 4f499c0..b750a2e 100644 --- a/index.js +++ b/index.js @@ -2,9 +2,18 @@ import fetch from "node-fetch"; import { readFile, writeFileSync } from "node:fs"; import { Octokit } from "@octokit/rest"; import * as dotenv from "dotenv"; -const octokit = new Octokit(); dotenv.config(); +const githubToken = process.env.GITHUB_TOKEN; +const octokit = new Octokit(githubToken ? { auth: githubToken } : {}); + +if (githubToken) { + console.log("GitHub token provided - using authenticated requests (5000/hour rate limit)"); +} else { + console.log("No GitHub token provided - using unauthenticated requests (60/hour rate limit)"); + console.log("Consider setting GITHUB_TOKEN environment variable to avoid rate limits"); +} + const asfport = process.env.ASF_PORT || "1242"; const asfhost = process.env.ASF_HOST || "localhost"; const password = process.env.ASF_PASSWORD || "";