preventing unecessary request
This commit is contained in:
9
run.sh
9
run.sh
@@ -8,6 +8,11 @@ fi
|
|||||||
|
|
||||||
FULL_URL=https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2
|
FULL_URL=https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2
|
||||||
|
|
||||||
|
if pgrep -fa "AppId=$STEAM_RUNGAMEID" > /dev/null; then
|
||||||
|
echo "[automate steam] detected playing: $STEAM_RUNGAMEID on this device. skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
RESPONSE=$(curl -s "$FULL_URL/?key=$STEAM_KEY&steamids=$STEAM_USERID64")
|
RESPONSE=$(curl -s "$FULL_URL/?key=$STEAM_KEY&steamids=$STEAM_USERID64")
|
||||||
|
|
||||||
if ! echo "$RESPONSE" | jq empty 2>/dev/null; then
|
if ! echo "$RESPONSE" | jq empty 2>/dev/null; then
|
||||||
@@ -18,9 +23,7 @@ fi
|
|||||||
APPID=$(echo $RESPONSE | jq -r '.response.players[0].gameid')
|
APPID=$(echo $RESPONSE | jq -r '.response.players[0].gameid')
|
||||||
|
|
||||||
if [ "$APPID" != "null" ] && [ -n "$APPID" ]; then
|
if [ "$APPID" != "null" ] && [ -n "$APPID" ]; then
|
||||||
if pgrep -fa "AppId=$STEAM_RUNGAMEID" > /dev/null && [ "$APPID" = "$STEAM_RUNGAMEID" ]; then
|
if ! pgrep -fa "AppId=$APPID" > /dev/null; then
|
||||||
echo "[automate steam] detected playing: $APPID on this device. skipping"
|
|
||||||
elif pgrep -f steam > /dev/null; then
|
|
||||||
# If not playing on CURRENT DEVICE but DETECTED PLAYING ON ACCOUNT
|
# If not playing on CURRENT DEVICE but DETECTED PLAYING ON ACCOUNT
|
||||||
echo "[automate steam] detected playing: $APPID ON OTHER DEVICE. quitting"
|
echo "[automate steam] detected playing: $APPID ON OTHER DEVICE. quitting"
|
||||||
steam steam://exit &
|
steam steam://exit &
|
||||||
|
|||||||
Reference in New Issue
Block a user