Update standalone_twitch_pubsub copy.py
This commit is contained in:
parent
6c485d6d2c
commit
0e15d236e6
@ -14,11 +14,12 @@ credentials_manager.load_credentials()
|
|||||||
twitchCredential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
twitchCredential = credentials_manager.find_Twitch_Credential(config.credentialsNickname)
|
||||||
|
|
||||||
def callback_channelPoints(self, uuid: UUID, data: dict) -> None:
|
def callback_channelPoints(self, uuid: UUID, data: dict) -> None:
|
||||||
print("Channel Point Redemption")
|
print("\nChannel Point Detection")
|
||||||
print('got callback for UUID ' + str(uuid))
|
print('got callback for UUID ' + str(uuid))
|
||||||
pprint(data)
|
pprint(data)
|
||||||
|
|
||||||
def callback_whisper(uuid: UUID, data: dict) -> None:
|
def callback_whisper(uuid: UUID, data: dict) -> None:
|
||||||
|
print("\nWhisper Detection")
|
||||||
print('got callback for UUID ' + str(uuid))
|
print('got callback for UUID ' + str(uuid))
|
||||||
pprint(data)
|
pprint(data)
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ twitch = Twitch(twitchCredential.pubsub_client_id, twitchCredential.pubsub_secre
|
|||||||
twitch.authenticate_app([])
|
twitch.authenticate_app([])
|
||||||
# you can get your user auth token and user auth refresh token following the example in twitchAPI.oauth
|
# you can get your user auth token and user auth refresh token following the example in twitchAPI.oauth
|
||||||
|
|
||||||
target_scope = [AuthScope.WHISPERS_READ, AuthScope.CHANNEL_READ_REDEMPTIONS]
|
target_scope = [AuthScope.WHISPERS_READ, AuthScope.CHANNEL_READ_REDEMPTIONS, AuthScope.CHANNEL_MANAGE_REDEMPTIONS]
|
||||||
auth = UserAuthenticator(twitch, target_scope, force_verify=True)
|
auth = UserAuthenticator(twitch, target_scope, force_verify=True)
|
||||||
token, refresh_token = auth.authenticate()
|
token, refresh_token = auth.authenticate()
|
||||||
if token is not None: print("found token")
|
if token is not None: print("found token")
|
||||||
@ -47,11 +48,11 @@ pubsub = PubSub(twitch)
|
|||||||
pubsub.ping_frequency = 30
|
pubsub.ping_frequency = 30
|
||||||
pubsub.start()
|
pubsub.start()
|
||||||
|
|
||||||
#uuid1 = pubsub.listen_whispers(user_id, callback_whisper)
|
uuid1 = pubsub.listen_whispers(user_id, callback_whisper)
|
||||||
uuid2 = pubsub.listen_channel_points(user_id, callback_channelPoints)
|
uuid2 = pubsub.listen_channel_points(user_id, callback_channelPoints)
|
||||||
|
|
||||||
input('press ENTER to close...')
|
input('press ENTER to close...')
|
||||||
# you do not need to unlisten to topics before stopping but you can listen and unlisten at any moment you want
|
# you do not need to unlisten to topics before stopping but you can listen and unlisten at any moment you want
|
||||||
#pubsub.unlisten(uuid1)
|
pubsub.unlisten(uuid1)
|
||||||
pubsub.unlisten(uuid2)
|
pubsub.unlisten(uuid2)
|
||||||
pubsub.stop()
|
pubsub.stop()
|
||||||
Loading…
Reference in New Issue
Block a user