Skip to content

BSBussell/GLRA-Democracy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Channel Point Redemption Manager

A comprehensive tool for automatically managing Twitch channel point redemptions. This tool monitors your Twitch channel for new redemptions, logs them to a Google Sheet, and automatically marks them as fulfilled on Twitch.

Features

  • 🎯 Real-time Monitoring: Continuously monitors for new channel point redemptions
  • πŸ“Š Google Sheets Integration: Automatically logs redemption data to Google Sheets
  • βœ… Auto-fulfillment: Marks redemptions as fulfilled on Twitch after logging
  • πŸ–₯️ GUI & CLI: Both graphical and command-line interfaces available
  • πŸ”„ Reliable Processing: Handles API rate limits and connection issues gracefully
  • πŸ“ Comprehensive Logging: Detailed logs for debugging and monitoring

Prerequisites

1. Twitch API Credentials

You'll need to create a Twitch application and obtain:

  • Client ID: From your Twitch Developer Console
  • Access Token: OAuth token with channel:manage:redemptions scope

Getting Twitch Credentials:

  1. Go to Twitch Developer Console
  2. Create a new application or use an existing one
  3. Note your Client ID
  4. For the Access Token, you can use tools like:

Required Scopes: channel:manage:redemptions and channel:read:redemptions

2. Google Sheets API Credentials

You'll need a Google Cloud project with Sheets API enabled:

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable the Google Sheets API
  4. Create credentials (Service Account recommended)
  5. Download the credentials JSON file

Service Account Setup (Recommended):

  1. In Google Cloud Console, go to "Credentials"
  2. Create a new Service Account
  3. Download the JSON key file
  4. Share your Google Sheet with the service account email
  5. Save the JSON file as credentials.json in the project directory

3. Google Sheet Setup

  1. Create a new Google Sheet
  2. Copy the Spreadsheet ID from the URL:
    • URL: https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/edit
  3. Share the sheet with your service account email (if using service account)
  4. The tool will automatically create headers in the sheet

Installation

  1. Clone or download this project

  2. Install Python dependencies:

    pip install -r requirements.txt
  3. Set up configuration:

    cp config.example.ini config.ini

    Edit config.ini with your credentials:

    [Twitch]
    access_token = your_twitch_access_token
    client_id = your_twitch_client_id
    broadcaster_id = 
    
    [GoogleSheets]
    credentials_file = credentials.json
    spreadsheet_id = your_google_sheet_id
    sheet_name = Redemptions
    
    [App]
    log_level = INFO
    refresh_interval = 5
    auto_reconnect = True
    watchdog_interval = 30
  4. Place your Google credentials file as credentials.json

Usage

GUI Application (Recommended)

Start the graphical interface:

python main_gui.py

The GUI provides:

  • Control Tab: Start/stop monitoring, test connections, view recent redemptions
  • Configuration Tab: Edit settings without manually editing config files
  • Logs Tab: View real-time application logs

Command Line Interface

Start Monitoring

python main_cli.py monitor

Test Connections

python main_cli.py test

Manual Check for Redemptions

python main_cli.py check

Show Status

python main_cli.py status

Custom Configuration File

python main_cli.py --config /path/to/config.ini monitor

How It Works

  1. Monitor: The tool continuously polls the Twitch API for unfulfilled redemptions
  2. Log: New redemptions are immediately written to your Google Sheet with details:
    • Timestamp
    • Redemption ID
    • Reward title and cost
    • User information
    • User input (if any)
    • Status
  3. Fulfill: After successful logging, the redemption is marked as fulfilled on Twitch
  4. Repeat: The process repeats based on your refresh interval

Google Sheet Data

The tool creates a sheet with these columns:

  • Timestamp: When the redemption was processed
  • Redemption ID: Unique Twitch redemption identifier
  • Reward Title: Name of the channel point reward
  • Reward Cost: Cost in channel points
  • User Name: Twitch username
  • User Display Name: User's display name
  • User Input: Any text input from the user
  • Status: Processing status
  • Redeemed At: Original redemption timestamp from Twitch

Configuration Options

Twitch Settings

  • access_token: Your Twitch OAuth token
  • client_id: Your Twitch application client ID
  • broadcaster_id: Auto-detected broadcaster ID

Google Sheets Settings

  • credentials_file: Path to Google credentials JSON file
  • spreadsheet_id: ID of your Google Sheet
  • sheet_name: Name of the sheet tab (default: "Redemptions")

Application Settings

  • log_level: Logging verbosity (DEBUG, INFO, WARNING, ERROR)
  • refresh_interval: How often to check for new redemptions (seconds)
  • auto_reconnect: Automatically reconnect on connection loss
  • watchdog_interval: Connection health check interval (seconds)

Troubleshooting

Common Issues

"Missing Twitch API credentials"

  • Ensure your access_token and client_id are set in config.ini
  • Verify your access token has the required scopes

"Google Sheets connection failed"

  • Check that credentials.json exists and is valid
  • Ensure the Google Sheets API is enabled in your Google Cloud project
  • Verify the spreadsheet is shared with your service account

"No redemptions found"

  • Make sure you have channel point rewards set up
  • Check that there are actually unfulfilled redemptions
  • Verify your broadcaster ID is correct

Rate Limiting

  • The tool handles Twitch rate limits automatically
  • If you see rate limit warnings, consider increasing the refresh interval

Logs

Check the application logs for detailed error information:

  • GUI: View logs in the "Logs" tab
  • CLI: Check console output and redemption_manager.log file

Security Notes

  • Keep your Twitch access token secure and private
  • Regenerate tokens periodically
  • Use service accounts for Google Sheets integration
  • Don't commit credentials to version control

Development

The project is structured as follows:

  • config_manager.py: Configuration handling
  • twitch_api_client.py: Twitch API communication
  • google_sheets_manager.py: Google Sheets integration
  • redemption_manager.py: Core business logic
  • main_gui.py: PyQt5 graphical interface
  • main_cli.py: Command-line interface

License

This project is open source. Feel free to modify and distribute as needed.

Support

For issues or questions:

  1. Check the logs for error details
  2. Verify your configuration is correct
  3. Test connections using the test feature
  4. Review the Twitch API documentation for any changes

About

The Voting System used for tallying and displaying votes to the public.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors