A simplistic Matrix bot for Twitter-backed watchalongs. It posts statuses from Nitter.
Available on:
Github - Gitlab - Sourcehut Project/Repo
Every five seconds, the bot polls new tweets from a given Twitter list and sends the Nitter version (unshortened URLs and all URLs rewritten to nitter.net) to a given Matrix room. If a hashtag is also provided, only tweets containing the hashtag (regardless of case) will be sent.
# Clone the repository
git clone https://github.com/refragable/matrix-nitterbot.git
cd matrix-tweetalong-bot
# Create a virtualenv
python3 -m venv env
. env/bin/activate
# Install the dependencies
pip install -r requirements.txt
# When you're finished
deactivate
Copy config.sample.yaml
into config.yaml
.
This sample configuration includes comments documenting how to configure
the bot.
It is best to run this bot in a screen/tmux session on a server. That way it will run 24/7.
. env/bin/activate
python3 main.py
A Systemd service will run the bot automatically on (re)boot and restart it if the process dies. This requires an account with sudo
permissions.
Create a shell script start.sh
:
#!/bin/bash
cd <path to nitterbot directory>
. env/bin/activate
python3 main.py
Then create the following nitterbot.service
file:
[Unit]
Description=Nitterbot for Matrix
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
User=<user>
Group=<user>
WorkingDirectory=/home/user/nitterbot/
ExecStart=/home/user/nitterbot/start.sh
Restart=always
RestartSec=5
RuntimeMaxSec=604800
[Install]
WantedBy=multi-user.target
Then run the following to install the service file:
sudo cp nitterbot.service /etc/systemd/system/
sudo systemctl enable nitterbot.service
sudo systemctl start nitterbot.service
Brendan Abolivier - Matrix Tweetalong bot
Ilya Pupko - TwitterStatic for the Nitter parsing.