Skip to main content

A TwitchPlays API

Project description

Twitch Plays hackRU

twitch_plays_hackru is a Python library for twitch chatters to be able to vote on commands in a game.

Installation

Use the package manager to install twitch_plays_hackru.

Usage

Importing the classes:

from twitch_plays_hackru import TwitchPlaysOnline, TwitchPlaysOffline

Initializing the TwitchPlaysOnline or TwitchPlaysOffline object:

voteingOptions = ["1","2","3","hi","bye"]
tPlays = TwitchPlaysOffline("irc.twitch.tv", 6667, "oauth:YOUR_OATH_CODE_HERE", "TwitchBot", "YOUR_CHANNEL_NAME_HERE", "YOUR_CHANNEL_NAME_HERE", voteingOptions)

The object will take in 7 parameters:
SERVER: the server that the bot will be interacting with. In this case it will always be "irc.twitch.tv"
PORT: the port you would like use.
PASS: the OAuth code for the twitch channel you would like this bot to listen on. Use twitchapp.com/tmi/ to generate the OAuth code for your twitch channel.
BOT: the nickname of the bot.
CHANNEL: the name of the channel you would like this bot to listen on.
OWNER: the username of the owner of the channel you would like this bot to listen on.
OPTIONS = []: an array of options that you would like the bot to keep track of.

Chatters voting:

The initialization of the bot will also startup the bot. This means that the bot will send a "Hello World" message in the chat and then begin to listen to all of the chat responses.
Chatters will preface their vote option by using play_ . For example, a vote for hi from the code above must be typed play_hi. It is not case sensitive.

Functions:

vote_results():

result = tPlays.vote_results()

vote_results() returns the majority vote since the last call of vote_results(). The number of votes for all options are reset to 0 after the call. If there are no votes since the last call of vote_results(), None is returned.

License

GNU

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

twitch_plays_hackru-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file twitch_plays_hackru-1.0.0.tar.gz.

File metadata

  • Download URL: twitch_plays_hackru-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for twitch_plays_hackru-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4c47ef69c337968262a89a23500165888c93d0fc4c8fa9d69dc5c64f689e0353
MD5 5ad806acf6bb54085efa400bfc5d25b9
BLAKE2b-256 e62f7f5f456c6afd94a75fe947c6f5ba00eff6c295bebffb3560bc79215dd2b2

See more details on using hashes here.

Supported by

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