summaryrefslogtreecommitdiff
path: root/forgebot.sh
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-10-17 12:44:39 +0200
committerLinnea Gräf <nea@nea.moe>2024-10-17 12:44:39 +0200
commitb7bf0368732edbc9858035432ba86b6b9b23545c (patch)
tree31e6cff7eb72ebe46dd6a7bdabd4bf05d8bd266d /forgebot.sh
parent6b85dda202b6305b38100a474037e5f05ed7b48d (diff)
downloadforgebot-b7bf0368732edbc9858035432ba86b6b9b23545c.tar.gz
forgebot-b7bf0368732edbc9858035432ba86b6b9b23545c.tar.bz2
forgebot-b7bf0368732edbc9858035432ba86b6b9b23545c.zip
Add docker file
Diffstat (limited to 'forgebot.sh')
-rwxr-xr-xforgebot.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/forgebot.sh b/forgebot.sh
index bf07e1c..98a246a 100755
--- a/forgebot.sh
+++ b/forgebot.sh
@@ -24,23 +24,23 @@ while true; do
processes="$(curl -H "Api-Key: $HYPIXEL_KEY" https://api.hypixel.net/v2/skyblock/profiles\?uuid=$uuid 2>/dev/null | tee api_response.json|
jq '[.profiles[] | select(.members["'$uuid'"].forge.forge_processes.forge_1) | {"qf": .members["'$uuid'"].mining_core.nodes.forge_time,"fp": [.members["'$uuid'"].forge.forge_processes.forge_1[]], cutename: .cute_name}]')"
atrocity_debug $processes
- mkdir -p notificationdata
- touch notificationdata/$uuid
+ mkdir -p "${DATA_DIR:-.}/"notificationdata
+ touch "${DATA_DIR:-.}/"notificationdata/$uuid
now=$(date +%s000)
- rm -f messagedata
+ rm -f "${DATA_DIR:-.}/"messagedata
echo "$processes"| jq -r '.[] | {qf: (.qf // 0), fp: .fp[], cutename: .cutename} | (if (.qf == 20) then "0.7" elif (.qf == 0) then "1" else (1 - (.qf * .5 + 10) / 100|tostring) end) + " " + .fp.id + " " + (.fp.startTime|tostring) + " " + (.fp.slot|tostring) + " " + (.cutename)' | while read qf id starttime slot cutename; do
atrocity_debug ID: $id STARTTIME: $starttime SLOT: $slot
doneat=$(($starttime + $(get_duration $id)))
atrocity_debug DONEAT WITHOUT QF: $doneat
doneat=$(bc <<<"$starttime + $qf*$(get_duration $id)"|sed s'/\..*//')
atrocity_debug DONE: $doneat
- already_notified=$(grep $starttime notificationdata/$uuid >/dev/null; echo $?)
+ already_notified=$(grep $starttime "${DATA_DIR:-.}/"notificationdata/$uuid >/dev/null; echo $?)
atrocity_debug NOTIFIED: $already_notified
isready=$(($now > $doneat))
atrocity_debug "$now > $doneat: $isready"
if [[ $isready -eq 1 ]]; then
atrocity_debug READY
- echo $starttime >> notificationdata/$uuid.new
+ echo $starttime >> "${DATA_DIR:-.}/"notificationdata/$uuid.new
if [[ already_notified -eq 1 ]]; then
echo Your $id in $slot on $cutename is ready since "<t:$(($doneat / 1000)):R> (started <t:$(($starttime / 1000)):R>)" >>messagedata
atrocity_debug ADDED
@@ -50,10 +50,10 @@ while true; do
done
if [[ -f messagedata ]]; then
echo Sending messagedata:
- atrocity_debug "$(cat messagedata)"
- jsondata="$(jq -n --arg body "$(list_watchers "$uuid"|sed -E 's|(.*)|<@\1>|';echo;cat messagedata)" '{"content": $body}')"
+ atrocity_debug "$(cat "${DATA_DIR:-.}/"messagedata)"
+ jsondata="$(jq -n --arg body "$(list_watchers "$uuid"|sed -E 's|(.*)|<@\1>|';echo;cat "${DATA_DIR:-.}/"messagedata)" '{"content": $body}')"
atrocity_rest POST "channels/$CHANNEL_ID/messages" "$jsondata"
- mv notificationdata/$uuid.new notificationdata/$uuid
+ mv "${DATA_DIR:-.}/"notificationdata/$uuid.new "${DATA_DIR:-.}/"notificationdata/$uuid
fi
sleep 10
done