Compare commits

..

No commits in common. "rest-bot" and "main" have entirely different histories.

4 changed files with 4 additions and 40 deletions

4
.gitignore vendored
View file

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

View file

@ -1,9 +0,0 @@
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"]

View file

@ -1,9 +0,0 @@
services:
quotebot:
container_name: quotebot
image: haui/quotebot
build: ./
volumes:
- ./.env:/usr/local/quotebot/.env
- ./quotes.txt:/usr/local/quotebot/quotes.txt
restart: unless-stopped

22
main.sh
View file

@ -1,22 +1,8 @@
#!/bin/bash #!/bin/sh
set -x
IdempotencyKey="$(uuidgen)" #if json quote list exist
. ./.env
Authorization="${UserToken}"
while /bin/true; do
if [ -f "./quotes.txt" ]; then if [ -f "./quotes.txt" ]; then
status=$(shuf -n 1 ./quotes.txt) 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 else
echo "file does not exist!" echo "file does not exist!"
fi fi
sleep 3600
done