#!/usr/bin/env python3 import json from twitchAPI.twitch import Twitch from twitchAPI.helper import first from package.config import CHANNEL_NAME as CHANNEL_NAME # 1. Fill in your credentials from the Twitch Developer Console SECRETS = None TWITCH = None USER = None async def get_twitch(): global SECRETS, TWITCH, USER if SECRETS is None: with open('twitch_secrets.json', 'r') as f: SECRETS = json.load(f) if TWITCH is None: TWITCH = await Twitch(SECRETS['client_id'], SECRETS['client_secret']) if USER is None: USER = await first(TWITCH.get_users(logins=[CHANNEL_NAME])) if not USER: print("User not found.")