Developed for the channels of PythonPhil and CodingAndGamingWithAdam.
For support using this bot, please join our official support server on Discord.
The source code can be found here.
Contributions welcome and gratefully appreciated!
Python 3 (Version 3.6 or later).
This has only been tested on Linux, so preferably use Linux or WSL 2 if on Windows.
Navigate to where you will store the bot files, then run:
git clone git@github.com:adambirds/pythonrobot-twitch-bot.git
Then run:
tools/setup/prep-prod-environment
Then run:
cp example-config.yaml config.yaml
You will then need to edit config.yaml to your needs. You shouldn't delete any of the keys, however any of the keys under SOCIALS
can be set to ""
which will inform the bot that you don't have an account.
The ACCESS_TOKEN
key can be generated using this generator.
The CLIENT_ID
and CLIENT_SECRET
keys have to be got from creating and registering your own application at dev.twitch.tv.
The SECRET_STRING
key can be set to any string you like but this cannot be changed without a lot of difficulty down the line for you. For security we highly reccommend that this is set to something long, ideally a randomly generated string of characters.
The CALLBACK_URL
key should be set to the domain you wish Twitch to send the webhooks to for which we will now setup a web server for.
The PORT
key should be set to a port number that the internal web server that the bot creates will listen on. By default this is set to 4000
in the config file.
Twitch requires your callback URL to be accessible via https://
with an SSL
certificate on port 443
. The bot doesn't support this so we need set up a reverse proxy to handle this for us. For this I reccommend using Nginx which you can install with the below command:
apt-get install nginx
For your SSL certificate you can use any valid SSL as long as it isn't self-signed. For a free SSL certificate I reccomend that you use Lets Encrypt. You can find the instructions on how to generate your SSL here.
I have included an example nginx config file here. Once you have this running the only thing then left is to setup your bot to run as a service if you wish which you can do by amending the ./pythonrobot-twitch-bot.service
file with your working directorys and copying it using the following command:
cp ./pythonrobot-twitch-bot.service /lib/systemd/system/
Then run:
systemctl daemon-reload
Then run:
systemctl start pythonrobot-twitch-bot
And then to ensure it starts when your server does run:
systemctl enable pythonrobot-twitch-bot
The bot supports the following commands:
Command | Aliases | Example | Permissions | Purpose |
---|---|---|---|---|
!8ball | !8ball Am I amazing? |
Everyone | The bot replies to a yes or no question. | |
!age | !age |
Everyone | The bot replies with a random age. | |
!ban | !ban @adamistesting or !ban @adamistesting spamming channel |
Moderators | Ban user with or without a reason. | |
!calculator | !calc | !calculator 4 + 4 |
Everyone | Performs a simple calculation. Supports +, -, *, / |
!dice | !roll | !dice |
Everyone | Random number between 1 and 6. |
!discord | !discord |
Everyone | The streamers discord link. | |
!fb | !facebook |
Everyone | The streamers facebook link. | |
!formatpy | !formatpy |
Everyone | Reminds someone how to format in python | |
!getthisbot | !getthisbot |
Everyone | The link to the bots github | |
!gitcheatsheet | !gitcheatsheet |
Everyone | The bot will reply with link to git cheat sheet. | |
!github | !github |
Everyone | The streamers github link. | |
!hello | !hello |
Everyone | The bot replies hello | |
!help | !commands | !help |
Everyone | The bot replies with the link to these commands. |
!ig , !insta | !instagram |
Everyone | The streamers instagram link. | |
!patreon | !patreon |
Everyone | The streamers patreon link. | |
!pycheatsheet | !pycheatsheet |
Everyone | The bot replies with the link to a Python cheat sheet. | |
!project | !project |
Everyone | The bot replies about information on the current project. | |
!pyvenv | !pyenv, !venv, !virtualenv | !pyvenv |
Everyone | The bot replies with the command to create a Python virtual environment. |
!quote | !quote |
Everyone | The bot replies with a random quote. | |
!reddit |
Everyone | The streamers reddit link. | ||
!shoutout | !so | !shoutout pythonphil |
Moderators | Shoutout a fellow streamer |
!socials | !links | !socials |
Everyone | The streamers social mnedia links. |
!tiktok | !tiktok |
Everyone | The streamers tiktok link. | |
!time | !date , !datetime | !time Europe/London |
Everyone | Current time anywhere in world |
!timeout | !to | !timeout @adamistesting 10 or !timeout @adamistesting 10 spamming channel |
Moderators | Timeout user for specified number of seconds with or without a reason. |
!twitter |
Everyone | The streamers twitter link. | ||
!unban | !unban @adamistesting |
Moderators | Unban user. | |
!uptime | !uptime |
Everyone | Display how long the streamer has been streaming for. | |
!website | !website |
Everyone | The streamers website link. | |
!youtube | !youtube |
Everyone | The streamers youtube link. |
The bot also currently reacts to the following events:
- New Follower - The bot will thank the follower and if the stream has a discord, give them the link.
- Channel Raid - The bot will shoutout the raider, thank them, and announce how many views they brought with them.
This project is released under the GNU GENERAL PUBLIC LICENSE v3.
Anybody is welcome to contribute to this project. I just ask that you check out our contributing guidelines here first.