diff --git a/chat_listener.py b/chat_listener.py index 11ce1b3..244cca6 100644 --- a/chat_listener.py +++ b/chat_listener.py @@ -1,11 +1,16 @@ from twitchio.ext import commands class TwitchBot(commands.Bot): - def __init__(self, access_token: str, channel_name: str): + def __init__(self, access_token: str, client_id: str, client_secret: str, bot_id: str, channel_name: str): super().__init__( token=access_token, prefix='!', # A prefix is required but won't be used for reading chat - initial_channels=[channel_name] + initial_channels=[channel_name], + # These are now required by twitchio + client_id=client_id, + client_secret=client_secret, + # The 'bot_id' is the Twitch ID of the user account the bot is running as + id=bot_id ) self.channel_name = channel_name diff --git a/listener_manager.py b/listener_manager.py index 058ebcc..8ea9925 100644 --- a/listener_manager.py +++ b/listener_manager.py @@ -3,6 +3,7 @@ from typing import Dict from chat_listener import TwitchBot import security # To decrypt tokens +from config import settings # To get client_id and client_secret class ListenerManager: def __init__(self): @@ -23,7 +24,13 @@ class ListenerManager: tokens = security.decrypt_tokens(user.encrypted_tokens) access_token = tokens['access_token'] - bot = TwitchBot(access_token=access_token, channel_name=user.username) + bot = TwitchBot( + access_token=access_token, + channel_name=user.username, + client_id=settings.TWITCH_CLIENT_ID, + client_secret=settings.TWITCH_CLIENT_SECRET, + bot_id=user.platform_user_id + ) task = asyncio.create_task(bot.start()) self.active_listeners[user.id] = task