README.md aktualisiert
This commit is contained in:
parent
2a2ab5ffff
commit
b66ec3ca1f
1 changed files with 38 additions and 20 deletions
56
README.md
56
README.md
|
|
@ -4,7 +4,7 @@ This is a quote bot (shell script) which shows a random quote from a file every
|
||||||
|
|
||||||
Note: You need to make it executable to use it.
|
Note: You need to make it executable to use it.
|
||||||
|
|
||||||
```chmod u+x main.sh```
|
chmod u+x main.sh
|
||||||
|
|
||||||
The reason i use a file and not the web is hackability, at the moment.
|
The reason i use a file and not the web is hackability, at the moment.
|
||||||
|
|
||||||
|
|
@ -18,32 +18,50 @@ https://docs.joinmastodon.org/client/intro/
|
||||||
|
|
||||||
You essentially need to run the following commands:
|
You essentially need to run the following commands:
|
||||||
|
|
||||||
```
|
|
||||||
#test connection
|
|
||||||
curl https://mastodon.example/endpoint?q=test&n=0
|
|
||||||
|
|
||||||
# create app https://docs.joinmastodon.org/methods/apps/ this will return secrets, write them down!
|
### test connection
|
||||||
curl -X POST -F 'client_name=Bot3' -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' -F 'scopes=read write push' -F 'website=https://myapp.example' https://mastodon.example.com/api/v1/apps
|
|
||||||
|
|
||||||
#verify the app works https://docs.joinmastodon.org/methods/apps/#verify_credentials
|
curl https://mastodon.example/endpoint?q=test&n=0
|
||||||
curl -H 'Authorization: Bearer ****' https://mastodon.example.com/api/v1/accounts/verify_credentials
|
|
||||||
|
|
||||||
#authorize a user https://docs.joinmastodon.org/methods/oauth/#authorize and https://docs.joinmastodon.org/client/authorized/#login you will have to input this in a browser then login and authorize the app, it will provide an authorization code
|
### create app
|
||||||
https://mastodon.example/oauth/authorize
|
https://docs.joinmastodon.org/methods/apps/
|
||||||
?client_id=CLIENT_ID
|
this will return secrets, write them down!
|
||||||
&scope=read+write+push
|
|
||||||
&redirect_uri=urn:ietf:wg:oauth:2.0:oob
|
|
||||||
&response_type=code
|
|
||||||
|
|
||||||
#obtain token https://docs.joinmastodon.org/methods/oauth/#token
|
curl -X POST -F 'client_name=Bot3' -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' -F 'scopes=read write push' -F 'website=https://myapp.example' https://mastodon.example.com/api/v1/apps
|
||||||
curl -X POST -F 'grant_type=authorization_code' -F 'client_id=\*' -F 'client_secret=\*' -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' -F 'code=\*' https://mastodon.example.com/oauth/token
|
|
||||||
|
|
||||||
|
### verify the app works
|
||||||
|
https://docs.joinmastodon.org/methods/apps/#verify_credentials
|
||||||
|
|
||||||
#make your first post
|
curl -H 'Authorization: Bearer ****' https://mastodon.example.com/api/v1/accounts/verify_credentials
|
||||||
curl -i -H 'Authorization: Bearer ***' -d 'status=Hello World!' https://mastodon.example.com/api/v1/statuses
|
|
||||||
|
|
||||||
```
|
### authorize a user
|
||||||
|
https://docs.joinmastodon.org/methods/oauth/#authorize and https://docs.joinmastodon.org/client/authorized/#login you will have to input this in a browser then login and authorize the app, it will provide an authorization code
|
||||||
|
|
||||||
|
https://mastodon.example/oauth/authorize
|
||||||
|
?client_id=CLIENT_ID
|
||||||
|
&scope=read+write+push
|
||||||
|
&redirect_uri=urn:ietf:wg:oauth:2.0:oob
|
||||||
|
&response_type=code
|
||||||
|
|
||||||
|
### obtain token
|
||||||
|
https://docs.joinmastodon.org/methods/oauth/#token
|
||||||
|
|
||||||
|
curl -X POST -F 'grant_type=authorization_code' -F 'client_id=\*' -F 'client_secret=\*' -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' -F 'code=\*' https://mastodon.example.com/oauth/token
|
||||||
|
|
||||||
|
### make your first post
|
||||||
|
|
||||||
|
curl -i -H 'Authorization: Bearer ***' -d 'status=Hello World!' https://mastodon.example.com/api/v1/statuses
|
||||||
|
|
||||||
To find this out took me hours and hours. I'm writing it down to spare you time.
|
To find this out took me hours and hours. I'm writing it down to spare you time.
|
||||||
|
|
||||||
|
## docker
|
||||||
|
you can use the dockerfile and docker-compose.yml i provided. I will at some point push a docker image which is ready to use. Until then you will have to build the image first. Here's how:
|
||||||
|
|
||||||
|
git clone https://code.kraftw3rk.de/alex/quote-bot.git
|
||||||
|
git switch rest-bot
|
||||||
|
touch quotes.txt #(fill with quotes, one per line, no longer than your instance character limit!)
|
||||||
|
touch .env #(fill with "UserToken='***'" insert the token where the stars are!)
|
||||||
|
mv docker-compose-example.yml docker-compose.yml
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
Have fun!
|
Have fun!
|
||||||
Loading…
Add table
Add a link
Reference in a new issue