How to use the twitchat bot

The twitchat chat bot will run on your own machine and allow you to run more complex commands than other Twitch bots.

Quick start

To get the bot up and running immediately, you have to do the following:

  1. pip install twitchat (or python -m pip install twitchat if that doesn’t work for you)
  2. Create a directory for the bot
  3. Inside this directory, run twitchat-settings

Here, you will have to enter the following:

  1. The name of your bot account
  2. A client ID for that account
  3. A corresponding oauth token (This can easily be acquired from here; exclude the “oauth:” part)
  4. The channel you want the bot to connect to

If you don’t know what any of this means, I have a guide prepared for you.

Finally, create a script in the bot directory (or just run python)::

from twitchat.twitchbot import main
main()

Your bot should now be connecting to your Twitch chat and saying “I am here now :)”. Try using !ping to see him reply!

Adding your own Commands

To add your own commands, you need to add them to extra_commands.py, a file that will be created after running twitchat-setting (refer to Quick start).

The general template for your commands will be::

def on_command_name(self, e, msg, c, bot):
    c.privmsg(bot.channel, "This is what the bot will say")

Additionally, in the same file, you will need to have a dictionary with the cooldowns for each command::

cooldowns = {
              'on_comm1': 10,
              'on_comm2': 2,
              'on_comm3': 0
}

In this case, the !comm2 command will have a 2 second cooldown, the !comm1 command a 10 second cooldown, and the !comm3 command (you guessed it) no cooldown at all.

Indices and tables