Compare commits
2 commits
5d20c07a54
...
45816e0239
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45816e0239 | ||
|
|
2c262a8770 |
3 changed files with 31 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,6 @@
|
|||
quotes.json
|
||||
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,8 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
#if json quote list exist
|
||||
#!/bin/bash
|
||||
set -x
|
||||
IdempotencyKey="$(uuidgen)"
|
||||
. ./.env
|
||||
Authorization="${UserToken}"
|
||||
while /bin/true; do
|
||||
if [ -f "./quotes.txt" ]; then
|
||||
shuf -n 1 ./quotes.txt
|
||||
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 3600
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue