Theme is https://github.com/KillYoy/DiscordNight
discord-twitter-webhooks
is an automated tool that checks Twitter for new tweets and sends them
to a Discord webhook.
This bot is configured with a config file (.env) or environment variables.
You can contact me if a feature is missing or you have a suggestion :-)
- Change Reddit username and subreddits to clickable links.
- Change Twitter username and hashtags to clickable links.
- Change t.co url to the actual url.
- If the tweet has more than one image, it will merge them into one image in the embed.
- Remove ®, ™ and © from the tweet text.
- Customize the Discord embed.
- You can choose if you want to send a text message or an embed to Discord.
- More features are documented in the .env.example file.
You have two choices, using Docker or install directly on your computer.
This is the recommended way to install the bot.
Docker Hub: thelovinator/discord-twitter-webhooks
- Rename .env.example to .env and open it in a text editor (e.g., VSCode, Notepad++, Notepad) and fill it out.
- If you can't see the file extension:
- Windows 10: Click the View Tab in File Explorer and click the box next to File name extensions.
- Windows 11: Click View -> Show -> File name extensions.
- If you can't see the file extension:
- Open a terminal in the repository folder.
- Windows 10: Shift + right-click in the folder and select
Open PowerShell window here
- Windows 11: Shift + right-click in the folder and Show more options
and
Open PowerShell window here
- Windows 10: Shift + right-click in the folder and select
- Run the Docker Compose file:
docker-compose up
- You can stop the bot with Ctrl + c.
- If you want to run the bot in the background, you can run
docker-compose up -d
.
- You can update the container with
docker-compose pull
- You can automate this with Watchtower or Diun.
This is not recommended if you don't have an init system (e.g., systemd)
- Install the latest version of needed software:
- Download the project from GitHub with Git or download
the ZIP.
- If you want to update the bot, you can run
git pull
in the project folder or download the ZIP again.
- If you want to update the bot, you can run
- Rename .env.example to .env and open it in a text editor (e.g.,
VSCode, Notepad++, Notepad) and fill it out.
- Your settings will be stored in the .env file, not settings.py.
- If you can't see the file extension:
- Windows 10: Click the View Tab in File Explorer and click the box next to File name extensions.
- Windows 11: Click View -> Show -> File name extensions.
- Open a terminal in the repository folder.
- Windows 10: Shift + right-click in the folder and select
Open PowerShell window here
- Windows 11: Shift + right-click in the folder and Show more options
and
Open PowerShell window here
- Windows 10: Shift + right-click in the folder and select
- Install requirements:
- Type
poetry install
into the PowerShell window. Make sure you are in the repository folder where the pyproject.toml file is located.- (You may have to restart your terminal if it can't find the
poetry
command. Also double check it is in your PATH.)
- (You may have to restart your terminal if it can't find the
- Type
- Start the bot:
- Type
poetry run bot
into the PowerShell window.- You can stop the bot with Ctrl + c.
- Type
Note: You will need to run poetry install
again if poetry.lock has been modified.
More information about the rules can be found in the Twitter Documentation.
Operator (AND, OR, NOT) examples can be found here.
If you want to get tweets, replies, retweets and quotes from @Steam, @Xbox and @PlayStation.
- You can use the following rule:
RULE="from:Steam OR from:Xbox OR from:PlayStation"
- See #remove-retweets-replies-and-quotes if you only want tweets.
- Remove retweets by adding -is:retweet to the rule:
RULE="(from:Steam OR from:Xbox OR from:PlayStation) -is:retweet"
- Change -is:retweet to is:retweet to only get retweets.
- Note that we added parentheses to group the operators together otherwise the -is:retweet would only be for Playstation.
- If you want to get retweets (and tweets, replies, quotes) from Steam but not Xbox or PlayStation, you can use the
following rule:
RULE="(from:Steam) OR (-is:retweet (from:Xbox OR from:PlayStation))"
- Remove replies by adding -is:reply to the rule.
RULE="(from:Steam OR from:Xbox OR from:PlayStation) -is:reply"
- Change -is:reply to is:reply to only get replies.
- Note that we added parentheses to group the operators together otherwise the -is:reply would only be for Playstation.
- If you want to get replies (and tweets, retweets, quotes) from Steam but not Xbox or PlayStation, you can use the
following rule:
RULE="(from:Steam) OR (-is:reply (from:Xbox OR from:PlayStation))"
- Remove quote tweets by adding -is:quote to the rule:
RULE="(from:Steam OR from:Xbox OR from:PlayStation) -is:quote"
- Change -is:quote to is:quote to only get quotes
- Note that we added parentheses to group the operators together otherwise the -is:quote would only be for Playstation.
- If you want to get quote tweets (and tweets, retweets, replies) from Steam but not Xbox or PlayStation, you can use
the following rule:
RULE="(from:Steam) OR (-is:quote (from:Xbox OR from:PlayStation))"
- If you want to only get tweets from Steam, you can use the following rule:
RULE="from:Steam -is:retweet -is:reply -is:quote"
- If you have several users you have to use parentheses to group them together:
RULE="(from:Steam OR from:Xbox OR from:PlayStation) -is:retweet -is:reply -is:quote"
- If you want to get tweets with the words
pepsi
,cola
orcoca cola
, you can use the following rule:RULE='pepsi OR cola OR "coca cola"'
- Note the double quotes around words with spaces.
- We have to use single quotes around the rule if we used double quotes in the rule.
- If we only want to get tweets from @Xbox that are about Halo you can use the following rule:
RULE="Halo from:Xbox"
- Several words can be used in the rule:
RULE='("Resident Evil" OR "Team Fortress" OR "Terraria" OR "Free Weekend") from:Steam'
- Email: tlovinator@gmail.com
- Discord: TheLovinator#9276
- Send an issue: discord-twitter-webhooks/issues