oliver-lloyd / twitch-listener

Easy python bot for scraping Twitch chat data
MIT License
44 stars 11 forks source link
adjacency-matrix python python-bot social-network-analysis twitch twitch-bot twitch-irc

Twitch listener bot

An easy to use Python bot for retrieving Twitch chat data from multiple streams/channels simultaneously. Includes functionality to generate adjacency matrices between the streams, for the purpose of network modelling. All files are generated in your working directory.

Installation:

pip install twitch-listener

Steps for acquiring Twitch credentials (skip if you already have these):

1) Get a twitch.tv account

Store these values securely. You now have everything you need to use TwitchListener.

Example usage:

from twitch_listener import listener

# Connect to Twitch
bot = listener.connect_twitch('yourUsernameHere', 
                             'yourOauthHere', 
                             'yourClientIDHere')

# List of channels to connect to
channels_to_listen_to = ['Northernlion', 'DumbDog', 'DanGheesling']

# Scrape live chat data into raw log files. (Duration is seconds)
bot.listen(channels_to_listen_to, duration = 1800) 

# Convert log files into .CSV format
bot.parse_logs(timestamp = True)

# Generate adjacency matrix
bot.adj_matrix(weighted = False, matrix_name = "streamer_network.csv")