Skip to content
Twitch Chat bot written in Python
Branch: master
Clone or download
Pull request Compare This branch is 83 commits ahead of aidanrwt:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is a simple Twitch chat/irc bot written in python.


  • Open up your terminal/shell of choice.

  • Install the [](Requests library) if you haven't already using pip install requests.

  • This application has been tested on Python 2.7.8.

  • Clone the Git repository.

  • Move config/ to config/ Replace all of the placeholders there with your own username/oauth token/channels to join etc (tips are given in the file).

  • Type chmod +x / To run, you simply need to execute the file by typing ./

Adding your own commands

You're going to need to know basic Python if you want to add your own commands. Open up res/commands.json. There are examples of pre-made commands in there as examples. The limit parameter is the amount of times a command can be used in seconds, if you don't want a limit to be enforced put in 0.

If your command is only going to return a string, ex - !hello returns Welcome!, don't include the argc parameter. Place the string you wish to be returned to the user in the return parameter. For example, if you wanted to create a command such as this and limit it to being used ever 30 seconds, you would add in:

'!hello': {'limit': 10, 'user_level': 'user', 'return': 'Welcome!'}

However, if your command has to have some logic implemented and if the command is just going to return whatever a function returns, set the return parameter on the command to command, and set argc to 0. If your command is going to take arguments, ex !hello <name>, set argc to 1 or however many arguments the command is going to take in.

Make a new file in lib/commands/ and give the filename where command is the command name. If your argc was set to 0, don't include args in the functions parameters, else set the only parameter to args. Args will contain a list of whatever arguments were passed to the command.

This command will contain whatever logic needs to be carried out. You should validate the arguments in there. After you have the response that you want a user to see, just return it.

Let's say we want to add a command which will take two arguments, we will call it !random and it will take a minimum and maximum argument. We will limit this command to be allowed to be called every 20 seconds.

Add the following to the commands dictionary:

'!random': {'limit': 20, 'user_level': 'user', 'argc': 2, 'return': 'command'}

And then in lib/commands/ , write the following:

import random

def random(roboraj):
  min = roboraj['command_info']['args'][0]
  max = roboraj['command_info']['args'][1]
  usage = '!random <min> <max>'
  # carry out validation
    return ranrange(min, max)
  except ValueError:
    return '!random <min> <max> (use full integers)'
    return usage

And now if somebody types !random 5 10 into the chat, the bot will respond with a pseudo-random number between 5 and 10.

User Levels

If you want to configure a command to only work for certain user groups, you can specify it in the "user_level" field in the command JSON.

There are 3 configurable user levels for commands. 'admin', 'mod', and 'user'

Configuring which users belong in which group can be specified in the "" file. (NOTE: If you want an admin to also have mod rights, include the username in the "mod" group.)

You can’t perform that action at this time.