feat(plugins/community/splatoon): add stat.ink integration
This commit is contained in:
BIN
.github/readme/imgs/plugin_splatoon_statink.png
vendored
Normal file
BIN
.github/readme/imgs/plugin_splatoon_statink.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
2
.github/scripts/files/examples.yml
vendored
2
.github/scripts/files/examples.yml
vendored
@@ -20,6 +20,8 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
SPLATOON_TOKEN:
|
SPLATOON_TOKEN:
|
||||||
required: true
|
required: true
|
||||||
|
SPLATOON_STATINK_TOKEN:
|
||||||
|
required: true
|
||||||
SPOTIFY_TOKENS:
|
SPOTIFY_TOKENS:
|
||||||
required: true
|
required: true
|
||||||
STOCK_TOKEN:
|
STOCK_TOKEN:
|
||||||
|
|||||||
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@@ -160,6 +160,7 @@ jobs:
|
|||||||
PAGESPEED_TOKEN: ${{ secrets.PAGESPEED_TOKEN }}
|
PAGESPEED_TOKEN: ${{ secrets.PAGESPEED_TOKEN }}
|
||||||
GOOGLE_MAP_TOKEN: ${{ secrets.GOOGLE_MAP_TOKEN }}
|
GOOGLE_MAP_TOKEN: ${{ secrets.GOOGLE_MAP_TOKEN }}
|
||||||
SPLATOON_TOKEN: ${{ secrets.SPLATOON_TOKEN }}
|
SPLATOON_TOKEN: ${{ secrets.SPLATOON_TOKEN }}
|
||||||
|
SPLATOON_STATINK_TOKEN: ${{ secrets.SPLATOON_STATINK_TOKEN }}
|
||||||
SPOTIFY_TOKENS: ${{ secrets.SPOTIFY_TOKENS }}
|
SPOTIFY_TOKENS: ${{ secrets.SPOTIFY_TOKENS }}
|
||||||
STOCK_TOKEN: ${{ secrets.STOCK_TOKEN }}
|
STOCK_TOKEN: ${{ secrets.STOCK_TOKEN }}
|
||||||
TWITTER_TOKEN: ${{ secrets.TWITTER_TOKEN }}
|
TWITTER_TOKEN: ${{ secrets.TWITTER_TOKEN }}
|
||||||
|
|||||||
@@ -118,6 +118,19 @@ deno run --allow-run=deno --allow-read=profile.json --allow-write=profile.json -
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## 🐙 [stat.ink](https://stat.ink) integration
|
||||||
|
|
||||||
|
It is possible to make this plugin automatically export fetched games to [stat.ink](https://stat.ink) by adding the following:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugin_splatoon_statink: yes
|
||||||
|
plugin_splatoon_statink_token: ${{ secrets.SPLATOON_STATINK_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
|
[stat.ink](https://stat.ink) API key can be found on user profile:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## 👨💻 About
|
## 👨💻 About
|
||||||
|
|
||||||
Data are fetched using [spacemeowx2/s3si.ts](https://github.com/spacemeowx2/s3si.ts) tool (which is itself based on [frozenpandaman/s3s](https://github.com/frozenpandaman/s3s)).
|
Data are fetched using [spacemeowx2/s3si.ts](https://github.com/spacemeowx2/s3si.ts) tool (which is itself based on [frozenpandaman/s3s](https://github.com/frozenpandaman/s3s)).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
- name: Example
|
- name: Splatnet data
|
||||||
uses: lowlighter/metrics@latest
|
uses: lowlighter/metrics@latest
|
||||||
with:
|
with:
|
||||||
filename: metrics.plugin.splatoon.svg
|
filename: metrics.plugin.splatoon.svg
|
||||||
@@ -6,6 +6,21 @@
|
|||||||
base: ""
|
base: ""
|
||||||
plugin_splatoon: yes
|
plugin_splatoon: yes
|
||||||
plugin_splatoon_token: ${{ secrets.SPLATOON_TOKEN }}
|
plugin_splatoon_token: ${{ secrets.SPLATOON_TOKEN }}
|
||||||
|
test:
|
||||||
|
skip: true
|
||||||
|
prod:
|
||||||
|
skip: true
|
||||||
|
|
||||||
|
- name: Splatnet data with stat.ink integration
|
||||||
|
uses: lowlighter/metrics@latest
|
||||||
|
with:
|
||||||
|
filename: metrics.plugin.splatoon.svg
|
||||||
|
token: ${{ secrets.METRICS_TOKEN }}
|
||||||
|
base: ""
|
||||||
|
plugin_splatoon: yes
|
||||||
|
plugin_splatoon_token: ${{ secrets.SPLATOON_TOKEN }}
|
||||||
|
plugin_splatoon_statink: yes
|
||||||
|
plugin_splatoon_statink_token: ${{ secrets.SPLATOON_STATINK_TOKEN }}
|
||||||
extras_css: |
|
extras_css: |
|
||||||
h2 { display: none !important; }
|
h2 { display: none !important; }
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import assets from "./assets.mjs"
|
import assets from "./assets.mjs"
|
||||||
|
|
||||||
//Setup
|
//Setup
|
||||||
export default async function({login, q, imports, data, account}, {enabled = false, extras = false, token} = {}) {
|
export default async function({login, q, imports, data, account}, {enabled = false, extras = false, token, "statink.token":_statink_token} = {}) {
|
||||||
//Plugin execution
|
//Plugin execution
|
||||||
try {
|
try {
|
||||||
//Check if plugin is enabled and requirements are met
|
//Check if plugin is enabled and requirements are met
|
||||||
@@ -10,7 +10,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
const {modes, "versus.limit": _versus_limit, "salmon.limit": _salmon_limit} = imports.metadata.plugins.splatoon.inputs({data, account, q})
|
const {modes, "versus.limit": _versus_limit, "salmon.limit": _salmon_limit, statink} = imports.metadata.plugins.splatoon.inputs({data, account, q})
|
||||||
|
|
||||||
//Save profile
|
//Save profile
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,18 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
const parsed = JSON.parse(token)
|
const parsed = JSON.parse(token)
|
||||||
if (!parsed?.loginState?.sessionToken)
|
if (!parsed?.loginState?.sessionToken)
|
||||||
throw new Error("Configuration is missing sessionToken")
|
throw new Error("Configuration is missing sessionToken")
|
||||||
await imports.fs.writeFile(profile, token)
|
if (statink) {
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > splatoon > stat.ink integration is enabled`)
|
||||||
|
if (_statink_token) {
|
||||||
|
parsed.statInkApiKey = _statink_token
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > splatoon > stat.ink api key set`)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.warnings.push({warning:{message:'"plugin_splatoon_statink" is set without "plugin_splatoon_statink_token"'}})
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > splatoon > stat.ink api key missing`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await imports.fs.writeFile(profile, JSON.stringify(parsed))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fetch data
|
//Fetch data
|
||||||
@@ -27,7 +38,12 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
|||||||
files: ["profile.json", "profile.json.swap", "export", "cache"],
|
files: ["profile.json", "profile.json.swap", "export", "cache"],
|
||||||
net: ["api.imink.app", "accounts.nintendo.com", "api.accounts.nintendo.com", "api-lp1.znc.srv.nintendo.net", "api.lp1.av5ja.srv.nintendo.net"],
|
net: ["api.imink.app", "accounts.nintendo.com", "api.accounts.nintendo.com", "api-lp1.znc.srv.nintendo.net", "api.lp1.av5ja.srv.nintendo.net"],
|
||||||
}
|
}
|
||||||
await imports.run(`deno run --no-prompt --cached-only --no-remote --allow-read="${allowed.files}" --allow-write="${allowed.files}" --allow-net="${allowed.net}" index.ts --exporter file --no-progress`, {cwd: `${imports.__module(import.meta.url)}/s3si`}, {prefixed: false})
|
const exporters = ["file"]
|
||||||
|
if (statink) {
|
||||||
|
exporters.push("stat.ink")
|
||||||
|
allowed.net.push("stat.ink")
|
||||||
|
}
|
||||||
|
await imports.run(`deno run --no-prompt --cached-only --no-remote --allow-read="${allowed.files}" --allow-write="${allowed.files}" --allow-net="${allowed.net}" index.ts --exporter="${exporters}" --no-progress`, {cwd: `${imports.__module(import.meta.url)}/s3si`}, {prefixed: false})
|
||||||
|
|
||||||
//Read fetched data
|
//Read fetched data
|
||||||
const fetched = (await Promise.all(
|
const fetched = (await Promise.all(
|
||||||
|
|||||||
@@ -62,3 +62,20 @@ inputs:
|
|||||||
default: 1
|
default: 1
|
||||||
min: 0
|
min: 0
|
||||||
max: 6
|
max: 6
|
||||||
|
|
||||||
|
plugin_splatoon_statink:
|
||||||
|
description: |
|
||||||
|
stat.ink integration
|
||||||
|
|
||||||
|
If set, fetched data will also be uploaded to stat.ink
|
||||||
|
Requires [`plugin_splatoon_statink_token`](/source/plugins/community/splatoon/README.md#plugin_splatoon_statink_token) to be set
|
||||||
|
type: boolean
|
||||||
|
default: no
|
||||||
|
extras:
|
||||||
|
- metrics.api.statink
|
||||||
|
|
||||||
|
plugin_splatoon_statink_token:
|
||||||
|
description: |
|
||||||
|
stat.ink token
|
||||||
|
type: token
|
||||||
|
default: ""
|
||||||
@@ -21,12 +21,13 @@ const allowed = {
|
|||||||
files:["profile.json", "profile.json.swap", "cache", "export"],
|
files:["profile.json", "profile.json.swap", "cache", "export"],
|
||||||
net:["api.imink.app", "accounts.nintendo.com", "api.accounts.nintendo.com", "api-lp1.znc.srv.nintendo.net", "api.lp1.av5ja.srv.nintendo.net"]
|
net:["api.imink.app", "accounts.nintendo.com", "api.accounts.nintendo.com", "api-lp1.znc.srv.nintendo.net", "api.lp1.av5ja.srv.nintendo.net"]
|
||||||
}
|
}
|
||||||
|
const script = import.meta.resolve("./s3si/index.ts")
|
||||||
const args = [
|
const args = [
|
||||||
"run", "--no-prompt", "--cached-only", "--no-remote",
|
"run", "--no-prompt", "--cached-only", "--no-remote",
|
||||||
`--allow-read="${allowed.files}"`,
|
`--allow-read="${allowed.files}"`,
|
||||||
`--allow-write="${allowed.files}"`,
|
`--allow-write="${allowed.files}"`,
|
||||||
`--allow-net="${allowed.net}"`,
|
`--allow-net="${allowed.net}"`,
|
||||||
"s3si/index.ts",
|
script,
|
||||||
'--exporter=none'
|
'--exporter=none'
|
||||||
]
|
]
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -13,5 +13,6 @@
|
|||||||
"STOCK_TOKEN":"MOCKED_TOKEN",
|
"STOCK_TOKEN":"MOCKED_TOKEN",
|
||||||
"CHESS_TOKEN":"MOCKED_TOKEN",
|
"CHESS_TOKEN":"MOCKED_TOKEN",
|
||||||
"SPLATOON_TOKEN":"{}",
|
"SPLATOON_TOKEN":"{}",
|
||||||
|
"SPLATOON_STATINK_TOKEN":"MOCKED_TOKEN",
|
||||||
"POOPMAP_TOKEN":"MOCKED_TOKEN"
|
"POOPMAP_TOKEN":"MOCKED_TOKEN"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user