TEMPORARY AUTO DROP CLAIMING FIX

This commit is contained in:
Roman Davydov
2023-08-11 23:27:59 +03:00
parent 1434f5ecf8
commit 73ed8b8708
3 changed files with 30 additions and 16 deletions

View File

@@ -88,7 +88,8 @@ class TwitchChannelPointsMiner:
):
# Fixes TypeError: 'NoneType' object is not subscriptable
if not username or username == "your-twitch-username":
logger.error("Please edit your runner file (usually run.py) and try again.")
logger.error(
"Please edit your runner file (usually run.py) and try again.")
logger.error("No username, exiting...")
sys.exit(0)
@@ -163,14 +164,16 @@ class TwitchChannelPointsMiner:
logger.info(
f"Twitch Channel Points Miner v2-{current_version} (fork by rdavydov)"
)
logger.info("https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2")
logger.info(
"https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2")
if github_version == "0.0.0":
logger.error(
"Unable to detect if you have the latest version of this script"
)
elif current_version != github_version:
logger.info(f"You are running the version {current_version} of this script")
logger.info(
f"You are running the version {current_version} of this script")
logger.info(f"The latest version on GitHub is: {github_version}")
for sign in [signal.SIGINT, signal.SIGSEGV, signal.SIGTERM]:
@@ -194,7 +197,8 @@ class TwitchChannelPointsMiner:
http_server.name = "Analytics Thread"
http_server.start()
else:
logger.error("Can't start analytics(), please set enable_analytics=True")
logger.error(
"Can't start analytics(), please set enable_analytics=True")
def mine(
self,
@@ -240,7 +244,8 @@ class TwitchChannelPointsMiner:
streamers_dict[username] = streamer
if followers is True:
followers_array = self.twitch.get_followers(order=followers_order)
followers_array = self.twitch.get_followers(
order=followers_order)
logger.info(
f"Load {len(followers_array)} followers from your profile!",
extra={"emoji": ":clipboard:"},
@@ -263,7 +268,8 @@ class TwitchChannelPointsMiner:
if isinstance(streamers_dict[username], Streamer) is True
else Streamer(username)
)
streamer.channel_id = self.twitch.get_channel_id(username)
streamer.channel_id = self.twitch.get_channel_id(
username)
streamer.settings = set_default_settings(
streamer.settings, Settings.streamer_settings
)
@@ -305,7 +311,8 @@ class TwitchChannelPointsMiner:
# If we have at least one streamer with settings = claim_drops True
# Spawn a thread for sync inventory and dashboard
if (
at_least_one_value_in_settings_is(self.streamers, "claim_drops", True)
at_least_one_value_in_settings_is(
self.streamers, "claim_drops", True)
is True
):
self.sync_campaigns_thread = threading.Thread(
@@ -364,12 +371,14 @@ class TwitchChannelPointsMiner:
if streamer.settings.make_predictions is True:
self.ws_pool.submit(
PubsubTopic("predictions-channel-v1", streamer=streamer)
PubsubTopic("predictions-channel-v1",
streamer=streamer)
)
if streamer.settings.claim_moments is True:
self.ws_pool.submit(
PubsubTopic("community-moments-channel-v1", streamer=streamer)
PubsubTopic("community-moments-channel-v1",
streamer=streamer)
)
refresh_context = time.time()
@@ -386,7 +395,8 @@ class TwitchChannelPointsMiner:
logger.info(
f"#{index} - The last PING was sent more than 10 minutes ago. Reconnecting to the WebSocket..."
)
WebSocketsPool.handle_reconnection(self.ws_pool.ws[index])
WebSocketsPool.handle_reconnection(
self.ws_pool.ws[index])
if ((time.time() - refresh_context) // 60) >= 30:
refresh_context = time.time()

View File

@@ -694,14 +694,11 @@ class Twitch(object):
def __get_drops_dashboard(self, status=None):
response = self.post_gql_request(GQLOperations.ViewerDropsDashboard)
campaigns = response["data"]["currentUser"]["dropCampaigns"]
if campaigns is None:
return [] # Return an empty list if campaigns is None
campaigns = response["data"]["currentUser"]["dropCampaigns"] or []
if status is not None:
campaigns = list(
filter(lambda x: x["status"] == status.upper(), campaigns))
filter(lambda x: x["status"] == status.upper(), campaigns)) or []
return campaigns
@@ -798,6 +795,11 @@ class Twitch(object):
or ((time.time() - campaigns_update) / 60) > 60
):
campaigns_update = time.time()
# TEMPORARY AUTO DROP CLAIMING FIX
self.claim_all_drops_from_inventory()
#####################################
# Get full details from current ACTIVE campaigns
# Use dashboard so we can explore new drops not currently active in our Inventory
campaigns_details = self.__get_campaigns_details(

View File

@@ -112,6 +112,7 @@ class GQLOperations:
Inventory = {
"operationName": "Inventory",
"variables": {"fetchRewardCampaigns": True},
# "variables": {},
"extensions": {
"persistedQuery": {
"version": 1,
@@ -130,7 +131,8 @@ class GQLOperations:
}
ViewerDropsDashboard = {
"operationName": "ViewerDropsDashboard",
"variables": {},
# "variables": {},
"variables": {"fetchRewardCampaigns": True},
"extensions": {
"persistedQuery": {
"version": 1,