This is a project I've made to crosspost things between Discord, Mastodon, and my own blog! Very custom-made, so just like all my other projects, I don't really recommend using it unless ur me :)
The below instructions are for the Discord bot. For additional instructions
that need to be followed to get the server running, see server/README.md
.
- Send a message in Discord in a channel where the bot has read permissions
- Copy the message ID and use the
/repost
slash command to post it to all configured platforms.
Create an application, and under the Settings > Bot tab, copy the Token value
and put it in the DISCORD_TOKEN
variable in shared/secrets/secrets.toml
.
Turn on the Message Content Intent, and when inviting the bot to a server, make
sure to give it the following permissions:
- Read Messages/View Channels
- Send Messages
Also, make sure to set the additional variables in secrets.toml
:
DISCORD_GUILD_ID
: The id of the main server you expect to run the bot inDISCORD_OWNER_ID
: The id of the only authenticated user allowed to run commands
If you want any other functionality you'll have to edit the bot urself sorry :(
In the developer settings tab, create an application and give it the
read:statuses
and write:statuses
permissions. Then, read the "Your Access
Token" variable and put it into MASTODON_TOKEN
variable in secrets.toml
.
Also, provide the following environment variables:
MASTODON_BASE_URL
: the URL of the server the app is registered in
To edit the post layout, see poster/templates/mastodon_cybersec.txt.j2
. This
is laid out using jinja2 templating from the model in shared/model.py
.
First, add your homeserver to BLUESKY_HOMESERVER
(e.x. https://bsky.app
or
https://girl.technology
), and then add your full username (e.x.
wolf.girl.technology
) and password under BLUESKY_USERNAME
and
BLUESKY_PASSWORD
respectively.
Create a personal access token
and put in in the GITHUB_TOKEN
variable in secrets.toml
. If creating a
fine-grained token, make sure to give it access to the repository you want to
crosspost to. Specifically, give it read-write access in the following
categories:
- Contents
What this target will do is, for a given post, create a commit adding the post file to the main branch. This assumes that the branch has a automatic deploy action set on push already.
Additionally, configure the following variables in config.toml
:
GITHUB_USERNAME
: the owner of the repositoryGITHUB_REPO
: the repository nameGITHUB_BRANCH
: the branch to add posts to automaticallyGITHUB_OUTPUT_DIR
: the directory to output posts to
And edit post.md.j2
as desired. It uses jinja2 formatting. To
control what goes before the .j2
, see poster/template.py
. To control
what the final filename will look like, see poster/github/__init__.py
.
After configuring the platforms above into the secrets.toml
file, also put in
the Discord bot keys into the file. Then, run:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python3 -m bot
and that's it! enjoy :)))
bot/
: Code for the Discord botposter/
: Code for all the crossposting targetsmastodon/
: The mastodon targetbluesky/
: The bluesky targetgithub/
: The github target
shared/
: Shared utility codemodel.py
: Data modelsecrets.py
: Utilities for reading secrets
scripts/
: Scripts to test things out
Because of the module structure, everything needs to be run with python -m
to
work correctly. Bit weird but u get used to it!