From f795265284ed8122283ef17329c200ded6d9a345 Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:15:24 +1000 Subject: [PATCH 1/7] Add github token support --- .env.template | 10 ++++++++-- README.md | 28 ++++++++++++++++++++-------- docker-compose.yml | 3 ++- index.js | 6 +++++- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.env.template b/.env.template index e64fede..b5c99ed 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,12 @@ +# GitHub Personal Access Token (required) +# 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_PASSWORD= ASF_COMMAND_PREFIX=! ASF_HTTPS=false -ASF_BOTS=asf #https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#bots-argument +ASF_BOTS=asf diff --git a/README.md b/README.md index b855c4f..778a298 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,30 @@ Latest games claimed: https://gist.github.com/C4illin/77a4bcb9a9a7a95e5f291badc9 ## Install 1. enable IPC in ASF (https://github.com/JustArchiNET/ArchiSteamFarm/wiki/IPC), by default it is enabled (also add password to .env if not empty) -2. install node.js (v18 or later) -3. `git clone https://github.com/C4illin/ASFclaim.git` -4. `cd ASFclaim` -5. `npm install` +2. Create a GitHub Personal Access Token: + - 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 +3. install node.js (v18 or later) +4. `git clone https://github.com/C4illin/ASFclaim.git` +5. `cd ASFclaim` +6. `npm install` +7. Create a `.env` file with your GitHub token: + ``` + GITHUB_TOKEN=your_github_token_here + ``` ## 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 +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 ``` #### Docker-compose: ```yml @@ -36,7 +46,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} # required - get from https://github.com/settings/tokens + # all below are optional, defaults are listed - ASF_PORT=1242 - ASF_HOST=localhost - ASF_PASSWORD= @@ -64,6 +76,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..477fee3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,8 @@ version: "3" services: asf-claim: build: . - # environment: + environment: + - GITHUB_TOKEN=${GITHUB_TOKEN} # - ASF_PORT=1242 # - ASF_HOST=localhost # - ASF_PASSWORD=hunter2 diff --git a/index.js b/index.js index 4f499c0..d567239 100644 --- a/index.js +++ b/index.js @@ -2,9 +2,13 @@ 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({ + auth: githubToken, +}); + const asfport = process.env.ASF_PORT || "1242"; const asfhost = process.env.ASF_HOST || "localhost"; const password = process.env.ASF_PASSWORD || ""; From 24bfd0cf9b58bff3ab31f36007e71d79e4b2bd3f Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:17:21 +1000 Subject: [PATCH 2/7] push --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d567239..587ce25 100644 --- a/index.js +++ b/index.js @@ -53,9 +53,8 @@ function checkGame() { asfcommand = asfcommand.slice(0, -1); const command = { Command: asfcommand }; - const url = `http${ - asfhttps ? "s" : "" - }://${asfhost}:${asfport}/Api/Command`; + const url = `http${asfhttps ? "s" : "" + }://${asfhost}:${asfport}/Api/Command`; const headers = { "Content-Type": "application/json" }; if (password && password.length > 0) { headers.Authentication = password; From 8e930d00e74e25bbaf5d99bc486a2701be36de9d Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:30:50 +1000 Subject: [PATCH 3/7] Allow github token to be optional --- .env.template | 4 +++- docker-compose.yml | 2 +- index.js | 16 +++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.env.template b/.env.template index b5c99ed..d3fa148 100644 --- a/.env.template +++ b/.env.template @@ -1,4 +1,6 @@ -# GitHub Personal Access Token (required) +# 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 diff --git a/docker-compose.yml b/docker-compose.yml index 477fee3..b624c95 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: asf-claim: build: . environment: - - GITHUB_TOKEN=${GITHUB_TOKEN} + # - 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 587ce25..e93c721 100644 --- a/index.js +++ b/index.js @@ -5,9 +5,14 @@ import * as dotenv from "dotenv"; dotenv.config(); const githubToken = process.env.GITHUB_TOKEN; -const octokit = new Octokit({ - auth: githubToken, -}); +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"; @@ -53,8 +58,9 @@ function checkGame() { asfcommand = asfcommand.slice(0, -1); const command = { Command: asfcommand }; - const url = `http${asfhttps ? "s" : "" - }://${asfhost}:${asfport}/Api/Command`; + const url = `http${ + asfhttps ? "s" : "" + }://${asfhost}:${asfport}/Api/Command`; const headers = { "Content-Type": "application/json" }; if (password && password.length > 0) { headers.Authentication = password; From ea0c5cb696fb6ebe309b1ed62fd3a6bc60b451e8 Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:39:21 +1000 Subject: [PATCH 4/7] Update readme --- .env.template | 2 +- README.md | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.env.template b/.env.template index d3fa148..5f0c13f 100644 --- a/.env.template +++ b/.env.template @@ -11,4 +11,4 @@ ASF_HOST=localhost ASF_PASSWORD= ASF_COMMAND_PREFIX=! ASF_HTTPS=false -ASF_BOTS=asf +ASF_BOTS=asf # https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#bots-argument diff --git a/README.md b/README.md index 778a298..9e0de80 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,21 @@ Latest games claimed: https://gist.github.com/C4illin/77a4bcb9a9a7a95e5f291badc9 ## Install 1. enable IPC in ASF (https://github.com/JustArchiNET/ArchiSteamFarm/wiki/IPC), by default it is enabled (also add password to .env if not empty) -2. Create a GitHub Personal Access Token: +2. install node.js (v18 or later) +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 -3. install node.js (v18 or later) -4. `git clone https://github.com/C4illin/ASFclaim.git` -5. `cd ASFclaim` -6. `npm install` -7. Create a `.env` file with your GitHub token: - ``` - GITHUB_TOKEN=your_github_token_here - ``` + - 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 @@ -34,7 +35,11 @@ The program checks available licenses every 6 hours. ### Docker ```bash +# 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 @@ -47,7 +52,7 @@ services: restart: unless-stopped depends_on: asf # remove this if asf is not running in docker environment: - - GITHUB_TOKEN=${GITHUB_TOKEN} # required - get from https://github.com/settings/tokens + - GITHUB_TOKEN=${GITHUB_TOKEN} # optional but recommended - prevents rate limiting # all below are optional, defaults are listed - ASF_PORT=1242 - ASF_HOST=localhost From 76cd8e289ff0a289d533396e15d7d1ab459d99d4 Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:39:46 +1000 Subject: [PATCH 5/7] restore ASF_PASSWORD --- .env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.template b/.env.template index 5f0c13f..b277fa9 100644 --- a/.env.template +++ b/.env.template @@ -8,7 +8,7 @@ GITHUB_TOKEN=your_github_token_here # ASF Configuration (optional) ASF_PORT=1242 ASF_HOST=localhost -ASF_PASSWORD= +ASF_PASSWORD=hunter2 ASF_COMMAND_PREFIX=! ASF_HTTPS=false ASF_BOTS=asf # https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#bots-argument From ae9cd864f3f80fefeecfb94a47c4b1336b1ac918 Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:40:50 +1000 Subject: [PATCH 6/7] remove emojis from copilot --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e93c721..b750a2e 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,10 @@ 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)"); + 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"); + 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"; From 59465792468d4a82b75ce6b8cdc0410a8e4efb42 Mon Sep 17 00:00:00 2001 From: Cory Manson <5052021+CoryManson@users.noreply.github.com> Date: Mon, 15 Sep 2025 10:41:17 +1000 Subject: [PATCH 7/7] comment environment block --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b624c95..21b62c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" services: asf-claim: build: . - environment: + # environment: # - GITHUB_TOKEN=${GITHUB_TOKEN} # optional: prevents rate limiting # - ASF_PORT=1242 # - ASF_HOST=localhost