Backfill Discord channel history into Nextcloud Talk rooms using matterbridge.toml account and gateway mappings.
On startup, the script creates its own project virtual environment (.venv) if needed, re-runs itself inside that environment, and installs dependencies from requirements.txt automatically.
This tool only backfills discord.* to nctalk.* gateway pairs. Other bridge/account types in matterbridge.toml are ignored.
- Uses
matterbridge.tomlfor:- Discord bot tokens (
[discord.*].Token) - Nextcloud Talk credentials (
[nctalk.*].Server/Login/Password) - Discord to Talk room mappings from enabled
[[gateway]]blocks
- Discord bot tokens (
- Creates and uses project
.venvautomatically when not already running in a virtual environment - Ensures dependencies from
requirements.txtare installed before runtime - Supports dry-run mode and message window filters
- Applies Talk
RemoteNickFormatwith a backfill marker in the posted author line
- Python 3.10+
- A valid
matterbridge.tomlwithdiscord,nctalk, andgatewaysections
Use matterbridge.example.toml as a template:
cp matterbridge.example.toml matterbridge.tomlThen fill real values in matterbridge.toml.
Default config path is ./matterbridge.toml.
You can override it with MATTERBRIDGE_CONFIG=/path/to/matterbridge.toml.
python discord_to_talk_backfill.py --helppython discord_to_talk_backfill.py --list-functionspython discord_to_talk_backfill.pypython discord_to_talk_backfill.py --dryrunpython discord_to_talk_backfill.py --maxmessages=500python discord_to_talk_backfill.py --daysback=30python discord_to_talk_backfill.py --dryrun --maxmessages=300 --daysback=14--helpshow command usage--list-functionsprint script utilities and exit--dryrunpreview output only; do not post--maxmessages=NUMBERprocess up to NUMBER most-recent messages per channel--daysback=NUMBERskip messages older than NUMBER days
MATTERBRIDGE_CONFIGpath to config file (default:matterbridge.toml)DISCORD_LIMIToptional fallback for max messages when--maxmessagesis not providedDAYS_BACKoptional fallback for days filter when--daysbackis not providedDRY_RUNoptional fallback dry-run flag (1enables dry-run)POST_DELAY_SECONDSdelay between posts (default:0.35)
- Discord messages with no text and no attachments are skipped.
- The script posts attachments links only; it does not include Discord message permalinks.
- If no message limit is provided, all available history may be read.