diff --git a/requirements_sa_twitch_pubsub.txt b/requirements_sa_twitch_pubsub.txt index a1dcd13..bfa5876 100644 --- a/requirements_sa_twitch_pubsub.txt +++ b/requirements_sa_twitch_pubsub.txt @@ -1,4 +1,4 @@ -twitch-python +twitchAPI psutil art requests \ No newline at end of file diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index fe9b376..da2bf5d 100644 --- a/standalone_twitch_pubsub.py +++ b/standalone_twitch_pubsub.py @@ -17,11 +17,11 @@ class Twitch_Pubsub(): self.credential : credentials.Twitch_Credential() self.twitch : Twitch() self.pubsub: PubSub() - self.target_scope = [AuthScope.CHANNEL_READ_REDEMPTIONS] + self.target_scope = [AuthScope.WHISPERS_READ, AuthScope.CHANNEL_READ_REDEMPTIONS] - self.uuid = None + self.uuid_1 = None + self.uuid_2 = None - #Making setup function properly should make all of this run. def setup(self): self.twitch.authenticate_app(self.target_scope) @@ -29,26 +29,36 @@ class Twitch_Pubsub(): def get_tokens(self): self.twitch.authenticate_app(self.target_scope) + for scope_ in self.target_scope: + print(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() - print(token) - print(refresh_token) + + if token is not None: print("found token") + if refresh_token is not None: print("found refresh_token") + #print(token) + #print(refresh_token) + self.twitch.set_user_authentication(token, self.target_scope, refresh_token) def start(self): self.pubsub = PubSub(self.twitch) + #self.pubsub.ping_frequency = 30 self.pubsub.start() print("started") + # TwitchAuthorizationException() gets raised by the listen_channel_points def next(self): user_id = self.twitch.get_users(logins=['my_username'])['data'][0]['id'] - #uuid = self.pubsub.listen_whispers(user_id, self.callback_whisper) + if user_id is not None: print("found user_id") #print(user_id) - self.uuid = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints) + self.uuid_1 = self.pubsub.listen_whispers(user_id, self.callback_whisper) + self.uuid_2 = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints) input('press ENTER to close...') def stop(self): - self.pubsub.unlisten(self.uuid) + self.pubsub.unlisten(self.uuid_1) + self.pubsub.unlisten(self.uuid_2) self.pubsub.stop() def callback_whisper(self, uuid: UUID, data: dict) -> None: @@ -66,8 +76,8 @@ if __name__ == "__main__": credentials_manager = credentials.Credentials_Module() credentials_manager.load_credentials() testModule.credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname) - testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret, target_app_auth_scope=testModule.target_scope) - pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) + testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret) + #pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) testModule.get_tokens() #testModule.setup()