make bot functional

This commit is contained in:
haui 2026-02-01 20:20:26 +01:00
parent 2c262a8770
commit 45816e0239
3 changed files with 29 additions and 6 deletions

4
.gitignore vendored
View file

@ -1,2 +1,6 @@
quotes.json
quotes.txt
.env
Credentials
docker-compose.yml
oauth.sh

9
Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM bash:5
WORKDIR /usr/local/quotebot
COPY main.sh ./
RUN adduser -S quotebot --disabled-password --uid 1000 && apk add curl && apk add uuidgen
USER quotebot
ENTRYPOINT ["bash", "/usr/local/quotebot/main.sh"]

22
main.sh
View file

@ -1,12 +1,22 @@
#!/bin/sh
#!/bin/bash
set -x
IdempotencyKey="$(uuidgen)"
. ./.env
Authorization="${UserToken}"
while /bin/true; do
#if json quote list exist
if [ -f "./quotes.txt" ]; then
CurrentQuote=$(shuf -n 1 ./quotes.txt)
#echo ${CurrentQuote}
kdialog --passivepopup "${CurrentQuote}"
status=$(shuf -n 1 ./quotes.txt)
result=$(curl -X POST \
-H "Authorization: Bearer ${Authorization}" \
-H "Idempotency-Key: ${IdempotencyKey}" \
-d "status=${status}" \
"https://mastodon.giftedmc.com/api/v1/statuses") # HTTP/1.1
echo "${result}"
else
echo "file does not exist!"
fi
sleep 300
sleep 3600
done