Skip to main content

Turn Twitch chatter into Python events.

Project description

twitchobserver makes interacting with Twitch chat super easy. It is built and tuned for realtime applications. You can make chatbots chat. You can build Twitch Plays video games.

Features

  • Pure Python: No extra dependencies. Just plain and simple Python.

  • Small API: With a few classes and a handful of methods, you can learn it over a coffee break.

  • Event Based: Makes writing apps easy and straightforward.

  • Context Manager: Further simplifies working with observers.

Installation

$ pip install twitchobserver

Usage

from twitchobserver import Observer

observer = Observer('Nick', 'oauth:abcdefghijklmnopqrstuvwxyz0123')
observer.start()
observer.join_channel('channel')
observer.send_message('Hello and goodbye', 'channel')
observer.leave_channel('channel')

Documentation

API documentation can be found over on ReadtheDocs.org.

Tests

$ python -m unittest discover -s tests

Examples

Echo bot

Whenever a message is sent, echo it back. The Observer is created as a context manager object which will implicitly handle calling start() and stop().

import time
from twitchobserver import Observer

with Observer('Nick', 'oauth:abcdefghijklmnopqrstuvwxyz0123') as observer:
    observer.join_channel('channel')

    while True:
        try:
            for event in observer.get_events():
                if event.type == 'TWITCHCHATMESSAGE':
                    observer.send_message(event.message, event.channel)

            time.sleep(1)

        except KeyboardInterrupt:
            observer.leave_channel('channel')
            break

More examples can be found in the Cookbook.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twitchobserver-0.8.0.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file twitchobserver-0.8.0.tar.gz.

File metadata

File hashes

Hashes for twitchobserver-0.8.0.tar.gz
Algorithm Hash digest
SHA256 aaf04c9a104bf52032e71e82aa59a75fe79570006caaeaff65ee80c15e956856
MD5 bac77cdc01eea7ff0ef30905e6ceb905
BLAKE2b-256 e53d57944a9bd44295d941c3b2d3bd4df1065bcf2ec493c3d3f616e89f1d0325

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page