-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsession
More file actions
executable file
·66 lines (50 loc) · 1.47 KB
/
session
File metadata and controls
executable file
·66 lines (50 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# Tracks and displays combined crucible stats per gameplay session.
#
# Created by Mike Chambers
# https://www.mikechambers.com
#
# Released under an MIT License
# More info at:
# https://github.com/mikechambers/dcli/
#
# Requires dcliah and dclitime v0.2.0
#https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -u
#pull variables from environment variables. Otherwise, you can
#just manually set them below
#can get from dclis
MEMBER_ID=$MEMBER_ID
#can get from dclis
PLATFORM=$PLATFORM
#how often we check (seconds)
CHECK_INTERVAL=30
#the mode to pull stats for
MODE="all_pvp"
#to moment to start pull stats from.
MOMENT="now"
#tip to track trials for the weekend MODE=trials_of_osiris and MOMENT=weekend
#lets get the start time string
SESSION_START=$(dclitime --moment ${MOMENT})
clear
LAST_CHECK_WAS_ERROR=0
#now just loop and keep checking the stats
while :
do
#this redirects stderr put to /dev/null
ACTIVITY_HISTORY=$(dcliah --member-id "${MEMBER_ID}" --platform "${PLATFORM}" --mode "${MODE}" --moment custom --custom-time "${SESSION_START}" 2> /dev/null)
#check and see if an error occured.
if [ $? -eq 1 ]
then
if [ $LAST_CHECK_WAS_ERROR -eq 0 ] ; then
echo -e "\nError retrieving activities. Trying again in ${CHECK_INTERVAL} seconds"
LAST_CHECK_WAS_ERROR=1
fi
else
LAST_CHECK_WAS_ERROR=0
clear
echo -e "$ACTIVITY_HISTORY"
fi
#check exit code here
sleep $CHECK_INTERVAL
done