aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: cbb1863abd33886c07b9eba31cc5a685cdbb6986 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# pleroma announce

this is a small quick and dirty tool that intended to be used to post
announcements and polls onto bot on pleroma.

## prerequisites

- python 3

- pip

- curl (optional, if you can replace it with other tool)

- registered pleroma app and authentication token (see next section)

## pleroma app registration

1. create pleroma user and mark it as bot.

2. create an application for pleroma to get `client_id` and `client_secret`.
refer to [pleroma api specification][1] and [mastodon api specification][2].
this tool requires `write:statuses` and `read:statuses` scopes, so don't forget
to specify them, otherwise it will fail.

  ```terminal
  curl -X POST \
      -F 'client_name={YOUR_APP_NAME}' \
      -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \
      -F 'scopes=write:statuses read:statuses' \
      https://yourdomain.tld/api/v1/apps
  ```
  [1]: https://api.pleroma.social/#operation/AppController.create
  [2]: https://docs.joinmastodon.org/client/authorized/

3. with your `client_id` authorize your application with
account you are planning to use for posting.

  in browser enter:
  ```
  https://yourdomain.tld/oauth/authorize?client_id={YOUR_CLIENT_ID}
  &scope=write:statuses+read:statuses
  &redirect_uri=urn:ietf:wg:oauth:2.0:oob
  &response_type=code
  ```

  after entering credentials, you will receive access code which
  will be used in the next step.

4. with obtained access code you have to aquire authentication token for
the application.

  ```terminal
  curl -X POST \
      -F 'client_id={YOUR_CLIENT_ID}' \
      -F 'client_secret={YOUR_CLIENT_SECRET}' \
      -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
      -F 'grant_type=authorization_code' \
      -F 'code={YOUR_AUTHERIZATION_CODE}' \
      -F 'scope=write:statuses read:statuses' \
      https://yourdomain.tld/oauth/token
  ```

  you will json response with authentication token, now save it to `.env` file,
  see `.env.example`.

## usage

1. git clone the repo

  ```terminal
  $ git clone https://git.aaoth.xyz/pleroma_announce.git
  $ cd pleroma_announce
  ```

2. install required pip packages
(though they are likely to be installed already)

  ```terminal
  $ pip install -r requirements.txt
  ```

3. now you can use the script, see `--help` for options. for example:

  ```terminal
  $ python plann.py post -d 2022-02-14T14:00+00:00 -p opt1 opt2 -e 3 -m test
  ```

  this will schedule a status with text `test` and poll with options `opt1` and
  `opt2` to 14 feb 2022 14:00 UTC.

## todos

- add setup.py

- figure out versions of pip packages

- handle media attachments

- add man page

## contacts

[email me][3] or reach me on [fedi][4] if you have found a bug or
just something weird.

[3]:mailto:aaoth@aaoth.xyz
[4]:https://pleroma.aaoth.xyz/users/la_ninpre

## licence

this program is licensed under an isc licence, see `LICENCE.txt` for details.