commit 221f8d867c69f55ef1966bb921ddbb01c01ab35e Author: Joakim <joakim@jnisse.xyz> Date: Sun, 7 Apr 2024 00:46:33 +0200 Initial Commit, added lichess tracker script Diffstat:
A | lichess_status | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/lichess_status b/lichess_status @@ -0,0 +1,24 @@ +#!/bin/sh + + +### +# Tracks lichess-users, intended for status-bars. +# -l : Echoes # of $usernames that are online +# -s : Echoes $usernames that are online +### + +usernames="ericrosen,alvinm" +data="$(curl "https://lichess.org/api/users/status?ids="${usernames} | sed -E "s/\{/\\n/g" | grep -Eio '.*"online":true(,"playing":true)?')" +while getopts 'ls' OPTION ; do +case "$OPTION" in + l) + [ -n "$data" ] && echo $data | tr " " "\n" | wc -l || echo "0" + ;; + s) echo $data | grep -Eio '"name":"[-[:alnum:]_]*"' | cut -d ":" -f2 | tr -d '"' + ;; +esac +done + + + +