make bot functional
This commit is contained in:
parent
2c262a8770
commit
45816e0239
3 changed files with 29 additions and 6 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,6 @@
|
||||||
quotes.json
|
quotes.json
|
||||||
quotes.txt
|
quotes.txt
|
||||||
|
.env
|
||||||
|
Credentials
|
||||||
|
docker-compose.yml
|
||||||
|
oauth.sh
|
||||||
|
|
|
||||||
9
Dockerfile
Normal file
9
Dockerfile
Normal 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
22
main.sh
|
|
@ -1,12 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
set -x
|
||||||
|
IdempotencyKey="$(uuidgen)"
|
||||||
|
. ./.env
|
||||||
|
Authorization="${UserToken}"
|
||||||
while /bin/true; do
|
while /bin/true; do
|
||||||
#if json quote list exist
|
|
||||||
if [ -f "./quotes.txt" ]; then
|
if [ -f "./quotes.txt" ]; then
|
||||||
CurrentQuote=$(shuf -n 1 ./quotes.txt)
|
status=$(shuf -n 1 ./quotes.txt)
|
||||||
#echo ${CurrentQuote}
|
|
||||||
kdialog --passivepopup "${CurrentQuote}"
|
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
|
else
|
||||||
echo "file does not exist!"
|
echo "file does not exist!"
|
||||||
fi
|
fi
|
||||||
sleep 300
|
sleep 3600
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue