Update standalone_twitch_pubsub.py
This commit is contained in:
parent
b91058660a
commit
7ab37a62b9
@ -17,21 +17,23 @@ class Twitch_Pubsub():
|
|||||||
self.credential : credentials.Twitch_Credential()
|
self.credential : credentials.Twitch_Credential()
|
||||||
self.twitch : Twitch()
|
self.twitch : Twitch()
|
||||||
self.pubsub: PubSub()
|
self.pubsub: PubSub()
|
||||||
self.target_scope = [AuthScope.CHANNEL_READ_REDEMPTIONS, AuthScope.CHANNEL_MANAGE_REDEMPTIONS]
|
self.target_scope = [AuthScope.CHANNEL_READ_REDEMPTIONS]
|
||||||
|
|
||||||
|
self.uuid = None
|
||||||
|
|
||||||
#Making setup function properly should make all of this run.
|
#Making setup function properly should make all of this run.
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.twitch.authenticate_app([])
|
self.twitch.authenticate_app(self.target_scope)
|
||||||
|
|
||||||
self.twitch.set_user_authentication(self.credential.pubsub_AccessToken, self.target_scope, self.credential.pubsub_RefreshToken)
|
self.twitch.set_user_authentication(self.credential.pubsub_AccessToken, self.target_scope, self.credential.pubsub_RefreshToken)
|
||||||
|
|
||||||
def get_tokens(self):
|
def get_tokens(self):
|
||||||
self.twitch.authenticate_app([])
|
self.twitch.authenticate_app(self.target_scope)
|
||||||
auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=False)
|
auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True)
|
||||||
token, refresh_token = auth.authenticate()
|
token, refresh_token = auth.authenticate()
|
||||||
print(token)
|
print(token)
|
||||||
print(refresh_token)
|
print(refresh_token)
|
||||||
#self.twitch.set_user_authentication(token, self.target_scope, refresh_token)
|
self.twitch.set_user_authentication(token, self.target_scope, refresh_token)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.pubsub = PubSub(self.twitch)
|
self.pubsub = PubSub(self.twitch)
|
||||||
@ -41,14 +43,12 @@ class Twitch_Pubsub():
|
|||||||
def next(self):
|
def next(self):
|
||||||
user_id = self.twitch.get_users(logins=['my_username'])['data'][0]['id']
|
user_id = self.twitch.get_users(logins=['my_username'])['data'][0]['id']
|
||||||
#uuid = self.pubsub.listen_whispers(user_id, self.callback_whisper)
|
#uuid = self.pubsub.listen_whispers(user_id, self.callback_whisper)
|
||||||
points = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints)
|
#print(user_id)
|
||||||
|
self.uuid = self.pubsub.listen_channel_points(user_id, self.callback_channelPoints)
|
||||||
input('press ENTER to close...')
|
input('press ENTER to close...')
|
||||||
|
|
||||||
self.stop(points)
|
def stop(self):
|
||||||
#self.stop(uuid)
|
self.pubsub.unlisten(self.uuid)
|
||||||
|
|
||||||
def stop(self, thing):
|
|
||||||
self.pubsub.unlisten(thing)
|
|
||||||
self.pubsub.stop()
|
self.pubsub.stop()
|
||||||
|
|
||||||
def callback_whisper(self, uuid: UUID, data: dict) -> None:
|
def callback_whisper(self, uuid: UUID, data: dict) -> None:
|
||||||
@ -66,9 +66,11 @@ if __name__ == "__main__":
|
|||||||
credentials_manager = credentials.Credentials_Module()
|
credentials_manager = credentials.Credentials_Module()
|
||||||
credentials_manager.load_credentials()
|
credentials_manager.load_credentials()
|
||||||
testModule.credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
testModule.credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||||
testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret)
|
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']))
|
pprint(testModule.twitch.get_users(logins=['thecuriousnerd']))
|
||||||
|
|
||||||
#testModule.get_tokens()
|
testModule.get_tokens()
|
||||||
testModule.setup()
|
#testModule.setup()
|
||||||
testModule.start()
|
testModule.start()
|
||||||
|
testModule.next()
|
||||||
|
testModule.stop()
|
||||||
Loading…
Reference in New Issue
Block a user