Compare commits

..

5 commits

Author SHA1 Message Date
Hugh Rundle 08c32b8647 Merge pull request 'update' (#9) from update into main
Reviewed-on: #9
2024-08-10 12:19:11 +10:00
Hugh Rundle a85e056b4b
Merge branch 'main' into update 2024-08-10 12:18:25 +10:00
Hugh Rundle e2ece557c2
add some more options
- add extra reply options
- fix mentions
2024-08-10 12:09:36 +10:00
Hugh Rundle 2a6cf879b6
update readme and deps 2024-08-10 11:44:48 +10:00
Hugh Rundle fa47c7a0fb
Update README.md 2024-07-29 20:16:28 +10:00
3 changed files with 92 additions and 22 deletions

View file

@ -1 +1,63 @@
Nag yourself when you post toots that make you feel bad.
# mastodon-clippy
A customisable nodejs clippy bot for mastodon.
`mastodon-clippy` notices when you are tooting about a topic that is bad for your health, and gently suggests you stop.
See an example in action at [auspol_clippy](https://ausglam.space/@auspol_clippy).
## configuration
`mastodon-clippy` takes all configuration as ENV variables:
* `CLIPPY_TOPIC` is the topic your clippy bot makes suggestions for. e.g. "auspol".
* `CLIPPY_DOMAIN` is the base domain for the Mastodon server your bot runs on _without a protocol_. e.g. "botsin.space"
* `CLIPPY_USER` is the username of the bot, e.g. "auspol_clippy".
* `CLIPPY_ACCESS_TOKEN` is the API access token for your bot.
## auto-config
Some settings for your bot account will be automatically set/overridden whenever the bot starts. These are:
```js
locked: false,
bot: true,
discoverable: true,
source: { privacy: 'private' }
```
That is, your bot must always:
* accept new followers
* declare it is a bot
* be discoverable on the server suggestions page
* post messages in "followers only" mode
## manual config
It does not appear to be possible to use the API to set accounts to hide their social graph. users should be able to use your bot without other people necessarily knowing, but the bot needs to follow them in order to work. Therefore you should manually select `Hide your network` in `https://example.com/settings/preferences/other`.
## setup
You can use the example systemd file at `mastodon-clippy.service.example` tweaked to suit your setup. This will keep the bot running and set your environment variables as above.
Then run `npm install .` to install npm modules `axios` and `ws`.
# running
Start the bot with the traditional `node index.js`.
However, you probably want this to run automatically on a web server. You can do this with `systemd` using the example unit file: `mastodon-clippy.service.example`. Adjust this for your user and paths, and then activate it:
```bash
sudo cp mastodon-clippy.service.example /etc/systemd/system/mastodon-clippy.service
sudo systemctl enable mastodon-clippy.service
sudo systemctl start mastodon-clippy service
```
## interacting with the bot
To "sign up" for notification from your bot, users have two options:
1. follow the bot account
2. send a toot to the bot with the word `START` in capital letters. e.g. `@auspol_clippy START`
To "unsubscribe" from the bot, users can send a toot with the word `STOP` in capital letters. e.g. `@auspol_clippy STOP`

View file

@ -53,25 +53,33 @@ function initiateSettings(socket) {
// return random suggestion string
function suggestion(username) {
const n = crypto.randomInt(8)
const n = crypto.randomInt(12)
switch(n) {
case 0:
return 'How about logging off instead?';
case 1:
return `Would you like to delete your toot, ${username}?`;
return `Would you like to delete your toot, @${username}?`;
case 2:
return 'Can I help you take a walk outside?';
return 'Can I help you take a walk outside? 🚶‍➡️';
case 3:
return 'You may like to reconsider your life choices.';
case 4:
return 'Why not try looking at #CatsOfMastodon instead?';
case 5:
return `Come on ${username}, we've talked about this.`;
return `Come on @${username}, we've talked about this. 🤷‍♂️`;
case 6:
return `You should go look at some trees. Trees are calming`;
return `You should go look at some trees. Trees are calming 🌳`;
case 7:
return `I'm not angry. I'm just very disappointed.`;
return `I'm not angry. I'm just very disappointed. 😔`;
case 8:
return `You said you were going to stop doing that ...and yet here we are.`;
case 9:
return `Time to touch some grass 🌱`;
case 10:
return `Why not have a nice cup of tea instead? 🫖`;
case 11:
return `And yet you still haven't read all of those books in your TBR pile. 🤔`;
}
}

View file

@ -1,8 +1,8 @@
{
"name": "mastodon-clippy",
"version": "1.1.1",
"version": "1.1.2",
"description": "Mastodon clippy bot",
"repository": "https://github.com/hughrun/mastodon-clippy.git",
"repository": "https://git.suboptimal.solutions/hugh/mastodon-clippy",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
@ -10,7 +10,7 @@
"author": "Hugh Rundle <hugh@hughrundle.net> (https://www.hughrundle.net)",
"license": "AGPL-3.0-or-later",
"dependencies": {
"axios": "^0.21.2",
"ws": "^7.5.10"
"axios": "^1.7.3",
"ws": "^8.18"
}
}