A lightweight Twitch ChatBot that allows viewers to send inputs and commands directly to your computer, safely and in real time.
ChatControl utilizes a combination of PyAutoGui for mouse actions and AutoHotkey for keyboard actions, both of which are reliable for their respective purposes. No installation for AutoHotkey is required; it's all integrated into the codebase.
Packages used: TwitchIO (2.10), python-dotenv, pyautogui
-
🕒 Real-time actions - Once someone executes a command, it happens immediately
-
🎮 Works with games - Keyboard actions use AutoHotKey, which allows movement in certain games. It's automatically set up in the codebase; no installation required.
-
🛠️ Restrictions Implemented - Stock restrictions have already been implemented inside ChatControl, including moderator-only commands & restricted
!keybindcombinations -
✅ Easy to Expand - ChatControl already has integrated modules separating commands into different Python files. It's highly organized and easy to expand for whatever you need.
A list of all commands your viewers can execute in chat.
!click <left/right>- Click the mouse!goto <x> <y>- Move the mouse to specified coordinates!pos- Retrieve the mouse's x and y position!center- Center the mouse in the middle of the screen!drag <x> <y>- Drag the mouse from its starting point to the specified x, y coordinates!scroll <up/down> <amount>- Scroll the mouse up or down, with an amount in pixels!tiny,small,big[amount, up/down/left/right]- A command collection for incremented movements (Ex. !tinydown, !smalldown, !bigdown)
!type <content>- Types specified content onto the host!keybind <keybind, ex. 'ctrl+shift+esc'>- Execute a keybind on the host, blacklisted keybinds are provided inconfig.json!holdkey <key> <duration- Holds a key for a certain time, max limit is 20 seconds!clear- Clears selected text usingctrl+a+del
Only moderators of chat can execute these commands
!togglecontrol- Toggle the main feature of this application
-
Download
codebase.zipfrom theReleasestab. Make sure you're using the latest version! -
After installation and extraction, head to
data > varand openclient.env. This is where you will put down credentials for ChatControl to function.Here's a guide on how to fill out everything:
-
Head to this link: https://dev.twitch.tv/console/apps and create an application in the top right corner.
You need 2FA to create applications; if you haven't turned it on, head to your Twitch account settings, go to the
Security and Privacytab, and enable it from there.-
Set the
Nameto whatever you want -
Set
OAuth Redirect URLstohttp://localhost, make sure it's usinghttp, nothttps. -
Set
CategorytoChat Bot, and make sureClient TypeisConfidential. -
Complete the "I am not a bot" check and create the application.
-
-
Click
Manageon your recently made application, and copy theClient IDfield in the section.-
Copy this link and open it in a browser. Make sure you replace
[CLIENT_ID]with the client ID you copied!https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=[CLIENT_ID]&redirect_uri=http://localhost&scope=chat:read+chat:edit+user:bot&force_verify=true -
After you've authorized your application, you will be redirected to
localhost. Do not exit the tab! -
Look at the URL of the link, you should see something like:
http://localhost/#access_token=[ACCESS_TOKEN]&scope=chat%3Aread+chat%3Aedit+user%3Abot&token_type=bearerCopy the access token provided in the link [
#access_token=[ACCESS_TOKEN]]. Do not copy&at the end, that's a separator. -
Replace
OAUTH_TOKENinsideclient.envwith the token you copied. It should look like:OAUTH_TOKEN=abcdefghijklmnopqrstuvwxyz
-
-
Go back to the
Managetab of your recently made application and create a Client Secret. Copy that, and paste it into theCLIENT_SECRETvariable inclient.env. Make sure you also get the Client ID and paste that into theCLIENT_IDfield too! -
The
BOT_IDfield insideclient.envis the user ID of the account you used when you authorized the application using theid.twitch.tvlink. For example, if you authorize the application on account User1, you would use the user ID of that account for the field.-
To get the user ID of the account, open
Terminalon your computer, and paste this:curl -X GET "https://id.twitch.tv/oauth2/validate" -H "Authorization: OAuth [OAUTH_TOKEN]"Before executing the command, replace
[OAUTH_TOKEN]with the token you pasted insideclient.env, specifically the fieldOAUTH_TOKEN. -
If it was successful, it should return with JSON content:
{"client_id":"[CLIENT_ID]","login":"[ACCOUNT_USERNAME]","scopes":["chat:edit","chat:read","user:bot"],"user_id":"[USER_ID]","expires_in":123456789}Ensure the content provided matches what you need, and lastly, copy the
user_idfield inside the response, and paste it into theBOT_IDfield insideclient.env.
-
-
Lastly, the
CHATfield insideclient.envis the channel username you want the application to monitor. ChatControl will listen and respond to commands in their chat. For example, if you authorized the application asuser2via theid.twitch.tvlink and want it to monitor the chat ofuser1, you'd inputuser1inside theCHATfield.
That's it for everything inside
client.env; make sure you double-check what you put in there before continuing. -
-
If you use Visual Studio Code, open it now, and open the
ChatControlfolder, not thecodebasefolder.If you don't use Visual Studio Code, open a command prompt of your choice and navigate to the
ChatControlfolder by usingcdor any other method.-
It is recommended to create a virtual environment using venv. In Visual Studio Code, this can be done easily by selecting the Python interpreter you'd like to use (preferably Python 3.10–3.13), and letting it create a virtual environment automatically.
-
When prompted, choose
requirements.txtas the base file for installing packages.
-
-
If you're not using Visual Studio Code or prefer setting up the environment manually, follow these steps:
⚠️ Make sure your path is set to the ChatControl folder; environment setup may fail if you don't follow this step.python -m venv venv .\venv\Scripts\activate pip install -r requirements.txtpython3 -m venv venv source venv/bin/activate pip install -r requirements.txt -
Once your virtual environment is installed, you're ready to use ChatControl. You can run ChatControl with this:
venv\Scripts\python.exe structure/main.pyvenv/bin/python structure/main.pyYou don't have to run ChatControl this way; you can do it via Visual Studio Code,
.batfiles, you name it.💡 You can also activate venv first, then directly run main.py from there. If you don't want the terminal to show, use
pythonw.
- As2Bax (Lead Production) - Lead Development
- Astrid (Programmer & Web Developer) - Legal
Inspired by TCMP2's chat control (https://twitch.tv/twitchcontrolsmypc2) as an open sourced rewrite
