Pystodon
A hybrid between a framework for building Mastodon bots and a standalone bot. You can see this bot in action on Mastodon (not always running).
Usage
Prerequisites
- A Mastodon account
- Preferably a bot account, but a normal account will work as well
- A Mastodon application
- Log into your Mastodon account on the respective instance's web interface
- Navigate to Preferences > Development > Your applications
- Click "New application"
- Set an application name (e.g. "Rather Curious Bot")
- For basic usage, allow the application to read and write to your account
- You can also try specifying more granular permissions but this is not tested (yet)
- Click "Submit"
- Make sure you are in the respective application's details page
- Copy "Your access token"
- This is your bot's access token
- You will need this later
- Do not share this token as it allows access to your account
Basic Configuration
- Configuration is handled through environment variables, a
.envfile, or command-line arguments (--helpfor more information) - To see an example configuration, see
.env.example - This can be copied to
.envand edited to suit your needs
Poetry
Specific Prerequisites
- Python (3.11+)
- Poetry
- Poetry is a package manager for Python that manages dependencies and virtual environments
Installation
- Clone the repository
git clone https://github.com/slashtechno/pystodon
- Change directory into the repository
cd pystodon
- Install dependencies
poetry install
Running
- Confirm the bot has been configured correctly
poetry run python -m pystodon
Docker
Recommended, especially if you want to use commands that depend on a database (e.g. #remindme)
Specific Prerequisites
- Docker
- Docker is a platform for developing, shipping, and running applications in containers
- Docker Compose
- Docker Compose is a tool for defining and running multi-container Docker applications
Running
- Clone the repository
git clone https://github.com/slashtechno/pystodon
- Change directory into the repository
cd pystodon
- Confirm the bot has been configured correctly
docker-compose up -d- The
-dflag runs the containers in the background
- The
Specific Prerequisites
- Python (3.11+)
- See the Poetry section for more information
PyPi
Not recommended as you can't modify the commands
Requirements
- Python (3.11+)
- Read the Poetry section for more information
Installation
pip install pystodon- You may need to use
pip3instead ofpipdepending on your system - In addition, you may want to try
python -m pip install pystodonorpython3 -m pip install pystodonif the above commands do not work
- You may need to use
Running
- Assuming programs installed by
pipare in your PATH, you can run the bot withpystodon
Usage
- By default, the bot will use the commands configured in
pystodon/commands.py- Commands include
#remindme,#timezone,#weather, and/test - The command
help(note the lack of a prefix) will list all available commands and can be used to get more information on a specific command - These commands can be modified, removed, or added to suit your needs
- Look in
pystodon/__main__.pyto see how commands are added - When running with Docker, run
docker compose --buildto rebuild the image with the new commands
- Look in
- Commands include
- The syntax for commands is
@bot_username@example.com command [arguments]- For example,
@rathercurious #remindme in 1h30m - The bot will match the visibility of the command to the visibility of the message it is replying to
- If the message is public, the bot will reply with a public message
- If the message is unlisted, the bot will reply with an unlisted message
- If the message is direct, the bot will reply with a direct message
- It's recommended to set
RC_ALWAYS_MENTIONtoTruein the.env(or use--always-mention) to ensure the user is mentioned in the reply
- For example,
Release files for pystodon 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pystodon-0.1.0.tar.gz | 12.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pystodon-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.2 kB
Release files / pystodon-0.1.0.tar.gz
| Download URL | pystodon-0.1.0.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
977272bec6aa610b808285faf40652eb837bb92ed674fce30c37fdfa273f12bc
|
|
BLAKE2b-256 checksum How to use checksums |
0bf9cbce7438ad55f4635e369818f0e6e77a18cd9ba535541053592c2ac449e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Windows/11
|
Release files / pystodon-0.1.0-py3-none-any.whl
| Download URL | pystodon-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b14527274023bbf26fd161a285a32586eb7aa6ad1dd1bd7fd57941f2f473018
|
|
BLAKE2b-256 checksum How to use checksums |
f7f5a5fd1843e5cd4c98b3308d3374b700752ae883fac5a9e9e3b9be83ac974f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Windows/11
|