botodon/README.md

127 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2019-06-13 11:58:47 +00:00
# Botodon
A pretty simple random message bot using [Mastodon](https://joinmastodon.org) statuses as source of truth.
- **no database:** store volatile data in statuses
- **easy edit:** allows easy edit from web ui or apps.
- **community:** allows public submit with strict or community driven moderation
## Install
### Mastodon
- Create an account for this bot. Please mark it as bot in configuration page.
2019-06-17 15:06:01 +00:00
- In settings page, create a new application with `read write` permission and copy the private key.
- Or `read:accounts read:statuses write:statuses write:media`
- Could use `npm run token-add` *(requires `DOMAIN` in `.env`)*
- Create a status to store actions (could be private) containing `#botodon` and copy its id. *Called `root status` after*
2019-06-14 15:10:20 +00:00
- Create a status to store content (could be private) and copy its id. *Called `data status` after*
- Reply to this status to add content. (Removing @acct, to limit self spam)
- Reply to `root status` with options tags *(See `action status`)* like `#botodon #global #data_from_{DATA_STATUS_ID}`
2019-06-13 11:58:47 +00:00
### Botodon
2019-06-17 15:06:01 +00:00
Download folder from [releases](https://git.wadza.fr/me/botodon/releases).
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
In `.env` set
- `DOMAIN={INSTANCE_DOMAIN}`
2019-06-17 15:06:01 +00:00
- `TOKEN={PRIVATE_KEY}`
2019-06-14 15:10:20 +00:00
- `ROOT_STATUS={ROOT_STATUS_ID}`
2019-06-13 11:58:47 +00:00
2019-06-17 15:06:01 +00:00
Run `node index.js` with cron.
2019-06-13 11:58:47 +00:00
Enjoy
2019-06-14 15:10:20 +00:00
## Main ideas
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
It uses statuses tags as configuration like `#xxx_yyy`. So content doesn't really matter except obviously for `content statuses`
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
There is 3 *types* of statuses:
- *The* `root status` contains global options. See [Root status](#root-status)
- `action status` contains action to run and is descendant of `root status`. See [Action status](#action-status)
- `data status` is a data source like a folder containing `content statuses`
- `content status` is a *normal* status its content *(including medias)* will send
### Root status
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
Its a folder containing `action statuses` and global options as tags.
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
tag | description
2019-06-17 15:06:01 +00:00
--- | ---
2019-06-14 15:10:20 +00:00
botodon | **Required** Enable tags processing
async | Enable actions parallel processing
deep | Use replies to actions as actions
shared | **Unsafe** Include other users actions
2019-06-17 15:06:01 +00:00
file | Also load actions from `actions.json`
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
### Action status
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
It describe an action to run
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
#### Sample
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
```
#botodon #global #data_from_xxxxxxxxxxxx
```
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
Send standard status with random content from `xxxxxxxxxxxx` status
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
#### Options
2019-06-13 11:58:47 +00:00
2019-06-14 15:10:20 +00:00
tag | default | description
2019-06-17 15:06:01 +00:00
--- | --- | ---
2019-06-14 15:10:20 +00:00
botodon | false | **Required** Enable tags processing
**Data source** | | content send
2019-06-17 15:06:01 +00:00
data_file | empty | Use `database.json` as source *(See database.sample.json)*
2019-06-14 15:10:20 +00:00
data_from_**ID** | empty | Add a source of content: `data status` id
data_deep | false | Use replies to content as content
data_shared | false | **Warning** Include other users content
2019-06-17 15:06:01 +00:00
data_tagged_**TAG** | empty | Require content to have this tag *(Tags are lowercase on backend)*
2019-06-14 15:10:20 +00:00
data_favourited | false | Require content to be fav by bot account
data_favourites_**N** | false | Require at least N favourites
data_last_**N** | disabled | Only include N last statuses
data_weighted | false | Use `favourites_count` as promotional random weight
data_same | false | Send same content for all targets
**Targets** | | target accounts
global | false | Send without target
followers | false | Send to each followers
followers_of_**ID** | empty | Send to each followers of given account id **Don't be evil**
replies_to_**ID** | empty | Send to each repliers of given status id
replies_deep | false | Include replies to replies
replies_visibility | false | Use reply visibility
2019-06-17 15:06:01 +00:00
favourites_**ID** | empty | Send to each use who fav given status id
2019-06-14 15:10:20 +00:00
visibility | unlisted | Visibility to use. One of `public`, `unlisted`, `private`, `direct`
2019-06-13 11:58:47 +00:00
## Multiple bots
Add `.env.XXX` files and run `BOT_NAME=XXX node index.js`
2019-06-14 15:10:20 +00:00
## Limits
2019-06-13 11:58:47 +00:00
Mastodon context API use an arbitrary limit of `4096` since [#7564](https://github.com/tootsuite/mastodon/pull/7564), it's so the limit were new replies are excluded.
2019-06-17 15:06:01 +00:00
Mastodon api limit to 300 requests within 5 minutes. Using a rate limiter at 150 requests for 5 minutes.
2019-06-13 11:58:47 +00:00
Followers soft limit of `999` *(must include pagination)* and hard limit of `7500`.
2019-06-17 15:06:01 +00:00
### Pleroma
It supports Mastodon API but uses case-sensitive ids which can't be stored as tag.
You have to use actions and database json files as fallback.
## Tools
`tools` folder contains some useful script which could be as helpful as dangerous.
2019-06-13 11:58:47 +00:00
## TODO
2019-06-14 15:10:20 +00:00
- Add abstract and inherit on deep actions
- Add actions time validators
- Use followers pagination
- Add options on `data status`
- Add move pick options
2019-06-17 15:06:01 +00:00
- Handle errors
- Move to Go ?