spasm

A simple twitch.tv chat viewer.


License
MIT
Install
pip install spasm==0.1.3

Documentation

Spasm

A Python library for quickly writing Twitch bots.

Installation

Install is simple using pip:

pip install spasm

Examples

You can easily create Twitch bots in just a few lines of code:

from spasm import TwitchBot

#-------------------------------------------------------------------
# Create your bot
#-------------------------------------------------------------------
bot = TwitchBot('twitch-bot-username', 'twitch-bot-password')

#-------------------------------------------------------------------
# Define your commands
#-------------------------------------------------------------------
@bot.command("!hello")
def hello_command(user, message):
    bot.send("Greetings @%s!" % user)

@bot.command("!goodbye", "!bye")
def goodbye_command(user, message):
    bot.send("Farewall @%s..." % user)

@bot.on_message
def filter_chat(user, message):
    bad_words = ['stupid', 'idiot', 'moron']

    for word in bad_words:
        if word in message:
            bot.send("@%s said a bad word!" % user)
            break

#-------------------------------------------------------------------
# Connect to the channel
#-------------------------------------------------------------------
bot.connect("mervman")

You can also define handlers for users joining or leaving chat:

from spasm import TwitchBot

#-------------------------------------------------------------------
# Create your bot
#-------------------------------------------------------------------
bot = TwitchBot('twitch-bot-username', 'twitch-bot-password')

#-------------------------------------------------------------------
# Define your handlers
#-------------------------------------------------------------------
@bot.on_join
def user_joined(user):
    bot.send("Welcome to the chat @%s!" % user)

@bot.on_leave
def user_left(user):
    bot.send("Oh no! @%s has left the chat..." % user)

#-------------------------------------------------------------------
# Connect to the channel
#-------------------------------------------------------------------
bot.connect("mervman")